mapping.smk 1.55 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
rule bwa_index:
    input:
        config["resources"]["ref"]["genome"]
    output:
        multiext(config["resources"]["ref"]["genome"], ".amb", ".ann", ".bwt", ".pac", ".sa")
    log:
        "logs/bwa/bwa_index.log"
    params:
        algorithm="bwtsw"
    wrapper:
Antonie Vietor's avatar
Antonie Vietor committed
11
        "0.60.0/bio/bwa/index"
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

rule bwa_mem:
    input:
        reads = get_map_reads_input,
        idx = rules.bwa_index.output
    output:
        temp("results/mapped/{sample}-{unit}.bam")
    log:
        "logs/bwa/bwa_mem/{sample}-{unit}.log"
    params:
        index= lambda w, input: os.path.splitext(input.idx[0])[0],
        extra= get_read_group,
        sort="samtools",
        sort_order="coordinate",
    threads: 8
    wrapper:
Antonie Vietor's avatar
Antonie Vietor committed
28
        "0.60.0/bio/bwa/mem"
29
30
31
32
33
34
35
36
37
38
39
40
41
42

rule merge_bams:
    input:
        lambda w: expand("results/mapped/{sample}-{unit}.bam",
            sample = w.sample,
            unit = units.loc[units['sample'] == w.sample].unit.to_list()
        )
    output:
        temp("results/merged/{sample}.bam")
    log:
        "logs/picard/mergebamfiles/{sample}.log"
    params:
        "VALIDATION_STRINGENCY=LENIENT"
    wrapper:
Antonie Vietor's avatar
Antonie Vietor committed
43
        "0.60.0/bio/picard/mergesamfiles"
44
45
46
47
48

rule mark_merged_duplicates:
    input:
        "results/merged/{sample}.bam"
    output:
Antonie Vietor's avatar
Antonie Vietor committed
49
50
        bam=temp("results/picard_dedup/{sample}.bam"),
        metrics="results/picard_dedup/{sample}.metrics.txt"
51
    log:
Antonie Vietor's avatar
Antonie Vietor committed
52
        "logs/picard/picard_dedup/{sample}.log"
53
54
55
    params:
        "REMOVE_DUPLICATES=false ASSUME_SORTED=true VALIDATION_STRINGENCY=LENIENT"
    wrapper:
Antonie Vietor's avatar
Antonie Vietor committed
56
        "0.60.0/bio/picard/markduplicates"