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:
Returns:

[0]float

The root date offset

[1]float

The date of the most recent tip in the tree

Return type:

tuple

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:
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.

Properties

treeBio.Phylo.BaseTree.Tree

BEAST traits are set as key-value pairs on node.attrs

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 (Bio.Phylo.BaseTree.Tree)

Return type:

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 (Bio.Phylo.BaseTree.Tree)

  • tip_date_regex (str) – 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 (str) – The format of the extracted date. (e.g. β€œ%Y-%m-%d” goes with β€œ2012-10-30”)

  • tip_date_delimeter (str) – The delimeter in tip_date_format

Raises:

AssertionError – If any tips were not matched by the regex

Returns:

The date of the most recent tip in the tree in decimal format

Return type:

float

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 (str) – 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) – Should output be printed?

Return type:

Bio.Phylo.Newick.Clade

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 – The nexus tree file

  • treestring_regex (str) – 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) – Should output be printed?

Raises:

AssertionError – If the tree was not correctly parsed

Returns:

A tree with BEAST attrs set on each node (as applicable)

Return type:

Bio.Phylo.BaseTree.Tree

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_parser(parent_subparsers)

Arguments available to augur import beast

augur.import_.beast.run(args)

BEAST MCC tree to newick and node-data JSON for further augur processing / export

augur.import_.beast.summarise_parsed_traits(tree)
Parameters:

tree (Bio.Phylo.BaseTree.Tree)