我有以下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.```