hisat2.rule.snakefile 2.68 KB
Newer Older
khalid's avatar
khalid committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if config["SeOrPe"] == "PE":

    rule <step_name>__hisat2_PE:
        input:
            **<step_name>__hisat2_PE_inputs()
        output:
            bam = config["results_dir"]+"/"+config["<step_name>__hisat2_PE_output_dir"]+"/{sample}.bam"
        log:
            config["results_dir"]+"/logs/" + config["<step_name>__hisat2_PE_output_dir"] + "/{sample}_hisat2_log.txt"
        threads:
            config["<step_name>__hisat2_threads"]
        params:
            command = config["<step_name>__hisat2_PE_command"],
            #indexPrefix = config["<step_name>__hisat2_index_output_dir"]+"/index",
            #here we have index files  : from .1.ht2 to .8.ht2
            indexPrefix = lambda w, input: os.path.splitext(os.path.splitext([x for x in input.index ][0])[0])[0],
            minins = config["<step_name>__hisat2_minins_PE"],
            maxins = config["<step_name>__hisat2_maxins_PE"],
            orientation = config["<step_name>__hisat2_orientation_PE"],
        shell:
21
            "{params.command} --new-summary "
khalid's avatar
khalid committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
            "--threads {threads} "
            "-x {params.indexPrefix} "
            "-I {params.minins} "
            "-X {params.maxins} "
            "{params.orientation} "
            "--rg-id ID:WAW --rg SM:{wildcards.sample} "
            #"-S "#output in sam format
            "-1 {input.read} "
            "-2 {input.read2} 2> {log} "
            "| samtools view -b 2>> {log} "
            "| samtools sort -@ {threads} > {output.bam} 2>> {log} &&"
            "samtools index -@ {threads} {output.bam} 2>> {log}"

elif config["SeOrPe"] == "SE":

    rule <step_name>__hisat2_SE:
        input:
            **<step_name>__hisat2_SE_inputs()
        output:
            bam = config["results_dir"]+"/"+config["<step_name>__hisat2_SE_output_dir"]+"/{sample}.bam"
        log:
            config["results_dir"]+"/logs/" + config["<step_name>__hisat2_SE_output_dir"] + "/{sample}_hisat2_log.txt"
        threads:
            config["<step_name>__hisat2_threads"]
        params:
            command = config["<step_name>__hisat2_SE_command"],
            #indexPrefix = config["<step_name>__hisat2_index_output_dir"]+"/index",
            indexPrefix = lambda w, input: os.path.splitext(os.path.splitext([x for x in input.index if not 'rev' in x][0])[0])[0],
        shell:
            "{params.command} "
            "--threads {threads} "
            "-x {params.indexPrefix} "
            "--rg-id ID:WAW --rg SM:{wildcards.sample} "
            #"-S "#output in sam format
56
            " -Ub{input.read} 2> {log} "
khalid's avatar
khalid committed
57
58
59
            "| samtools view -b 2>> {log} "
            "| samtools sort -@ {threads} > {output.bam} 2>> {log} &&"
            "samtools index -@ {threads} {output.bam} 2>> {log}"