【发布时间】:2020-03-25 17:24:50
【问题描述】:
我有以下 bash 脚本,我想将其转换为蛇文件:
mmseqs rbh flye_db megahit_db flye_megahit_rbh --min-seq-id 0.9 mmseq2_tmp --threads 12
mmseqs rbh flye_db metaspades_db flye_metaspades_rbh --min-seq-id 0.9 mmseq2_tmp --threads 12
mmseqs rbh megahit_db metaspades_db megahit_metaspades_rbh --min-seq-id 0.9 mmseq2_tmp --threads 12
我想出了以下方法,但想知道是否有办法使用正则表达式或扩展来进一步改进代码:
rule mmseq2_compare:
input:
mm1=expand(os.path.join(RESULTS_DIR, "annotation/mmseq2/{assembler}_db"), assembler="flye"),
mm2=expand(os.path.join(RESULTS_DIR, "annotation/mmseq2/{assembler}_db"), assembler="megahit"),
mm3=expand(os.path.join(RESULTS_DIR, "annotation/mmseq2/{assembler}_db"), assembler="metaspades_hybrid")
output:
mo1=os.path.join(RESULTS_DIR, "annotation/mmseq2/flye_megahit_rbh"),
mo2=os.path.join(RESULTS_DIR, "annotation/mmseq2/flye_metaspades_hybrid_rbh"),
mo3=os.path.join(RESULTS_DIR, "annotation/mmseq2/megahit_metaspades_hybrid_rbh")
log: os.path.join(RESULTS_DIR, "annotation/mmseq2/compare.mmseq2.log")
conda: "cd-hit.yml"
shell:
"""
(date &&\
mmseqs rbh {input.mm1} {input.mm2} {output.mo1} --min-seq-id 0.9 mmseq2_tmp --threads 12 &&\
mmseqs rbh {input.mm1} {input.mm3} {output.mo2} --min-seq-id 0.9 mmseq2_tmp --threads 12 &&\
mmseqs rbh {input.mm2} {input.mm3} {output.mo3} --min-seq-id 0.9 mmseq2_tmp --threads 12 &&\
date) &> >(tee {log})
"""
对于 3 个汇编器(flye、megahit 和 metaspades_hybrid),有什么方法可以消除冗余,尤其是在“shell”中?
谢谢!
试运行输出
Building DAG of jobs...
Job counts:
count jobs
1 all
1 mmseq_compare
2
[Thu Mar 26 12:25:14 2020]
rule mmseq_compare:
input: results/annotation/mmseq2/flye_db, results/annotation/mmseq2/megahit_db
output: results/annotation/mmseq2/flye_megahit_rbh
jobid: 1
wildcards: assembler1=flye, assembler2=megahit
mmseqs rbh results/annotation/mmseq2/flye_db results/annotation/mmseq2/megahit_db results/annotation/mmseq2/flye_megahit_rbh --min-seq-id 0.9 mmseq2_tmp --threads 12
[Thu Mar 26 12:25:14 2020]
localrule all:
input: results/annotation/mmseq2/flye_megahit_rbh, results/annotation/mmseq2/flye_metaspades_hybrid_rbh, results/annotation/mmseq2/megahit_metaspades_hybrid_rbh
jobid: 0
Job counts:
count jobs
1 all
1 mmseq_compare
2
This was a dry-run (flag -n). The order of jobs does not reflect the order of execution.```
【问题讨论】:
标签: python shell wildcard snakemake