为什么总是忽略或忽略一个蛇形规则

时间:2019-05-10 16:09:03

标签: python workflow snakemake

我正在尝试修复Snakefile。有两个规则(请参见下面的代码),如果只有一个,则每个规则都可以使用,但是同时保留两个规则时,只有规则prernaseqc可以使用。

似乎snakemake完全忽略了另一个。

我尝试触摸文件files_to_rnaseqc.txt等,但没有帮助。为什么?

任何想法都将不胜感激。

import os
configfile: "run.json"
workpath = config['project']['workpath']

samples=sorted(list(config['project']['units'].keys()))

from snakemake.utils import R
from os.path import join
configfile: "run.json"

from os import listdir

star_dir="STAR_files"
bams_dir="bams"
log_dir="logfiles"
rseqc_dir="RSeQC"
kraken_dir="kraken"
preseq_dir="preseq"
pfamily = 'rnaseq'


rule prernaseqc:
   input: 
    expand(join(workpath,bams_dir,"{name}.star_rg_added.sorted.dmark.bam"), name=samples)
   output:
    out1=join(workpath,bams_dir,"files_to_rnaseqc.txt")
   priority: 2
   params: 
    rname='pl:prernaseqc',batch='--mem=4g --time=04:00:00'
   run:
        with open(output.out1, "w") as out:
            out.write("Sample ID\tBam file\tNotes\n")
            for f in input:
                out.write("%s\t"  % f)
                out.write("%s\t"  % f)
                out.write("%s\n"  % f)
            out.close()

rule rnaseqc:
   input:
    join(workpath,bams_dir,"files_to_rnaseqc.txt")
   output:
    join(workpath,"STAR_QC")
   priority: 2
   params: 
    rname='pl:rnaseqc',
    batch='--mem=24g --time=48:00:00',
    bwaver=config['bin'][pfamily]['tool_versions']['BWAVER'],
    rrnalist=config['references'][pfamily]['RRNALIST'],
    rnaseqcver=config['bin'][pfamily]['RNASEQCJAR'],
    rseqcver=config['bin'][pfamily]['tool_versions']['RSEQCVER'],   
    gtffile=config['references'][pfamily]['GTFFILE'],
    genomefile=config['references'][pfamily]['GENOMEFILE']

   shell: """
module load {params.bwaver}
module load {params.rseqcver}

var="{params.rrnalist}"
if [  $var == "-" ]; then
      java -Xmx48g -jar {params.rnaseqcver} -n 1000 -s {input} -t {params.gtffile} -r {params.genomefile}  -o {output}
else
      java -Xmx48g -jar {params.rnaseqcver} -n 1000 -s {input} -t {params.gtffile} -r {params.genomefile} -rRNA {params.rrnalist}  -o {output}
fi

1 个答案:

答案 0 :(得分:0)

Snakemake在设计上会将文件第一条规则中列出的输出文件用作目标文件(即需要创建的文件)。因此,在您的情况下,无论哪个规则恰好是第一个被执行,而另一个则未执行。

您需要specify a target rule列出所有输出文件。通常将其命名为rule all

rule all:
    input:
        join(workpath,bams_dir,"files_to_rnaseqc.txt"),
        join(workpath,"STAR_QC")