Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.SCOP.Cla.Index Class Reference

List of all members.

Public Member Functions

def __init__
def __getitem__

Public Attributes

 filename

Detailed Description

A CLA file indexed by SCOP identifiers, allowing rapid
   random access into a file.

Definition at line 93 of file Cla.py.


Constructor & Destructor Documentation

def Bio.SCOP.Cla.Index.__init__ (   self,
  filename 
)
Arguments:

  filename  -- The file to index

Definition at line 96 of file Cla.py.

00096 
00097     def __init__(self, filename):
00098         """
00099         Arguments:
00100         
00101           filename  -- The file to index
00102         """
00103         dict.__init__(self)
00104         self.filename = filename
00105         f = open(self.filename, "rU")
00106         try:
00107             position = 0
00108             while True:
00109                 line = f.readline()
00110                 if not line: break
00111                 if line.startswith('#'):
00112                     continue
00113                 record = Record(line)
00114                 key = record.sid
00115                 if key != None:
00116                     self[key] = position
00117                 position = f.tell()
00118         finally:
00119             f.close()


Member Function Documentation

def Bio.SCOP.Cla.Index.__getitem__ (   self,
  key 
)
Return an item from the indexed file. 

Definition at line 120 of file Cla.py.

00120 
00121     def __getitem__(self, key):
00122         """ Return an item from the indexed file. """
00123         position = dict.__getitem__(self,key)
00124 
00125         f = open(self.filename, "rU")
00126         try:
00127             f.seek(position)
00128             line = f.readline()
00129             record = Record(line)
00130         finally:
00131             f.close()
00132         return record

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 103 of file Cla.py.


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