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

2024-09-19 23:45:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我在修一个蛇形锉刀。有两个规则(请参见下面的代码),如果只有一个规则,每个规则都可以工作,但是只有规则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

Tags: importconfiginputoutput规则dirfilesparams
1条回答
网友
1楼 · 发布于 2024-09-19 23:45:25

根据设计,Snakemake使用文件第一个规则中列出的输出文件作为目标文件(即需要创建的文件)。因此,在您的例子中,无论哪条规则碰巧是第一条,都将被执行,而另一条规则仍然没有执行。在

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

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

相关问题 更多 >