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 Nov 29, 2023
1 parent 4af0996 commit ce7f094
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## __NEXT__

* ancestral: For VCF alignments, a VCF output file is now only created when requested via `--output-vcf`.

## 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 ce7f094

Please sign in to comment.