Skip to content

Commit

Permalink
formatted with snakefmt: call_variants, maftools
Browse files Browse the repository at this point in the history
  • Loading branch information
massiddamt committed Jul 14, 2022
1 parent 0714cf3 commit de9d395
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 147 deletions.
182 changes: 134 additions & 48 deletions workflow/rules/call_variants.smk
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@
rule get_sample_names:
input:
normal=lambda wildcards: get_normal_bam(wildcards),
tumoral= lambda wildcards: get_tumoral_bam(wildcards),
tumoral=lambda wildcards: get_tumoral_bam(wildcards),
output:
normal=resolve_results_filepath(config.get("paths").get("results_dir"),"results/tmp/{sample}_normal.samplename.txt"),
tumor=resolve_results_filepath(config.get("paths").get("results_dir"),"results/tmp/{sample}_tumor.samplename.txt")
normal=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/tmp/{sample}_normal.samplename.txt",
),
tumor=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/tmp/{sample}_tumor.samplename.txt",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"),multiply_by=5)
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
log:
normal=resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/getsamplename/{sample}.gsn.log"),
tumor=resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/getsamplename/{sample}.gsn_tumor.log")
normal=resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/getsamplename/{sample}.gsn.log",
),
tumor=resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/getsamplename/{sample}.gsn_tumor.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
threads: conservative_cpu_count(reserve_cores=2,max_cores=99)
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
shell:
"gatk "
"--java-options {params.custom} "
Expand All @@ -28,32 +42,59 @@ rule get_sample_names:
"-O {output.normal} "
">& {log.normal} "


rule mutect_matched:
input:
normal=lambda wildcards: get_normal_bam(wildcards),
tumoral= lambda wildcards: get_tumoral_bam(wildcards),
normal_name=resolve_results_filepath(config.get("paths").get("results_dir"),"results/tmp/{sample}_normal.samplename.txt"),
tumor_name=resolve_results_filepath(config.get("paths").get("results_dir"),"results/tmp/{sample}_tumor.samplename.txt")
tumoral=lambda wildcards: get_tumoral_bam(wildcards),
normal_name=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/tmp/{sample}_normal.samplename.txt",
),
tumor_name=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/tmp/{sample}_tumor.samplename.txt",
),
output:
vcf=resolve_results_filepath(config.get("paths").get("results_dir"),"results/matched/{sample}_somatic.vcf.gz"),
bam=resolve_results_filepath(config.get("paths").get("results_dir"),"results/matched/{sample}_tumor_normal.bam"),
fir=resolve_results_filepath(config.get("paths").get("results_dir"),"results/matched/{sample}_tumor_normal_f1r2.tar.gz"),
stats=resolve_results_filepath(config.get("paths").get("results_dir"),"results/matched/{sample}_somatic.vcf.gz.stats")
vcf=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/matched/{sample}_somatic.vcf.gz",
),
bam=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/matched/{sample}_tumor_normal.bam",
),
fir=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/matched/{sample}_tumor_normal_f1r2.tar.gz",
),
stats=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/matched/{sample}_somatic.vcf.gz.stats",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
genome=config.get("resources").get("reference"),
intervals=resolve_single_filepath(config.get("paths").get("workdir"),resolve_single_filepath("resources",config.get("resources").get("bed"))),
intervals=resolve_single_filepath(
config.get("paths").get("workdir"),
resolve_single_filepath("resources", config.get("resources").get("bed")),
),
param=config.get("params").get("gatk").get("Mutect"),
germline_resource=config.get("params").get("gatk").get("germline"),
normal_bam = lambda wildcards, input: get_name(input.normal_name),
tumor_bam= lambda wildcards,input: get_name(input.tumor_name)
normal_bam=lambda wildcards, input: get_name(input.normal_name),
tumor_bam=lambda wildcards, input: get_name(input.tumor_name),
log:
resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/Mutect2/{sample}.mutect.log")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/Mutect2/{sample}.mutect.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
resources:
tmpdir = config.get("paths").get("tmp_dir")
tmpdir=config.get("paths").get("tmp_dir"),
shell:
"gatk "
"--java-options {params.custom} "
Expand All @@ -74,44 +115,65 @@ rule mutect_matched:
"--f1r2-tar-gz {output.fir} "
">& {log} "


