Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.Nexus.Nodes.Chain Class Reference
Inheritance diagram for Bio.Nexus.Nodes.Chain:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def all_ids
def add
def collapse
def kill
def unlink
def link
def is_parent_of
def trace

Public Attributes

 chain
 id

Private Member Functions

def _get_id

Detailed Description

Stores a list of nodes that are linked together.

Definition at line 23 of file Nodes.py.


Constructor & Destructor Documentation

Initiates a node chain: (self).

Definition at line 26 of file Nodes.py.

00026 
00027     def __init__(self):
00028         """Initiates a node chain: (self)."""
00029         self.chain={}
00030         self.id=-1

Here is the caller graph for this function:


Member Function Documentation

def Bio.Nexus.Nodes.Chain._get_id (   self) [private]
Gets a new id for a node in the chain.

Definition at line 31 of file Nodes.py.

00031 
00032     def _get_id(self):
00033         """Gets a new id for a node in the chain."""
00034         self.id+=1
00035         return self.id 
   

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.add (   self,
  node,
  prev = None 
)
Attaches node to another: (self, node, prev).

Definition at line 40 of file Nodes.py.

00040 
00041     def add(self,node,prev=None):
00042         """Attaches node to another: (self, node, prev)."""
00043         if prev is not None and prev not in self.chain:
00044             raise ChainException('Unknown predecessor: '+str(prev))
00045         else:
00046             id=self._get_id()
00047             node.set_id(id)
00048             node.set_prev(prev)
00049             if prev is not None:
00050                 self.chain[prev].add_succ(id)
00051             self.chain[id]=node
00052         return id

Here is the call graph for this function:

Here is the caller graph for this function:

Return a list of all node ids.

Definition at line 36 of file Nodes.py.

00036 
00037     def all_ids(self):
00038         """Return a list of all node ids."""
00039         return self.chain.keys()

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.collapse (   self,
  id 
)
Deletes node from chain and relinks successors to predecessor: collapse(self, id).

Definition at line 53 of file Nodes.py.

00053 
00054     def collapse(self,id):
00055         """Deletes node from chain and relinks successors to predecessor: collapse(self, id)."""
00056         if id not in self.chain:
00057             raise ChainException('Unknown ID: '+str(id))
00058         prev_id=self.chain[id].get_prev()
00059         self.chain[prev_id].remove_succ(id)
00060         succ_ids=self.chain[id].get_succ()
00061         for i in succ_ids:
00062             self.chain[i].set_prev(prev_id)
00063         self.chain[prev_id].add_succ(succ_ids)
00064         node=self.chain[id]
00065         self.kill(id)
00066         return node

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.is_parent_of (   self,
  parent,
  grandchild 
)
Check if grandchild is a subnode of parent: is_parent_of(self,parent,grandchild).

Definition at line 96 of file Nodes.py.

00096 
00097     def is_parent_of(self,parent,grandchild):
00098         """Check if grandchild is a subnode of parent: is_parent_of(self,parent,grandchild)."""
00099         if grandchild==parent or grandchild in self.chain[parent].get_succ():
00100             return True
00101         else:
00102             for sn in self.chain[parent].get_succ():
00103                 if self.is_parent_of(sn,grandchild):
00104                     return True
00105             else:
00106                 return False

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.kill (   self,
  id 
)
Kills a node from chain without caring to what it is connected: kill(self,id).

Definition at line 67 of file Nodes.py.

00067 
00068     def kill(self,id):
00069         """Kills a node from chain without caring to what it is connected: kill(self,id)."""
00070         if id not in self.chain:
00071             raise ChainException('Unknown ID: '+str(id))
00072         else:
00073             del self.chain[id]

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.link (   self,
  parent,
  child 
)
Connects son to parent: link(self,son,parent).

Definition at line 85 of file Nodes.py.

00085 
00086     def link(self, parent,child):
00087         """Connects son to parent: link(self,son,parent)."""
00088         if child not in self.chain:
00089             raise ChainException('Unknown ID: '+str(child))
00090         elif parent not in self.chain:
00091             raise ChainException('Unknown ID: '+str(parent))
00092         else:
00093             self.unlink(child)
00094             self.chain[parent].succ.append(child)
00095             self.chain[child].set_prev(parent)

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.trace (   self,
  start,
  finish 
)
Returns a list of all node_ids between two nodes (excluding start, including end): trace(start,end).

Definition at line 107 of file Nodes.py.

00107 
00108     def trace(self,start,finish):
00109         """Returns a list of all node_ids between two nodes (excluding start, including end): trace(start,end)."""
00110         if start not in self.chain or finish not in self.chain:
00111             raise NodeException('Unknown node.')
00112         if not self.is_parent_of(start,finish) or start==finish:
00113             return []
00114         for sn in self.chain[start].get_succ():
00115             if self.is_parent_of(sn,finish):
00116                 return [sn]+self.trace(sn,finish)
                

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.Nexus.Nodes.Chain.unlink (   self,
  id 
)
Disconnects node from his predecessor: unlink(self,id).

Definition at line 74 of file Nodes.py.

00074 
00075     def unlink(self,id):
00076         """Disconnects node from his predecessor: unlink(self,id)."""
00077         if id not in self.chain:
00078             raise ChainException('Unknown ID: '+str(id))
00079         else:
00080             prev_id=self.chain[id].prev
00081             if prev_id is not None:
00082                 self.chain[prev_id].succ.pop(self.chain[prev_id].succ.index(id))
00083             self.chain[id].prev=None
00084             return prev_id

Here is the caller graph for this function:


Member Data Documentation

Definition at line 28 of file Nodes.py.

Definition at line 29 of file Nodes.py.


The documentation for this class was generated from the following file: