From a2eccae779e1066aeb44845aa64f2e0ad56d5d9b Mon Sep 17 00:00:00 2001 From: James Hadfield Date: Mon, 4 Dec 2023 16:54:42 +1300 Subject: [PATCH] [ancestral] Mutually exclusive ref/root seq arg 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. --- augur/ancestral.py | 10 +++++++--- tests/functional/ancestral/cram/invalid-args.t | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) 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