正如你可以閱讀標題,我有興趣將存儲shell命令的結果並將其傳遞給另一個規則。存儲shell命令的結果
貝婁是我的規則:
SAMTOOLS = config["SAMTOOLS"]
rule useDepth:
input:
depth = "{individual}_{chr}.fixmate.sort.rgmdup.bam.depth"
output:
tmpVCF = "{individual}_{chr}.vcf"
run:
depth = storage.fetch("chrDepth")
shell("echo {depth} | exit 1")
rule calDepth:
input:
bam = "{individual}.fixmate.sort.rgmdup.bam"
output:
temp("{individual}_{chr}.fixmate.sort.rgmdup.bam.depth")
run:
import subprocess,shlex
depth=subprocess.check_output(shlex.split("{SAMTOOLS} depth -r {wildcards.chr} {input.bam} | awk '{{sum += $3}} END {{print sum/NR}}'"),shell=True)
storage.store("chrDepth", depth)
shell("echo \"Depth for {wildcards.chr} has been calculated\" > {output[0]}")
我肯定在這裏接受,因爲1號出口的錯誤!但那只是爲了測試。
我試圖解決的錯誤是subprocess.check_output()中{SAMTOOLS}的值!
depth: 1: depth: {SAMTOOLS}: not found
Error in job chrDepth while creating output file
RuleException:
Command '['{SAMTOOLS}', 'depth', '-r', '{wildcards.chr}', '{input.bam}', '|', 'awk', '{{sum += $3}} END {{print sum/NR}}']'
要更多的信息,因爲不同勢用戶可能安裝samtools在不同的地方,我們做samtools的地址,通過CONFIGFILE配置。但是,在這裏我不能:
1)讀取{SAMTOOLS}的正確值!
2)使整個命令可以運行!
那麼,你能否告訴我是否有其他方式存儲/傳遞規則的輸出到另一個規則!?更特別的是,我如何增強snakemake來告訴shell {SAMTOOLS}可用。
謝謝!
正如你所建議的使用SAMTOOLS以外的折扣是訣竅!但是,我想知道爲什麼我以前沒有收到這個錯誤。我正在使用{SAMTOOLS}或其他沒有通配符的程序,我的規則都沒有抱怨這種用法(即我在這些規則中使用shell)。 – khikho