Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Member Functions
Bio.SCOP.Hie.Record Class Reference

List of all members.

Public Member Functions

def __init__
def __str__

Public Attributes

 sunid
 parent
 children

Private Member Functions

def _process

Detailed Description

Holds information for one node in the SCOP hierarchy.

sunid      -- SCOP unique identifiers of this node

parent     --  Parents sunid

children   -- Sequence of childrens sunids

Definition at line 19 of file Hie.py.


Constructor & Destructor Documentation

def Bio.SCOP.Hie.Record.__init__ (   self,
  line = None 
)

Definition at line 28 of file Hie.py.

00028 
00029     def __init__(self, line=None):
00030         self.sunid = ''
00031         self.parent = ''
00032         self.children = []
00033         if line:
00034             self._process(line)


Member Function Documentation

Definition at line 70 of file Hie.py.

00070 
00071     def __str__(self):
00072         s = []
00073         s.append(str(self.sunid))
00074 
00075         if self.parent:
00076             s.append(str(self.parent))
00077         else:
00078             if self.sunid != 0:
00079                 s.append('0')
00080             else:
00081                 s.append('-')
00082                 
00083 
00084         if self.children:
00085             child_str = map(str, self.children)
00086             s.append(",".join(child_str))
00087         else:
00088             s.append('-')
00089 
00090         return "\t".join(s) + "\n"
00091 

def Bio.SCOP.Hie.Record._process (   self,
  line 
) [private]
Parses HIE records.

Records consist of 3 tab deliminated fields; node's sunid,
parent's sunid, and a list of children's sunids.

Definition at line 35 of file Hie.py.

00035 
00036     def _process(self, line):
00037         """Parses HIE records.
00038 
00039         Records consist of 3 tab deliminated fields; node's sunid,
00040         parent's sunid, and a list of children's sunids.
00041         """
00042         #For example ::
00043         #
00044         #0       -       46456,48724,51349,53931,56572,56835,56992,57942
00045         #21953   49268   -
00046         #49267   49266   49268,49269
00047         line = line.rstrip()        # no trailing whitespace
00048         columns = line.split('\t')   # separate the tab-delineated cols
00049         if len(columns) != 3:
00050             raise ValueError("I don't understand the format of %s" % line)
00051         
00052         sunid, parent, children = columns
00053 
00054         if sunid =='-':
00055             self.sunid = ''
00056         else:
00057             self.sunid = int(sunid)
00058 
00059         if parent=='-':
00060             self.parent = ''
00061         else:
00062             self.parent = int(parent)
00063 
00064         if children=='-':
00065             self.children = ()
00066         else:
00067             children = children.split(',')
00068             self.children = map(int, children)
00069 


Member Data Documentation

Definition at line 31 of file Hie.py.

Definition at line 30 of file Hie.py.

Definition at line 29 of file Hie.py.


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