celalp
celalp

Reputation: 101

output of one rule as input of another

I am new to snakemake and I'm trying to write a complex pipeline with many steps and branching points. One of the earlier steps is a STAR alignment.

Here I want to use the genome alignment for some stuff and the transcriptome aligment for others. I'm outputting two output files and I want to use each of these as inputs for other rules in snakemake.

If possible I want to avoid using actual filenames and I want snakemake to deal with it for me.

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
        """

So then I wan to use something like

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

I'm not even sure if this is possible.

Upvotes: 1

Views: 847

Answers (1)

celalp
celalp

Reputation: 101

EDIT: nwm here is the solution

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

rule2
  input:rules.rule1.output.out1

Upvotes: 3

Related Questions