Skip to content

Commit

Permalink
[ancestral] only export VCF if requested
Browse files Browse the repository at this point in the history
This is consistent with augur's general behaviour of "request a file for
it to be produced". Moreover, the previous code would ~always result in
the VCF input file being overwritten.

This is potentially a backwards compatible change. The number of users
expected to be affected is minimal (perhaps zero).

Closes #1343.
  • Loading branch information
jameshadfield committed Dec 4, 2023
1 parent 4af0996 commit 3ceaad3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## __NEXT__

* ancestral: For VCF alignments, a VCF output file is now only created when requested via `--output-vcf`. [#1344][] (@jameshadfield)

[#1344]: https://github.com/nextstrain/augur/issues/1334

## 23.1.1 (7 November 2023)

Expand Down
12 changes: 4 additions & 8 deletions augur/ancestral.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,9 @@ def run(args):
SeqIO.write(records, args.output_sequences, "fasta")
print("ancestral sequences FASTA written to", args.output_sequences, file=sys.stdout)

# If VCF, output VCF including new ancestral seqs
if is_vcf:
if args.output_vcf:
vcf_fname = args.output_vcf
else:
vcf_fname = '.'.join(args.alignment.split('.')[:-1]) + '.vcf'
write_vcf(nuc_result['tt'].get_tree_dict(keep_var_ambigs=True), vcf_fname)
print("ancestral sequences as vcf-file written to",vcf_fname, file=sys.stdout)
# If VCF output VCF including new ancestral seqs if requested to
if is_vcf and args.output_vcf:
write_vcf(nuc_result['tt'].get_tree_dict(keep_var_ambigs=True), args.output_vcf)
print("Mutations, including for ancestral nodes, exported as VCF to", args.output_vcf, file=sys.stdout)

return 0

0 comments on commit 3ceaad3

Please sign in to comment.