rule learn_orientation_model:
input:
rules.mutect_matched.output.fir
rules.mutect_matched.output.fir,
output:
resolve_results_filepath(config.get("paths").get("results_dir"),"results/filters/matched/{sample}_read-orientation-model.tar.gz")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/filters/matched/{sample}_read-orientation-model.tar.gz",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
exac=config.get("params").get("gatk").get("exac")
exac=config.get("params").get("gatk").get("exac"),
log:
resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/Mutect2/{sample}_pileupsummaries_T.log")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/Mutect2/{sample}_pileupsummaries_T.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
resources:
tmpdir = config.get("paths").get("tmp_dir")
tmpdir=config.get("paths").get("tmp_dir"),
shell:
"gatk LearnReadOrientationModel "
"--java-options {params.custom} "
"-I {input} "
"-O {output} "
">& {log} "


rule pileup_summaries_tumoral:
input:
tumoral= lambda wildcards: get_tumoral_bam(wildcards)
tumoral=lambda wildcards: get_tumoral_bam(wildcards),
output:
resolve_results_filepath(config.get("paths").get("results_dir"),"results/filters/matched/{sample}_getpileupsummaries.table")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/filters/matched/{sample}_getpileupsummaries.table",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
intervals=resolve_single_filepath(config.get("paths").get("workdir"),resolve_single_filepath("resources",config.get("resources").get("bed"))),
exac=config.get("params").get("gatk").get("exac")
intervals=resolve_single_filepath(
config.get("paths").get("workdir"),
resolve_single_filepath("resources", config.get("resources").get("bed")),
),
exac=config.get("params").get("gatk").get("exac"),
log:
resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/Mutect2/{sample}_pileupsummaries_T.log")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/Mutect2/{sample}_pileupsummaries_T.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
resources:
tmpdir = config.get("paths").get("tmp_dir")
tmpdir=config.get("paths").get("tmp_dir"),
shell:
"gatk GetPileupSummaries "
"--java-options {params.custom} "
Expand All @@ -121,22 +183,34 @@ rule pileup_summaries_tumoral:
"-O {output} "
">& {log} "


rule pileup_summaries_normal:
input:
normal=lambda wildcards: get_normal_bam(wildcards)
normal=lambda wildcards: get_normal_bam(wildcards),
output:
resolve_results_filepath(config.get("paths").get("results_dir"),"results/filters/matched/{sample}_normal_pileups.table")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/filters/matched/{sample}_normal_pileups.table",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
intervals=resolve_single_filepath(config.get("paths").get("workdir"),resolve_single_filepath("resources",config.get("resources").get("bed"))),
exac=config.get("params").get("gatk").get("exac")
intervals=resolve_single_filepath(
config.get("paths").get("workdir"),
resolve_single_filepath("resources", config.get("resources").get("bed")),
),
exac=config.get("params").get("gatk").get("exac"),
log:
resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/Mutect2/{sample}_pileupsummaries_C.log")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/Mutect2/{sample}_pileupsummaries_C.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
resources:
tmpdir = config.get("paths").get("tmp_dir")
tmpdir=config.get("paths").get("tmp_dir"),
shell:
"gatk GetPileupSummaries "
"--java-options {params.custom} "
Expand All @@ -146,22 +220,34 @@ rule pileup_summaries_normal:
"-O {output} "
">& {log} "


rule calculate_contamination:
input:
tab_t=rules.pileup_summaries_tumoral.output,
tab_c=rules.pileup_summaries_normal.output
tab_c=rules.pileup_summaries_normal.output,
output:
table=resolve_results_filepath(config.get("paths").get("results_dir"),"results/filters/matched/{sample}_contamination.table"),
segment=resolve_results_filepath(config.get("paths").get("results_dir"),"results/filters/matched/{sample}_tumor.segment")
table=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/filters/matched/{sample}_contamination.table",
),
segment=resolve_results_filepath(
config.get("paths").get("results_dir"),
"results/filters/matched/{sample}_tumor.segment",
),
params:
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"),multiply_by=5)
custom=java_params(tmp_dir=config.get("paths").get("tmp_dir"), multiply_by=5),
log:
resolve_results_filepath(config.get("paths").get("results_dir"),"logs/gatk/Mutect2/{sample}_calculatecontamination.log")
resolve_results_filepath(
config.get("paths").get("results_dir"),
"logs/gatk/Mutect2/{sample}_calculatecontamination.log",
),
conda:
resolve_single_filepath(config.get("paths").get("workdir"),"workflow/envs/gatk.yaml")
resolve_single_filepath(
config.get("paths").get("workdir"), "workflow/envs/gatk.yaml"
)
threads: conservative_cpu_count(reserve_cores=2, max_cores=99)
resources:
tmpdir = config.get("paths").get("tmp_dir")
tmpdir=config.get("paths").get("tmp_dir"),
shell:
"gatk CalculateContamination "
"--java-options {params.custom} "
Expand Down
Loading

0 comments on commit de9d395

Please sign in to comment.