From ab826041528a92a6e8b326bb4b4432cc00629505 Mon Sep 17 00:00:00 2001 From: tdayris Date: Mon, 21 Sep 2020 09:16:53 +0200 Subject: [PATCH 1/4] [fix] (template): Missing code in wrappers' doc. Error #187 --- docs/generate_docs.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/generate_docs.py b/docs/generate_docs.py index c471d06d2f..446fe83a9e 100644 --- a/docs/generate_docs.py +++ b/docs/generate_docs.py @@ -34,10 +34,10 @@ TOOL_TEMPLATE = Template(f.read()) with open(os.path.join(BASE_DIR, "_templates", "wrapper.rst")) as f: - TEMPLATE = Template(f.read()) + TEMPLATE_WRAPPER = Template(f.read()) with open(os.path.join(BASE_DIR, "_templates", "meta_wrapper.rst")) as f: - TEMPLATE = Template(f.read()) + TEMPLATE_META = Template(f.read()) def get_tool_dir(tool): @@ -88,7 +88,7 @@ def render_wrapper(path, target): name = meta["name"].replace(" ", "_") + ".rst" os.makedirs(os.path.dirname(target), exist_ok=True) with open(target, "w") as readme: - rst = TEMPLATE.render( + rst = TEMPLATE_WRAPPER.render( snakefile=snakefile, wrapper=wrapper, wrapper_lang=wrapper_lang, @@ -113,7 +113,7 @@ def render_meta(path, target): with open(os.path.join(path, "test", "Snakefile")) as snakefile: snakefile = textwrap.indent(snakefile.read(), " ").replace("master", TAG) - + wrappers = [] for uw in used_wrappers: wrapper = os.path.join(WRAPPER_DIR, uw, "wrapper.py") @@ -124,11 +124,11 @@ def render_meta(path, target): with open(wrapper) as wrapper: wrapper = textwrap.indent(wrapper.read(), " ") wrappers.append((wrapper, wrapper_lang, uw)) - + name = meta["name"].replace(" ", "_") + ".rst" os.makedirs(os.path.dirname(target), exist_ok=True) with open(target, "w") as readme: - rst = TEMPLATE.render( + rst = TEMPLATE_META.render( snakefile=snakefile, wrappers=wrappers, usedwrappers=used_wrappers, From f3bb31f8fb06f8c0e53ea995688fd18eb8747aed Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 12 Jul 2022 13:24:13 +0200 Subject: [PATCH 2/4] Wrapper update --- bio/gatk/filtermutectcalls/meta.yaml | 16 ++++++++++---- bio/gatk/filtermutectcalls/test/Snakefile | 22 +++++++++++++++++++ bio/gatk/filtermutectcalls/wrapper.py | 26 +++++++++++++++++++++++ 3 files changed, 60 insertions(+), 4 deletions(-) diff --git a/bio/gatk/filtermutectcalls/meta.yaml b/bio/gatk/filtermutectcalls/meta.yaml index d4958046ba..20f5e4cbaa 100644 --- a/bio/gatk/filtermutectcalls/meta.yaml +++ b/bio/gatk/filtermutectcalls/meta.yaml @@ -1,14 +1,22 @@ name: gatk FilterMutectCalls +url: https://gatk.broadinstitute.org/hc/en-us/articles/360042476952-FilterMutectCalls description: | - Run gatk FilterMutectCalls. + Run gatk FilterMutectCalls to filter variants in a Mutect2 VCF callset. authors: - Patrik Smeds - Filipe G. Vieira + - Thibault Dayris input: - - vcf file - - reference genome + - vcf: Path to vcf file (pbgzipped, indexed) + - ref: Path to reference genome (with .dict file alongside) + - aln: Optional path to SAM/BAM/CRAM files + - contamination: Optional path to + - segmentation: Optional path to tumor segments + - f1r2: Optional path to prior artefact (tar.gz2) + - intervels: Optional file to BED intervals output: - - filtered vcf file + - vcf: filtered vcf file + - stats: Optional stats from Mutect2 notes: | * The `java_opts` param allows for additional arguments to be passed to the java compiler, e.g. "-XX:ParallelGCThreads=10" (not for `-XmX` or `-Djava.io.tmpdir`, since they are handled automatically). * The `extra` param allows for additional program arguments. diff --git a/bio/gatk/filtermutectcalls/test/Snakefile b/bio/gatk/filtermutectcalls/test/Snakefile index 4641ea33c2..2dd4ab929d 100644 --- a/bio/gatk/filtermutectcalls/test/Snakefile +++ b/bio/gatk/filtermutectcalls/test/Snakefile @@ -13,3 +13,25 @@ rule gatk_filtermutectcalls: mem_mb=1024, wrapper: "master/bio/gatk/filtermutectcalls" + + +rule gatk_filtermutectcalls_complete: + input: + vcf="calls/snvs.vcf", + ref="genome.fasta", + bam="mapped/a.bam", + intervals="intervals.bed", + # contamination="", # from gatk CalculateContamination + # segmentation="", # from gatk CalculateContamination + # f1r2="", # from gatk LearnReadOrientationBias + output: + vcf="calls/snvs.mutect.filtered.b.vcf", + log: + "logs/gatk/filter/snvs.log", + params: + extra="--max-alt-allele-count 3", # optional arguments, see GATK docs + java_opts="", # optional + resources: + mem_mb=1024, + wrapper: + "master/bio/gatk/filtermutectcalls" diff --git a/bio/gatk/filtermutectcalls/wrapper.py b/bio/gatk/filtermutectcalls/wrapper.py index 418b1854a3..881e8418ff 100644 --- a/bio/gatk/filtermutectcalls/wrapper.py +++ b/bio/gatk/filtermutectcalls/wrapper.py @@ -12,11 +12,37 @@ log = snakemake.log_fmt_shell(stdout=True, stderr=True) + +aln = snakemake.input.get("aln", "") +if aln: + aln = f"--input {aln}" + +contamination = snakemake.input.get("contemination_table", "") +if contamination: + contamination = f"--contamination-table {contamination}" + +segmentation = snakemake.input.get("segmentation", "") +if segmentation: + segmentation = f"--tumor-segmentation {segmentation}" + +f1r2 = snakemake.input.get("f1r2", "") +if f1r2: + f1r2 = f"--orientation-bias-artifact-priors {f1r2}" + +intervals = snakemake.input.get("bed", "") +if intervals: + intervals = f"--intervals {intervals}" + with tempfile.TemporaryDirectory() as tmpdir: shell( "gatk --java-options '{java_opts}' FilterMutectCalls" " --variant {snakemake.input.vcf}" " --reference {snakemake.input.ref}" + " {aln}" # BAM/SAM/CRAM file containing reads + " {contamination}" # Tables containing contamination information + " {segmentation}" # Tumor segments' minor allele fractions + " {f1r2}" # .tar.gz files containing tables of prior artifact + " {intervals}" # Genomic intervals over which to operate " {extra}" " --tmp-dir {tmpdir}" " --output {snakemake.output.vcf}" From a86e9ba8e515451d3b3ab46fb814a4a70a8d56c3 Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 12 Jul 2022 13:24:24 +0200 Subject: [PATCH 3/4] Test datasets --- bio/gatk/filtermutectcalls/test/intervals.bed | 2 ++ bio/gatk/filtermutectcalls/test/mapped/a.bam | Bin 0 -> 521 bytes bio/gatk/filtermutectcalls/test/mapped/a.bam.bai | Bin 0 -> 24 bytes 3 files changed, 2 insertions(+) create mode 100644 bio/gatk/filtermutectcalls/test/intervals.bed create mode 100644 bio/gatk/filtermutectcalls/test/mapped/a.bam create mode 100644 bio/gatk/filtermutectcalls/test/mapped/a.bam.bai diff --git a/bio/gatk/filtermutectcalls/test/intervals.bed b/bio/gatk/filtermutectcalls/test/intervals.bed new file mode 100644 index 0000000000..df100f631f --- /dev/null +++ b/bio/gatk/filtermutectcalls/test/intervals.bed @@ -0,0 +1,2 @@ +ref 3 44 +ref2 8 31 diff --git a/bio/gatk/filtermutectcalls/test/mapped/a.bam b/bio/gatk/filtermutectcalls/test/mapped/a.bam new file mode 100644 index 0000000000000000000000000000000000000000..a407ae2040d5f118d107ef42cdafa491bf9aa549 GIT binary patch literal 521 zcmb2|=3rp}f&Xj_PR>jW$qdCsUsAWECnOYb@IB%Awpq)|_wkpHn~e;gI&nxey7KIh zX}V)+8@r}RyIZ)JyC}%Ax%Od>p4tLI9S5F}a|^haL@MSev+=UAu`y&El!{FO8ZD1z zM+al?r2T$}4Fry@*L4hOcp=Knws6J72`6sU8>lZ7+90a6z<@ExTx->)17gOhZ>&E! ztvO@EG3Ro2s^!`!@A)!w-`@W|cdla3ajlbu`ltD74w_x>^EkdFacflb3_GVF2d&Ag zmbiF`D23F0m@a!a?@HuC--y%A4U94K?Z4RHoA;}Ey4;>khoyFleYLyvM5ibAb&0?M zW!p(*m6ucaDtHY;7O8HW(wPwDHZ67D>}@*I1&7NH9oJcUc#7__7i{L6rlfiOc)B2W zlE}XIuAdLJ_Snv8({41@j_EI46?)R)Tu=Jt2{KD{i+sy}Isd-AT;^qWx03$6nNPdI zifh(PNK&X}Gd^9-%e1Py+eK4nu}k@}4exc2&vGcw$&kGjlCRq7@+IKpjo6mjv?Ygc zFr8&L+cwc`&H5kF|2Ol5KMJmVcPDYzoz31CIriu8Hc52(s%hD?VUx(8zK5^bVs3p9 w?pT?(;cx1N?LGHQE>xTS5@8E5Ke1Hx#Q#74zn?J!Ml*UuNHZ{l;~qo+0Fsg3fB*mh literal 0 HcmV?d00001 diff --git a/bio/gatk/filtermutectcalls/test/mapped/a.bam.bai b/bio/gatk/filtermutectcalls/test/mapped/a.bam.bai new file mode 100644 index 0000000000000000000000000000000000000000..a9b9979fed416428b1762d263d09d49bb00e5119 GIT binary patch literal 24 RcmZ>A^kigYKmaBv695vP0MP&d literal 0 HcmV?d00001 From d074c010b5e184d206ed45ccd712b3c834e5d710 Mon Sep 17 00:00:00 2001 From: tdayris Date: Tue, 12 Jul 2022 13:24:37 +0200 Subject: [PATCH 4/4] Update test case --- test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test.py b/test.py index 335ebb86b8..d03704d8a2 100644 --- a/test.py +++ b/test.py @@ -3290,6 +3290,18 @@ def test_gatk_filtermutectcalls(): ], ) + run( + "bio/gatk/filtermutectcalls", + [ + "snakemake", + "--cores", + "1", + "calls/snvs.mutect.filtered.b.vcf", + "--use-conda", + "-F", + ], + ) + @skip_if_not_modified def test_gatk_selectvariants():