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__()

Initialize a node chain.

all_ids()

Return a list of all node ids.

add(node, prev=None)

Attach node to another.

collapse(id)

Delete node from chain and relinks successors to predecessor.

kill(id)

Kill a node from chain without caring to what it is connected.

Disconnect node from his predecessor.

Connect son to parent.

is_parent_of(parent, grandchild)

Check if grandchild is a subnode of parent.

trace(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__(data=None)

Represent a node with one predecessor and multiple successors.

set_id(id)

Set the id of a node, if not set yet.

get_id()

Return the node’s id.

get_succ()

Return a list of the node’s successors.

get_prev()

Return the id of the node’s predecessor.

add_succ(id)

Add a node id to the node’s successors.

remove_succ(id)

Remove a node id from the node’s successors.

set_succ(new_succ)

Set the node’s successors.

set_prev(id)

Set the node’s predecessor.

get_data()

Return a node’s data.

set_data(data)

Set a node’s data.