Snakemake: output folder a as dependency to a different rule
1
2
Entering edit mode
4.7 years ago
Veewhy ▴ 20

I want to make sure a genome is indexed by STAR before I use STAR to align the genome.

Currently, I have two rules to achieve this:

rule star_index:
    input:
        gtf = "path/to/gtfFile.gtf",
        fasta = "path/to/assembly.fa"
    output:
        directory("path/to/star/index/directory")
    message:
        "Building STAR Index"
    wrapper:
        "0.36.0/bio/star/index"

rule align_to_genome:
    input: 
        fq1 = "path/to/fastq_forward",
        fq2 = "path/to/fastq_reverse"
    output:
        "star/{sample}/Aligned.out.bam",
        "star/{sample}/ReadsPerGene.out.tab"
    log:
        "logs/star/{sample}.log"
    params:
        index="path/to/star/index/directory"
    wrapper:
        "0.31.1/bio/star/align"

This currently works, but the genome index isn't a dependancy to the mapping, so if it's missing the mapping just fails (whereas I'd want the index to be built). Is the only thing to do to manually specify all the output files of STAR index (and then re-write the wrapper to only use the folder name in the star index command?) That seems quite clunky, as STAR outputs its index to a folder, and also accepts the index as a folder.

Snakemake RNA-Seq • 5.6k views
ADD COMMENT
3
Entering edit mode
4.7 years ago
gb ★ 2.2k

Something like this:

rule star_index:
    input:
        gtf = "path/to/gtfFile.gtf",
        fasta = "path/to/assembly.fa"
    output:
        dir = directory("path/to/star/index/directory")
    message:



 rule align_to_genome:
        input: 
            dir = rules.star_index.output.dir
            fq1 = "path/to/fastq_forward",
            fq2 = "path/to/fastq_reverse"
        output:

Never used the directory output but if it is not possible to do dir = directory("path/to/star/index/directory") You can put one of the output files of star or even create a "fake" file afther the index creation and give that as input to rule align_to_genome

Here the page (with better explanation): https://snakemake.readthedocs.io/en/latest/snakefiles/rules.html#rule-dependencies

ADD COMMENT

Login before adding your answer.

Traffic: 2565 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6