diff --git a/CHANGES.md b/CHANGES.md index 2962bbab4..60beae6b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/augur/ancestral.py b/augur/ancestral.py index 260c252d6..d2012342c 100644 --- a/augur/ancestral.py +++ b/augur/ancestral.py @@ -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", diff --git a/tests/functional/ancestral/cram/invalid-args.t b/tests/functional/ancestral/cram/invalid-args.t index e91132835..888b66672 100644 --- a/tests/functional/ancestral/cram/invalid-args.t +++ b/tests/functional/ancestral/cram/invalid-args.t @@ -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