torchtree.evolution.io#

Classes#

Functions#

read_tree(tree[, dated, heterochornous])

read_tree_and_alignment(tree, alignment[, dated, ...])

to_nexus(node, fp)

convert_samples_to_nexus(tree, sample, output)

random_tree_from_heights(→ Node)

parse_translate(fp)

parse_trees(fp[, count])

parse_taxa(fp)

split_newick(→ list[str])

Split tree in newick format around (),;

extract_taxa(→ list[str])

Extract taxon list from a nexus file.

Module Contents#

torchtree.evolution.io.read_tree(tree, dated=True, heterochornous=True)[source]#
torchtree.evolution.io.read_tree_and_alignment(tree, alignment, dated=True, heterochornous=True)[source]#
torchtree.evolution.io.to_nexus(node, fp)[source]#
torchtree.evolution.io.convert_samples_to_nexus(tree, sample, output)[source]#
class torchtree.evolution.io.Node(name, height=0.0)[source]#
name#
height#
parent = None#
children = []#
torchtree.evolution.io.random_tree_from_heights(sampling: torch.Tensor, heights: torch.Tensor) Node[source]#
torchtree.evolution.io.parse_translate(fp)[source]#
torchtree.evolution.io.parse_trees(fp, count=None)[source]#
torchtree.evolution.io.parse_taxa(fp)[source]#
torchtree.evolution.io.split_newick(newick: str) list[str][source]#

Split tree in newick format around (),;

Example

>>> newick = '((a:1[&a={1,2}],b:1):1,c:1);'
>>> split_newick('((a:1,b:1):1,c:1);')
['(', '(', 'a:1', ',', 'b:1', ')', ':1', ',', 'c:1', ')', ';']
Parameters:

newick (str) – newick tree

Return List[str]:

list of strings

torchtree.evolution.io.extract_taxa(file_name: str) list[str][source]#

Extract taxon list from a nexus file.

This function will try get the taxon names from the taxa and trees blocks.

Parameters:

file_name (str) – path to the nexus file

Return List[str]:

list of taxon names