diff --git a/bio/rbt/vcf_fix_iupac_alleles/environment.yaml b/bio/rbt/vcf_fix_iupac_alleles/environment.yaml new file mode 100644 index 00000000000..ffcf275b9b5 --- /dev/null +++ b/bio/rbt/vcf_fix_iupac_alleles/environment.yaml @@ -0,0 +1,8 @@ +channels: + - conda-forge + - bioconda + - nodefaults +dependencies: + - rust-bio-tools =0.42.0 + - bcftools =1.17 + - snakemake-wrapper-utils =0.5.3 diff --git a/bio/rbt/vcf_fix_iupac_alleles/meta.yaml b/bio/rbt/vcf_fix_iupac_alleles/meta.yaml new file mode 100644 index 00000000000..fa7f26737f3 --- /dev/null +++ b/bio/rbt/vcf_fix_iupac_alleles/meta.yaml @@ -0,0 +1,10 @@ +name: rbt vcf-fix-iupac-alleles +description: | + Convert any IUPAC codes in alleles into Ns (in order to comply with VCF 4 specs). +url: https://github.com/rust-bio/rust-bio-tools +authors: + - Filipe G. Vieira +input: + - VCF +output: + - VCF/BCF diff --git a/bio/rbt/vcf_fix_iupac_alleles/test/Snakefile b/bio/rbt/vcf_fix_iupac_alleles/test/Snakefile new file mode 100644 index 00000000000..41d17c47434 --- /dev/null +++ b/bio/rbt/vcf_fix_iupac_alleles/test/Snakefile @@ -0,0 +1,22 @@ + +rule vcf_fix_iupac_alleles_vcf: + input: + "{file}.vcf.gz", + output: + vcf="results/{file}.vcf.gz", + log: + "logs/{file}.vcf.log", + params: + extra="", + threads: 1 + resources: + mem_mb=1024, + wrapper: + "master/bio/rbt/vcf_fix_iupac_alleles" + + +use rule vcf_fix_iupac_alleles_vcf as vcf_fix_iupac_alleles_bcf with: + output: + bcf="results/{file}.bcf", + log: + "logs/{file}.bcf.log", diff --git a/bio/rbt/vcf_fix_iupac_alleles/test/homo_sapiens-chrMT.vcf.gz b/bio/rbt/vcf_fix_iupac_alleles/test/homo_sapiens-chrMT.vcf.gz new file mode 100644 index 00000000000..29d5ea85ce9 Binary files /dev/null and b/bio/rbt/vcf_fix_iupac_alleles/test/homo_sapiens-chrMT.vcf.gz differ diff --git a/bio/rbt/vcf_fix_iupac_alleles/wrapper.py b/bio/rbt/vcf_fix_iupac_alleles/wrapper.py new file mode 100644 index 00000000000..c332490cc9c --- /dev/null +++ b/bio/rbt/vcf_fix_iupac_alleles/wrapper.py @@ -0,0 +1,18 @@ +__author__ = "Filipe G. Vieira" +__copyright__ = "Copyright 2023, Filipe G. Vieira" +__license__ = "MIT" + +import tempfile +from snakemake.shell import shell +from snakemake_wrapper_utils.bcftools import get_bcftools_opts + + +bcftools_opts = get_bcftools_opts(snakemake, parse_ref=False) +log = snakemake.log_fmt_shell(stdout=True, stderr=True) +extra = snakemake.params.get("extra", "") + + +with tempfile.TemporaryDirectory() as tmpdir: + shell( + "(rbt vcf-fix-iupac-alleles {extra} < {snakemake.input[0]} | bcftools sort --temp-dir {tmpdir} {bcftools_opts}) {log}" + ) diff --git a/test.py b/test.py index af8383e390f..17ce445830a 100644 --- a/test.py +++ b/test.py @@ -6121,13 +6121,26 @@ def test_verifybamid2(): @skip_if_not_modified -def test_collapse_reads_to_fragments_bam(): +def test_rbt_collapse_reads_to_fragments_bam(): run( "bio/rbt/collapse_reads_to_fragments-bam", ["snakemake", "--cores", "1", "--use-conda", "-F"], ) +@skip_if_not_modified +def test_rbt_vcf_fix_iupac_alleles(): + run( + "bio/rbt/vcf_fix_iupac_alleles", + ["snakemake", "--cores", "1", "--use-conda", "-F", "results/homo_sapiens-chrMT.vcf.gz"], + ) + + run( + "bio/rbt/vcf_fix_iupac_alleles", + ["snakemake", "--cores", "1", "--use-conda", "-F", "results/homo_sapiens-chrMT.bcf"], + ) + + @skip_if_not_modified def test_gatk_mutect2_calling_meta(): run(