Snakefile.flt3 2.22 KB
Newer Older
bow's avatar
bow committed
1
from os import path
bow's avatar
bow committed
2
from rattle import Run
bow's avatar
bow committed
3
4
5
6


RUN = Run(config)

bow's avatar
bow committed
7
# Region of interest ~ exon 14-15 in transcript coordinates.
bow's avatar
bow committed
8
RUN.set_default_setting("flt3_name", "FLT3-001")
bow's avatar
bow committed
9
10
11
RUN.set_default_setting("flt3_start", 1787)
RUN.set_default_setting("flt3_end", 2024)

bow's avatar
bow committed
12
13
14

rule all_flt3:
    input:
bow's avatar
bow committed
15
16
        flt3_sc_jsons=expand(RUN.output("{sample}/itd/{sample}.flt3-sc.json"), sample=RUN.samples),
        flt3_sc_plots=expand(RUN.output("{sample}/itd/{sample}.flt3-sc.png"), sample=RUN.samples),
bow's avatar
bow committed
17
18
19
20
21

rule align_flt3:
    input:
        fq1=RUN.output("{sample}/{sample}-R1.fq.gz"),
        fq2=RUN.output("{sample}/{sample}-R2.fq.gz"),
bow's avatar
bow committed
22
        index=RUN.settings["flt3_bwa_index"]
bow's avatar
bow committed
23
    output:
bow's avatar
bow committed
24
25
        bam=RUN.output("{sample}/itd/{sample}.flt3.bam"),
        bai=RUN.output("{sample}/itd/{sample}.flt3.bai"),
bow's avatar
bow committed
26
    params:
27
        rg="@RG\\tID:{sample}\\tSM:{sample}"
bow's avatar
bow committed
28
    threads: 3
bow's avatar
bow committed
29
    conda: srcdir("envs/align_itd.yml")
bow's avatar
bow committed
30
    shell:
31
        "bwa mem -R \'{params.rg}\' -t {threads} -L 2,2 {input.index} {input.fq1} {input.fq2}"
bow's avatar
bow committed
32
33
34
        " | samtools view -Sbh -F 0x4 -"
        " | picard SortSam I=/dev/stdin O={output.bam} SO=coordinate CREATE_INDEX=true"

bow's avatar
bow committed
35
rule detect_flt3:
bow's avatar
bow committed
36
    input:
bow's avatar
bow committed
37
38
        bam=RUN.output("{sample}/itd/{sample}.flt3.bam"),
        bai=RUN.output("{sample}/itd/{sample}.flt3.bai"),
bow's avatar
bow committed
39
        ref=RUN.settings["flt3_fasta"],
40
        exe=RUN.settings["rose_dt_exe"],
bow's avatar
bow committed
41
    output:
bow's avatar
bow committed
42
43
        csv=RUN.output("{sample}/itd/{sample}.flt3.csv"),
        bg_csv=RUN.output("{sample}/itd/{sample}.flt3.bg.csv"),
bow's avatar
bow committed
44
    threads: 1
bow's avatar
bow committed
45
    params:
bow's avatar
bow committed
46
        trx_name=RUN.settings["flt3_name"],
bow's avatar
bow committed
47
48
        start=RUN.settings["flt3_start"],
        end=RUN.settings["flt3_end"],
bow's avatar
bow committed
49
    shell:
bow's avatar
bow committed
50
        "{input.exe} -r {params.trx_name}:{params.start}-{params.end} --bg-counts {output.bg_csv} {input.ref} {input.bam} > {output.csv}"
bow's avatar
bow committed
51

bow's avatar
bow committed
52
rule plot_itd_flt3:
bow's avatar
bow committed
53
    input:
bow's avatar
bow committed
54
55
        csv=RUN.output("{sample}/itd/{sample}.flt3.csv"),
        bg_csv=RUN.output("{sample}/itd/{sample}.flt3.bg.csv"),
bow's avatar
bow committed
56
        scr=RUN.settings["plot_itd"],
bow's avatar
bow committed
57
    output:
bow's avatar
bow committed
58
        png=RUN.output("{sample}/itd/{sample}.flt3.png"),
bow's avatar
bow committed
59
60
    threads: 1
    conda: RUN.settings["plot_itd_conda"]
bow's avatar
bow committed
61
    shell:
bow's avatar
bow committed
62
63
64
        "python {input.scr}"
        " --sample-id {wildcards.sample} --mode per-event"
        " {input.csv} {input.bg_csv} {output.png}"