-
Notifications
You must be signed in to change notification settings - Fork 29
Class `baltic.leaf`
The leaf
class in BALTIC represents a leaf (also known as a tip) in a phylogenetic tree. This class is crucial for representing the terminal nodes of the tree, typically corresponding to sampled organisms or sequences.
class leaf:
def __init__(self):
# ... (initialization of attributes)
def is_leaflike(self):
return True
def is_leaf(self):
return True
def is_node(self):
return False
Attribute | Type | Description |
---|---|---|
branchType |
str | The type of branch. Default is 'leaf'. |
name |
str | The name of the tip after translation. Assigned in make_tree() . |
index |
int | The index of the character that defines this object in the tree string. Assigned in make_tree() . |
length |
float | The length of the branch. Assigned in make_tree() . |
absoluteTime |
float or None | The position of the tip in absolute time. Assigned in setAbsoluteTime() . |
height |
float | The height of the tip. Assigned in traverse_tree() . |
parent |
node | The parent node. Assigned in make_tree() . |
traits |
dict | Dictionary containing traits associated with the leaf. Assigned in make_tree() . |
x |
float or None | The x-coordinate for plotting. Default is None. |
y |
float or None | The y-coordinate for plotting. Default is None. |
def is_leaflike(self):
return True
Indicates whether the object is leaf-like. Always returns True
for leaf
objects.
def is_leaf(self):
return True
Indicates whether the object is a leaf. Always returns True
for leaf
objects.
def is_node(self):
return False
Indicates whether the object is a node. Always returns False
for leaf
objects.
The leaf
class is used internally by BALTIC to represent the tips of phylogenetic trees. Users typically don't create leaf
objects directly, but interact with them when analyzing or visualizing trees.
Example of accessing leaf attributes after tree construction:
# Assuming 'tree' is a BALTIC tree object
for obj in tree.Objects:
if obj.is_leaf():
print(f"Leaf {obj.index}:")
print(f" Name: {obj.name}")
print(f" Branch length: {obj.length}")
print(f" Absolute time: {obj.absoluteTime}")
print(f" Traits: {obj.traits}")
- The
leaf
class is essential for representing the tips of the phylogenetic tree, which often correspond to sampled sequences or organisms. - The
name
attribute is particularly important as it identifies the specific entity represented by this leaf. - The
traits
dictionary can contain various metadata associated with the leaf, such as sampling date, location, or any other relevant information provided in the input tree. - The
x
andy
attributes are used for plotting and visualization purposes and are typically set by BALTIC's tree drawing functions. - The
absoluteTime
attribute is useful for time-calibrated trees, representing the sampling time or age of the tip.
For more information on how leaf
objects are used in tree construction and analysis, refer to the BALTIC documentation on tree building, traversal, and visualization functions.
Wiki written with the assistance of claude.ai 3.5 "Sonnet".
- Core
baltic
classes:-
Class
tree
- Tree Construction and Manipulation methods
- Tree Analysis methods
- Tree Conversion and Output methods
- Tree Visualization
- Utility Methods
- Class
leaf
- Class
node
- Class
clade
- Class
reticulation
-
Class