jkim
jkim

Reputation: 91

Snakemake rules

I want to use snakemake for making a bioinformatics pipeline and I googled it and read documents and other stuff, but I still don't know how to get it works.

Here are some of my raw data files.

Rawdata/010_0_bua_1.fq.gz, Rawdata/010_0_bua_2.fq.gz
Rawdata/11_15_ap_1.fq.gz, Rawdata/11_15_ap_2.fq.gz

...they are all paired files.)

Here is my align.snakemake

from os.path import join


STAR_INDEX = "/app/ref/ensembl/human/idx/"
SAMPLE_DIR = "Rawdata"
SAMPLES, = glob_wildcards(SAMPLE_DIR + "/{sample}_1.fq.gz")

R1 = '{sample}_1.fq.gz'
R2 = '{sample}_2.fq.gz'


rule alignment:
    input:
        r1 = join(SAMPLE_DIR, R1),
        r2 = join(SAMPLE_DIR, R2),
    params:
        STAR_INDEX = STAR_INDEX
    output:
        "Align/{sample}.bam"
    message:
        "--- mapping STAR---"
    shell:"""
        mkdir -p Align/{wildcards.sample}
        STAR --genomeDir {params.STAR_INDEX} --readFilesCommand zcat  --readFilesIn {input.r1} {input.r2}  --outFileNamePrefix Align/{wildcards.sample}/log
"""

This is it. I run this file by "snakemake -np -s align.snakemake" and I got this error.

WorkflowError: Target rules may not contain wildcards. Please specify concrete files or a rule without wildcards.

I am sorry that I ask this question, there are many people using it pretty well though. any help would be really appriciated. Sorry for my English.

P.S. I read the official document and tutorial but still have no idea.

Upvotes: 0

Views: 296

Answers (1)

jkim
jkim

Reputation: 91

Oh I did. Here is my answer to my question for some people might want some help.

  from os.path import join


STAR_INDEX = "/app/ref/ensembl/human/idx/"
SAMPLE_DIR = "Rawdata"
SAMPLES, = glob_wildcards(SAMPLE_DIR + "/{sample}_1.fq.gz")

R1 = '{sample}_1.fq.gz'
R2 = '{sample}_2.fq.gz'


rule all:
    input:
        expand("Align/{sample}/Aligned.toTranscriptome.out.bam", sample=SAMPLES)

rule alignment:
    input:
        r1 = join(SAMPLE_DIR, R1),
        r2 = join(SAMPLE_DIR, R2)
    params:
        STAR_INDEX = STAR_INDEX
    output:
        "Align/{sample}/Aligned.toTranscriptome.out.bam"
    threads:
        8
    message:
        "--- Mapping STAR---"
    shell:"""
        mkdir -p Align/{wildcards.sample}
        STAR --genomeDir {params.STAR_INDEX} --outSAMunmapped Within --outFilterType BySJout --outSAMattributes NH HI AS NM MD --outFilterMultimapNmax 20 --outFilterMismatchNmax 999  --outFilterMismatchNoverLmax 0.04  --alignIntronMin 20  --alignIntronMax 1000000  --alignMatesGapMax 1000000  --alignSJoverhangMin 8  --alignSJDBoverhangMin 1  --sjdbScore 1  --runThreadN {threads}  --genomeLoad NoSharedMemory  --outSAMtype BAM Unsorted  --quantMode TranscriptomeSAM  --outSAMheaderHD \@HD VN:1.4 SO:unsorted  --readFilesCommand zcat  --readFilesIn {input.r1} {input.r2}  --outFileNamePrefix Align/{wildcards.sample}/log
"""

Upvotes: 1

Related Questions