From bbf963fb148ddc4648aeb00f0d9f5a7fc3f9e011 Mon Sep 17 00:00:00 2001 From: John Huddleston Date: Thu, 18 Mar 2021 14:41:45 -0700 Subject: [PATCH] Replace utils.open_file in mask with io.open_file Replaces calls to a similar `open_file` function from `utils.py` with the new function in `io.py`. Updates the functional tests for the mask module to confirm that compressed VCF inputs work with the old and new function alike. --- augur/mask.py | 4 ++-- tests/functional/mask.t | 14 +++++++------- tests/functional/mask/variants.vcf | 10 ---------- tests/functional/mask/variants.vcf.gz | Bin 0 -> 155 bytes 4 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 tests/functional/mask/variants.vcf create mode 100644 tests/functional/mask/variants.vcf.gz diff --git a/augur/mask.py b/augur/mask.py index f45c5ba52..b52232d7d 100644 --- a/augur/mask.py +++ b/augur/mask.py @@ -10,8 +10,8 @@ from Bio import SeqIO from Bio.Seq import MutableSeq -from .io import read_sequences, write_sequences -from .utils import run_shell_command, shquote, open_file, is_vcf, load_mask_sites, VALID_NUCLEOTIDES +from .io import open_file, read_sequences, write_sequences +from .utils import run_shell_command, shquote, is_vcf, load_mask_sites, VALID_NUCLEOTIDES def get_chrom_name(vcf_file): """Read the CHROM field from the first non-header line of a vcf file. diff --git a/tests/functional/mask.t b/tests/functional/mask.t index b669e134c..9197b28a3 100644 --- a/tests/functional/mask.t +++ b/tests/functional/mask.t @@ -5,24 +5,24 @@ Integration tests for augur mask. Try masking a VCF without any specified mask. - $ ${AUGUR} mask --sequences mask/variants.vcf + $ ${AUGUR} mask --sequences mask/variants.vcf.gz No masking sites provided. Must include one of --mask, --mask-from-beginning, --mask-from-end, --mask-invalid, or --mask-sites [1] Mask a VCF with a BED file and no specified output file. - $ cp "mask/variants.vcf" "$TMP/" + $ cp "mask/variants.vcf.gz" "$TMP/" $ ${AUGUR} mask \ - > --sequences "$TMP/variants.vcf" \ + > --sequences "$TMP/variants.vcf.gz" \ > --mask "mask/mask_variants.bed" > /dev/null - $ diff -u "mask/masked_variants.vcf" "$TMP/variants.vcf" - $ rm -f "$TMP/variants.vcf" + $ diff -u "mask/masked_variants.vcf" <(gzip -c -d "$TMP/variants.vcf.gz") + $ rm -f "$TMP/variants.vcf.gz" Mask a VCF with a BED file and a specified output file. $ ${AUGUR} mask \ - > --sequences "mask/variants.vcf" \ + > --sequences "mask/variants.vcf.gz" \ > --mask "mask/mask_variants.bed" \ > --output "$TMP/masked_variants.vcf" > /dev/null @@ -104,4 +104,4 @@ Mask invalid nucleotides ATCGNNNN $ rm -f "$TMP/masked.fasta" - $ popd > /dev/null \ No newline at end of file + $ popd > /dev/null diff --git a/tests/functional/mask/variants.vcf b/tests/functional/mask/variants.vcf deleted file mode 100644 index 06293fd86..000000000 --- a/tests/functional/mask/variants.vcf +++ /dev/null @@ -1,10 +0,0 @@ -#CHROM POS ID REF ALT QUAL FILTER INFO -MTB_anc 1199 . G A . PASS . -MTB_anc 1463 . G C . PASS . -MTB_anc 2018 . C T . PASS . -MTB_anc 2532 . C T . PASS . -MTB_anc 3132 . A C . PASS . -MTB_anc 4663 . G C . PASS . -MTB_anc 5887 . C T . PASS . -MTB_anc 7581 . G T . PASS . -MTB_anc 8322 . T G . PASS . diff --git a/tests/functional/mask/variants.vcf.gz b/tests/functional/mask/variants.vcf.gz new file mode 100644 index 0000000000000000000000000000000000000000..61e4698844bd4196c2b9c9cbe5825c0b5e5b208b GIT binary patch literal 155 zcmV;M0A&9kiwFoyP>x>!19o9@X<=@3b1rscW&m}~u@b@{5CqVA{SEt!KuAc57?c?z z5iYgk*!%ybNTG$$Tybx9cW*8+ELcN=J0Z>%+7oV@_OQ;=9O14u>=ruSAFn4En