Skip to content

Commit

Permalink
Replace utils.open_file in mask with io.open_file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
huddlej committed Mar 18, 2021
1 parent 46b8a65 commit bbf963f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions augur/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions tests/functional/mask.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -104,4 +104,4 @@ Mask invalid nucleotides
ATCGNNNN
$ rm -f "$TMP/masked.fasta"

$ popd > /dev/null
$ popd > /dev/null
10 changes: 0 additions & 10 deletions tests/functional/mask/variants.vcf

This file was deleted.

Binary file added tests/functional/mask/variants.vcf.gz
Binary file not shown.

0 comments on commit bbf963f

Please sign in to comment.