我开始为我的生物信息学项目编写管道,并且我使用Snakemake作为工作流程。 我制作了官方网站的所有教程和一些文档。
我想运行一个shell命令,就像这样:
fastp -i input-1 -I input-2 -o output-1 -O output-2
我在Snakefile中的代码:
SAMPLES = ['1', '2', '3', '4']
rule fastp:
input:
reads1=expand("sample{sample}.R1.fq.gz", sample=SAMPLES),
reads2=expand("sample{sample}.R2.fq.gz", sample=SAMPLES)
output:
reads1out=expand("sample{sample}.R1.fq.gz.out", sample=SAMPLES),
reads2out=expand("sample{sample}.R2.fq.gz.out", sample=SAMPLES)
shell:
"fastp -i {input.reads1} -I {input.reads2} -o {output.reads1out} -O {output.reads2out}"
但程序运行这一行代码:
fastp -i sample1.R1.fq.gz sample2.R1.fq.gz sample3.R1.fq.gz sample4.R1.fq.gz -I sample1.R2.fq.gz sample2.R2.fq.gz sample3.R2.fq.gz sample4.R2.fq.gz -o sample1.R1.fq.gz.out sample2.R1.fq.gz.out sample3.R1.fq.gz.out sample4.R1.fq.gz.out -O sample1.R2.fq.gz.out sample2.R2.fq.gz.out sample3.R2.fq.gz.out sample4.R2.fq.gz.out
如何编写程序为每个样本执行不同的shell命令?我在for i in SAMPLES:
之后尝试rule fastp:
,但没有工作,我不知道我现在可以尝试什么。很抱歉,如果这个主题在某种程度上太基础,但我是Python中的菜鸟。
谢谢。
答案 0 :(得分:0)
您需要define target使用rule all
输出文件。
SAMPLES = ['1', '2', '3', '4']
rule all:
input:
expand("sample{sample}.R{read_no}.fq.gz.out", sample=SAMPLES, read_no=['1', '2'])
rule fastp:
input:
reads1="sample{sample}.R1.fq.gz",
reads2="sample{sample}.R2.fq.gz"
output:
reads1out="sample{sample}.R1.fq.gz.out",
reads2out="sample{sample}.R2.fq.gz.out"
shell:
"fastp -i {input.reads1} -I {input.reads2} -o {output.reads1out} -O {output.reads2out}"
答案 1 :(得分:0)
这是命令snakemake -np的输出,带有rule all:
,正如JeeYem所写:
λ fastp/testdata master ✗ snakemake -np
rule fastp:
input: sample1.R1.fq.gz, sample2.R1.fq.gz, sample3.R1.fq.gz, sample4.R1.fq.gz, sample1.R2.fq.gz, sample2.R2.fq.gz, sample3.R2.fq.gz, sample4.R2.fq.gz
output: sample1.R1.fq.gz.out, sample2.R1.fq.gz.out, sample3.R1.fq.gz.out, sample4.R1.fq.gz.out, sample1.R2.fq.gz.out, sample2.R2.fq.gz.out, sample3.R2.fq.gz.out, sample4.R2.fq.gz.out
jobid: 1
fastp -i sample1.R1.fq.gz sample2.R1.fq.gz sample3.R1.fq.gz sample4.R1.fq.gz -I sample1.R2.fq.gz sample2.R2.fq.gz sample3.R2.fq.gz sample4.R2.fq.gz -o sample1.R1.fq.gz.out sample2.R1.fq.gz.out sample3.R1.fq.gz.out sample4.R1.fq.gz.out -O sample1.R2.fq.gz.out sample2.R2.fq.gz.out sample3.R2.fq.gz.out sample4.R2.fq.gz.out
localrule all:
input: sample1.R1.fq.gz.out, sample1.R2.fq.gz.out, sample2.R1.fq.gz.out, sample2.R2.fq.gz.out, sample3.R1.fq.gz.out, sample3.R2.fq.gz.out, sample4.R1.fq.gz.out, sample4.R2.fq.gz.out
jobid: 0
Job counts:
count jobs
1 all
1 fastp
2