一个规则的输出作为另一个规则的输入

时间:2019-09-12 17:31:53

标签: snakemake

我是snakemake的新手,我正在尝试编写具有许多步骤和分支点的复杂管道。较早的步骤之一是STAR对齐。

在这里,我想对一些东西使用基因组比对,对其他东西使用转录组匹配。我正在输出两个输出文件,我想将它们中的每个用作蛇形中其他规则的输入。

如果可能的话,我想避免使用实际的文件名,而是让snakemake为我处理它。

rule star:
    input:
        reads=samples.iloc[0,1].split(",")
    output:
        tx_align=temp("/".join([output_directory, "star", samplename+"Aligned.toTranscriptome.out.bam"])),
        genome_align="/".join([output_directory, "star", samplename+"Aligned.sortedByCoord.out.bam"])
    params:
        index=config["resources"]["star_index"],
        gtf=config["resources"]["gtf"],
        prefix="/".join([output_directory, "star", samplename])
    log: config["root_dir"]+"/"+str{samples["samplename"]}+"star.log"
    threads: 10
    shell:
        """
        STAR --runMode alignReads \
        --runThreadN {threads} \
        --readFilesCommand zcat \
        --readFilesIn {reads} \
        --genomeDir {params.index} \
        --outFileNamePrefix {params.prefix} \
        --twopassMode Basic \
        --sjdbGTFfile {params.gtf} \
        --outFilterType BySJout \
        --limitSjdbInsertNsj 1200000 \
        --outSAMstrandField intronMotif \
        --outFilterIntronMotifs None \
        --alignSoftClipAtReferenceEnds Yes \
        --quantMode TranscriptomeSAM GeneCounts \
        --outSAMtype BAM SortedByCoordinate \
        --outSAMattrRGline ID:{samplename}, SM:sm1 \
        --outSAMattributes All \
        --outSAMunmapped Within \
        --outSAMprimaryFlag AllBestScore \
        --chimSegmentMin 15 \
        --chimJunctionOverhangMin 15 \
        --chimOutType Junctions \
        --chimMainSegmentMultNmax 1 \
        --genomeLoad NoSharedMemory
        """

所以我想用类似的东西

rule rsem:
    input:
        rules.star.ouput[0]
    output:
        somefile
    run:
       etc

我什至不确定这是否可行。

1 个答案:

答案 0 :(得分:1)

编辑: nwm这是解决方案

rule1
  input: some_input
  output:
     out1=output1,
     out2=output2
  shell:
     "command {input} {out1} {out2}"

rule2
  input:rules.rule1.output.out1