Bio.Nexus.Nodes module¶
Linked list functionality for use in Bio.Nexus.
Provides functionality of a linked list. Each node has one (or none) predecessor, and an arbitrary number of successors. Nodes can store arbitrary data in a NodeData class.
Subclassed by Nexus.Trees to store phylogenetic trees.
Bug reports to Frank Kauff (fkauff@biologie.uni-kl.de)
- exception Bio.Nexus.Nodes.ChainException¶
Bases:
Exception
Provision for the management of Chain exceptions.
- exception Bio.Nexus.Nodes.NodeException¶
Bases:
Exception
Provision for the management of Node exceptions.
- class Bio.Nexus.Nodes.Chain¶
Bases:
object
Stores a list of nodes that are linked together.
- __init__(self)¶
Initialize a node chain.
- all_ids(self)¶
Return a list of all node ids.
- add(self, node, prev=None)¶
Attach node to another.
- collapse(self, id)¶
Delete node from chain and relinks successors to predecessor.
- kill(self, id)¶
Kill a node from chain without caring to what it is connected.
- unlink(self, id)¶
Disconnect node from his predecessor.
- link(self, parent, child)¶
Connect son to parent.
- is_parent_of(self, parent, grandchild)¶
Check if grandchild is a subnode of parent.
- trace(self, start, finish)¶
Return a list of all node_ids between two nodes (excluding start, including end).
- class Bio.Nexus.Nodes.Node(data=None)¶
Bases:
object
A single node.
- __init__(self, data=None)¶
Represent a node with one predecessor and multiple successors.
- set_id(self, id)¶
Set the id of a node, if not set yet.
- get_id(self)¶
Return the node’s id.
- get_succ(self)¶
Return a list of the node’s successors.
- get_prev(self)¶
Return the id of the node’s predecessor.
- add_succ(self, id)¶
Add a node id to the node’s successors.
- remove_succ(self, id)¶
Remove a node id from the node’s successors.
- set_succ(self, new_succ)¶
Set the node’s successors.
- set_prev(self, id)¶
Set the node’s predecessor.
- get_data(self)¶
Return a node’s data.
- set_data(self, data)¶
Set a node’s data.