augur.import_beast module¶
Parse a BEAST MCC tree for further analysis in augur or export for auspice v2+ (using augur export v2 or greater).
-
augur.import_beast.
calc_tree_dates
(tree, most_recent_tip_date, tip_date_regex, tip_date_format, tip_date_delimeter)¶ Extract date information from the tree
- Parameters
tree (<class 'Bio.Phylo.BaseTree.Tree'>) –
time_units (#) –
tip_date (#) –
most_recent_tip_data_fmt (#) –
most_recent_tip_date (numeric) –
tip_date_regex (string) –
tip_date_format (string) –
tip_date_delimeter (string) –
- Returns
tuple –
- [0]float
The root date offset
- [1]float
The date of the most recent tip in the tree
TODO (Time units are taken as years, but days are also common for BEAST analysis)
-
augur.import_beast.
collect_node_data
(tree, root_date_offset, most_recent_tip_date)¶ Collect & summarise the BEAST traits included on the tree in a format applicable for augur to use (i.e. the “node_data.json” file).
- Parameters
tree (<class 'Bio.Phylo.BaseTree.Tree'>) –
root_date_offset (float) –
most_recent_tip_date (float) –
- Returns
the keys are dependent on the content of the BEAST input
- Return type
dict
-
augur.import_beast.
compute_entropies_for_discrete_traits
(tree)¶ Computes entropies for discrete traits. Discrete traits are assumed to be those where the value is a dictionary. This will set a “entropy” value for each identified discrete trait on all applicable nodes in the tree.
- tree<class ‘Bio.Phylo.BaseTree.Tree’>
BEAST traits are set as key-value pairs on node.attrs
Author: James Hadfield
-
augur.import_beast.
fake_alignment
(T)¶ Fake alignment to appease treetime when only using it for naming nodes… This is lifted from refine.py and ideally could be imported
- Parameters
T (<class 'Bio.Phylo.BaseTree.Tree'>) –
- Returns
- Return type
<class ‘Bio.Align.MultipleSeqAlignment’>
-
augur.import_beast.
find_most_recent_tip
(tree, tip_date_regex, tip_date_format, tip_date_delimeter)¶ Find the most recent tip in the tree
- Parameters
tree (<class 'Bio.Phylo.BaseTree.Tree'>) –
tip_date_regex (string) – The regex used to extract the date (e.g. isolate collection date from each tip in the string. default: hyphen delimited numbers at the end of tip name
tip_date_format (string) – The format of the extracted date. (e.g. “%Y-%m-%d” goes with “2012-10-30”)
tip_date_delimeter (string) – The delimeter in tip_date_format
- Raises
AssertionError – If any tips were not matched by the regex
- Returns
float – The date of the most recent tip in the tree in decimal format
Author (Gytis Dudas)
-
augur.import_beast.
get_root_date_offset
(tree)¶ years from most recent tip of the root
-
augur.import_beast.
parse_beast_tree
(data, tipMap, verbose=False)¶ Parses the BEAST tree (and attributes etc) as encoded in NEXUS.
- Parameters
data (string) – The (really long) line in the NEXUS file beginning with “tree”, pruned to start at the first “(” character.
tipMap (dict) – Mapping of tips (as encoded in data) to their names
verbose (bool, optional (default: false)) – Should output be printed?
- Returns
<class ‘Bio.Phylo.Newick.Clade’>
Author (Gytis Dudas)
-
augur.import_beast.
parse_nexus
(tree_path, treestring_regex='tree [A-Za-z\\_]+([0-9]+)', verbose=False)¶ Parses the BEAST MCC tree (NEXUS format)
- Parameters
tree_path (string or file handle open for reading) – The nexus tree file
treestring_regex (string) – The regex to match the tree string in the nexus file (the really long string which typically starts with “tree” and looks similar to a newick tree)
verbose (bool, optional (default: False)) – Should output be printed?
- Raises
AssertionError – If the tree was not correctly parsed
- Returns
<class ‘Bio.Phylo.BaseTree.Tree’> – A tree with BEAST attrs set on each node (as applicable)
Author (Gytis Dudas)
-
augur.import_beast.
print_what_to_do_next
(nodes, mcc_path, tree_path, node_data_path)¶ Print a suggested auspice_config.json file, which the user will have to configure and provide to augur export. There is not enough information in a MCC tree to do this automatically.
-
augur.import_beast.
register_arguments_beast
(subparsers)¶ Arguments available to augur import beast
-
augur.import_beast.
run_beast
(args)¶ BEAST MCC tree to newick and node-data JSON for further augur processing / export
-
augur.import_beast.
summarise_parsed_traits
(tree)¶ - Parameters
tree (<class 'Bio.Phylo.BaseTree.Tree'>) –