Skip to content

Commit

Permalink
clades: Add validation options
Browse files Browse the repository at this point in the history
This keeps consistent with other subcommands that take node data JSON as
input.
  • Loading branch information
victorlin committed Oct 22, 2024
1 parent cd3ccb0 commit 014b064
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions augur/clades.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .io.file import PANDAS_READ_CSV_OPTIONS
from argparse import SUPPRESS
from .utils import get_parent_name_by_child_name_for_tree, read_node_data, write_json, get_json_name
from .argparse_ import add_validation_arguments

UNASSIGNED = 'unassigned'

Expand Down Expand Up @@ -324,10 +325,10 @@ def get_reference_sequence_from_root_node(all_muts, root_name):

return ref

def parse_nodes(tree_file, node_data_files):
def parse_nodes(tree_file, node_data_files, validation_mode):
tree = Phylo.read(tree_file, 'newick')
# don't supply tree to read_node_data as we don't want to require that every node is present in the node_data JSONs
node_data = read_node_data(node_data_files)
node_data = read_node_data(node_data_files, validation_mode=validation_mode)
# node_data files can be parsed without 'nodes' (if they have 'branches')
if "nodes" not in node_data or len(node_data['nodes'].keys())==0:
raise AugurError(f"No nodes found in the supplied node data files. Please check {', '.join(node_data_files)}")
Expand All @@ -347,11 +348,12 @@ def register_parser(parent_subparsers):
parser.add_argument('--output-node-data', type=str, metavar="NODE_DATA_JSON", help='name of JSON file to save clade assignments to')
parser.add_argument('--membership-name', type=str, default="clade_membership", help='Key to store clade membership under; use "None" to not export this')
parser.add_argument('--label-name', type=str, default="clade", help='Key to store clade labels under; use "None" to not export this')
add_validation_arguments(parser)
return parser


def run(args):
(tree, all_muts) = parse_nodes(args.tree, args.mutations)
(tree, all_muts) = parse_nodes(args.tree, args.mutations, args.validation_mode)

if args.reference:
# PLACE HOLDER FOR vcf WORKFLOW.
Expand Down

0 comments on commit 014b064

Please sign in to comment.