Skip to content

Commit

Permalink
[ancestral] Mutually exclusive ref/root seq arg
Browse files Browse the repository at this point in the history
For VCF alignments, `--vcf-reference` becomes the 'ref' variable and
for FASTA alignments, `--root-sequence` becomes the 'ref' variable.
If both was provided then (previously) one was silently ignored, but
they are now mutually exclusive.

The argument help messages are also improved.
  • Loading branch information
jameshadfield committed Dec 4, 2023
1 parent 317cf0a commit a529731
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
## __NEXT__

* ancestral: For VCF alignments, a VCF output file is now only created when requested via `--output-vcf`. [#1344][] (@jameshadfield)
* ancestral: Improvements to command line arguments. [#1344][] (@jameshadfield)
* Incompatible arguments are now checked, especially related to VCF vs FASTA inputs.
* `--vcf-reference` and `--root-sequence` are now mutually exclusive.

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

Expand Down
10 changes: 7 additions & 3 deletions augur/ancestral.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ def register_parser(parent_subparsers):
)
input_group.add_argument('--tree', '-t', required=True, help="prebuilt Newick")
input_group.add_argument('--alignment', '-a', help="alignment in FASTA or VCF format")
input_group.add_argument('--vcf-reference', type=str, help='FASTA file of the sequence the VCF was mapped to (only used if a VCF is provided as the alignment)')
input_group.add_argument('--root-sequence', type=str, help='FASTA/genbank file of the sequence that is used as root for mutation calling.'
' Differences between this sequence and the inferred root will be reported as mutations on the root branch.')
input_group_ref = input_group.add_mutually_exclusive_group()
input_group_ref.add_argument('--vcf-reference', type=str, metavar='FASTA',
help='[VCF alignment only] file of the sequence the VCF was mapped to.'
' Differences between this sequence and the inferred root will be reported as mutations on the root branch.')
input_group_ref.add_argument('--root-sequence', type=str,metavar='FASTA/GenBank',
help='[FASTA alignment only] file of the sequence that is used as root for mutation calling.'
' Differences between this sequence and the inferred root will be reported as mutations on the root branch.')

global_options_group = parser.add_argument_group(
"global options",
Expand Down
15 changes: 15 additions & 0 deletions tests/functional/ancestral/cram/invalid-args.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,18 @@ Missing tree file
> --output-sequences "$CRAMTMP/$TESTFILE/output.fasta" > /dev/null
ERROR: The provided tree file .* doesn't exist (re)
[2]


Attempting to use FASTA-input reference and VCF-input reference args
(The files here don't exist, but we exit before they're checked)

$ ${AUGUR} ancestral \
> --tree $TESTDIR/../data/tree-doesnt-exist.nwk \
> --alignment $TESTDIR/../data/aligned.fasta \
> --root-sequence $TESTDIR/../data/reference.fasta \
> --vcf-reference $TESTDIR/../data/reference.fasta \
> --output-sequences "$CRAMTMP/$TESTFILE/output.fasta" > /dev/null 2>"$CRAMTMP/$TESTFILE/err-args.txt"
[2]

$ grep "augur ancestral: error: argument --vcf-reference: not allowed with argument --root-sequence" "$CRAMTMP/$TESTFILE/err-args.txt"
augur ancestral: error: argument --vcf-reference: not allowed with argument --root-sequence

0 comments on commit a529731

Please sign in to comment.