augur.export_v2 moduleο
Export version 2 JSON schema for visualization with Auspice
- class augur.export_v2.CustomOrderedDict(*args)ο
Bases:
OrderedDict
Similar to OrderedDict but will convert dictionaries (and dictionaries of dictionaries) into (nested) CustomOrderedDicts. Encountered lists of dicts will be converted to lists of CustomOrderedDict but we will not recursively explore nested lists. Tuples and other iterators are not explored.
- move_to_end_if_present(key, **kwargs)ο
- set_order(*order)ο
changes the order of keys to match those specified in order as much as possible. Missing keys are ignored. Extra keys will come after those specified in order.
- augur.export_v2.are_mutations_defined(branch_attrs)ο
- augur.export_v2.attr_confidence(node_name, attrs, key)ο
Extracts and formats the confidence & entropy keys from the provided node-data attrs If there is no confidence-related information an empty dict is returned. If the information appears incorrect / incomplete, a warning is printed and an empty dict returned.
- Return type:
- augur.export_v2.configure_warnings()ο
- augur.export_v2.convert_tree_to_json_structure(node, metadata, get_div, div=0)ο
converts the Biopython tree structure to a dictionary that can be written to file as a json. This is called recursively.
- Parameters:
node (Bio.Phylo.Newick.Clade)
metadata (dict) β Per-node metadata, with keys matching node.name
get_div β (None or function) Function returns divergence for this node. Arguments: (node, metadata_for_node) If None then divergence is not defined for this dataset and so βdivβ is not set on returned nodes.
div (int) β cumulative divergence leading to the current node (root = 0)
- Returns:
See schema-export-v2.json#/$defs/tree for full details. Node names are always set, and divergence is set if applicable
- Return type:
- augur.export_v2.counter_to_disambiguation_suffix(count)ο
Given a numeric count of author papers, return a distinct alphabetical disambiguation suffix.
Examples
>>> counter_to_disambiguation_suffix(0) 'A' >>> counter_to_disambiguation_suffix(25) 'Z' >>> counter_to_disambiguation_suffix(26) 'AA' >>> counter_to_disambiguation_suffix(51) 'AZ' >>> counter_to_disambiguation_suffix(52) 'BA'
- augur.export_v2.create_author_data(node_attrs)ο
Gather the authors which appear in the metadata and create the author info structure with unique keys
- augur.export_v2.create_branch_labels(branch_attrs, node_data, branch_data)ο
- augur.export_v2.create_branch_mutations(branch_attrs, node_data)ο
- augur.export_v2.deprecated(message)ο
- augur.export_v2.fatal(message)ο
- augur.export_v2.get_additional_metadata_columns(config, command_line_metadata_columns, metadata_names)ο
- augur.export_v2.get_config(args)ο
- augur.export_v2.get_config_colorings_as_dict(config)ο
- augur.export_v2.get_values_across_nodes(node_attrs, key)ο
- augur.export_v2.is_node_attr_defined(node_attrs, attr_name)ο
- augur.export_v2.is_valid(value)ο
- augur.export_v2.node_data_prop_is_normal_trait(name)ο
- augur.export_v2.node_div(T, node_attrs)ο
Scans the provided tree & metadata to see if divergence is defined, and if so returns a function which gets it from individual nodes. Divergence may be defined via a number of sources, and we pick them in the following order: * metadata.mutation_length (typically via augur refine) * metadata.branch_length (typically via augur refine) * Branch lengths encoded in the Newick tree
Returns either: * function with arguments: (node, metadata_for_node) which returns the node divergence * None (indicates that divergence is not available for this dataset)
- augur.export_v2.orderKeys(data)ο
converts the data dict (where keys are inherently unordered) into an OrderedDict where keys are nicely ordered for human eyes to scan the data when written to JSON. The ordering (mostly) mirrors the schema.
- augur.export_v2.parse_node_data_and_metadata(T, node_data, metadata)ο
- augur.export_v2.register_parser(parent_subparsers)ο
- augur.export_v2.run(args)ο
- augur.export_v2.set_annotations(data_json, node_data)ο
- augur.export_v2.set_branch_attrs_on_tree(data_json, branch_attrs)ο
Shifts the provided branch_attrs onto the (auspice) data_json. Currently all data is transferred, there is no way for (e.g.) the set of exported labels to be restricted by the user in a config.
- augur.export_v2.set_build_url(data_json, config, cmd_line_build_url)ο
- augur.export_v2.set_colorings(data_json, config, command_line_colorings, metadata_names, node_data_colorings, provided_colors, node_attrs, branch_attrs)ο
- augur.export_v2.set_data_provenance(data_json, config)ο
Set the data provenance from the given config file to the given data JSON.
- Parameters:
Examples
>>> config = {"data_provenance": [{"name": "GISAID"}, {"name": "INSDC"}]} >>> data_json = {"meta": {}} >>> set_data_provenance(data_json, config) >>> data_json["meta"]["data_provenance"][0]["name"] 'GISAID'
- augur.export_v2.set_description(data_json, cmd_line_description_file)ο
Read Markdown file provided by cmd_line_description_file and set meta.description in data_json to the text provided.
- augur.export_v2.set_display_defaults(data_json, config)ο
- augur.export_v2.set_filters(data_json, config)ο
- augur.export_v2.set_geo_resolutions(data_json, config, command_line_traits, lat_long_mapping, node_attrs)ο
appropriately combine provided geo resolutions from command line & config files and associate with lat/longs.
- augur.export_v2.set_maintainers(data_json, config, cmd_line_maintainers)ο
- augur.export_v2.set_node_attrs_on_tree(data_json, node_attrs, additional_metadata_columns)ο
Assign desired colorings, metadata etc to the node_attrs of nodes in the tree
- augur.export_v2.set_panels(data_json, config, cmd_line_panels)ο
- augur.export_v2.set_title(data_json, config, cmd_line_title)ο
- augur.export_v2.update_deprecated_names(name)ο
- augur.export_v2.validate_data_json(filename, validation_mode=ValidationMode.ERROR)ο
- augur.export_v2.validation_failure(mode)ο
- augur.export_v2.warning(message)ο