From 1361a7ae2633376f2ca69317b4e62de45c13a3d6 Mon Sep 17 00:00:00 2001 From: PierreBarrat Date: Wed, 8 May 2019 18:00:49 +0200 Subject: [PATCH 1/3] refined.py: enable re-rooting with outgroup without timetree inference --- augur/refine.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/augur/refine.py b/augur/refine.py index ff8d7934e..f4e0b75e7 100644 --- a/augur/refine.py +++ b/augur/refine.py @@ -168,6 +168,11 @@ def run(args): else: tree_fname = '.'.join(args.alignment.split('.')[:-1]) + '_tt.nwk' + if args.root and len(args.root) == 1: #if anything but a list of seqs, don't send as a list + args.root = args.root[0] + if args.keep_root: # This flag overrides anything specified by 'root' + args.root = None + if args.timetree: # load meta data and covert dates to numeric if args.metadata is None: @@ -184,10 +189,7 @@ def run(args): if n.name in metadata and 'date' in metadata[n.name]: n.raw_date = metadata[n.name]['date'] - if args.root and len(args.root) == 1: #if anything but a list of seqs, don't send as a list - args.root = args.root[0] - if args.keep_root: # This flag overrides anything specified by 'root' - args.root = None + tt = refine(tree=T, aln=aln, ref=ref, dates=dates, confidence=args.date_confidence, reroot=args.root, # or 'best', # We now have a default in param spec - this just adds confusion. @@ -207,6 +209,8 @@ def run(args): else: from treetime import TreeAnc # instantiate treetime for the sole reason to name internal nodes + if args.root: + T.root_with_outgroup(args.root) tt = TreeAnc(tree=T, aln=aln, ref=ref, gtr='JC69', verbose=1) node_data['nodes'] = collect_node_data(T, attributes) From c2ab232a84ecd904736af3181aec956219e666d4 Mon Sep 17 00:00:00 2001 From: Richard Neher Date: Wed, 8 May 2019 18:42:40 +0200 Subject: [PATCH 2/3] refine.py: catch inappropriate rooting option in non-timetree case --- augur/refine.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/augur/refine.py b/augur/refine.py index f4e0b75e7..07122a9ae 100644 --- a/augur/refine.py +++ b/augur/refine.py @@ -189,8 +189,6 @@ def run(args): if n.name in metadata and 'date' in metadata[n.name]: n.raw_date = metadata[n.name]['date'] - - tt = refine(tree=T, aln=aln, ref=ref, dates=dates, confidence=args.date_confidence, reroot=args.root, # or 'best', # We now have a default in param spec - this just adds confusion. Tc=0.01 if args.coalescent is None else args.coalescent, #use 0.01 as default coalescent time scale @@ -210,7 +208,11 @@ def run(args): from treetime import TreeAnc # instantiate treetime for the sole reason to name internal nodes if args.root: + if args.root in ['best', 'least-squares', 'min_dev', 'oldest']: + raise TypeError("The rooting option '%s' is only available when inferring a timetree. Please specify an explicit outgroup."%args.root) + T.root_with_outgroup(args.root) + tt = TreeAnc(tree=T, aln=aln, ref=ref, gtr='JC69', verbose=1) node_data['nodes'] = collect_node_data(T, attributes) From ab8e640449035c6546cbc430f123c8053003e21a Mon Sep 17 00:00:00 2001 From: Richard Neher Date: Wed, 8 May 2019 18:44:02 +0200 Subject: [PATCH 3/3] refine.py: whitespace --- augur/refine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/augur/refine.py b/augur/refine.py index 07122a9ae..66ff3705f 100644 --- a/augur/refine.py +++ b/augur/refine.py @@ -208,8 +208,8 @@ def run(args): from treetime import TreeAnc # instantiate treetime for the sole reason to name internal nodes if args.root: - if args.root in ['best', 'least-squares', 'min_dev', 'oldest']: - raise TypeError("The rooting option '%s' is only available when inferring a timetree. Please specify an explicit outgroup."%args.root) + if args.root in ['best', 'least-squares', 'min_dev', 'oldest']: + raise TypeError("The rooting option '%s' is only available when inferring a timetree. Please specify an explicit outgroup."%args.root) T.root_with_outgroup(args.root)