Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
Bio.SCOP.Raf.SeqMapIndex Class Reference

List of all members.

Public Member Functions

def __init__
def __getitem__
def getSeqMap

Public Attributes

 filename

Detailed Description

An RAF file index.

The RAF file itself is about 50 MB. This index provides rapid, random
access of RAF records without having to load the entire file into memory.

The index key is a concatenation of the  PDB ID and chain ID. e.g
"2drcA", "155c_". RAF uses an underscore to indicate blank
chain IDs.    

Definition at line 45 of file Raf.py.


Constructor & Destructor Documentation

def Bio.SCOP.Raf.SeqMapIndex.__init__ (   self,
  filename 
)
Arguments:

  filename  -- The file to index

Definition at line 56 of file Raf.py.

00056 
00057     def __init__(self, filename):
00058         """
00059         Arguments:
00060         
00061           filename  -- The file to index
00062         """
00063         dict.__init__(self)
00064         self.filename = filename
00065 
00066         f = open(self.filename, "rU")
00067         try:
00068             position = 0
00069             while True:
00070                 line = f.readline()
00071                 if not line: break
00072                 key = line[0:5]
00073                 if key != None:
00074                     self[key]=position
00075                 position = f.tell()
00076         finally:
00077             f.close()


Member Function Documentation

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

Definition at line 78 of file Raf.py.

00078 
00079     def __getitem__(self, key):
00080         """ Return an item from the indexed file. """
00081         position = dict.__getitem__(self,key)
00082 
00083         f = open(self.filename, "rU")
00084         try:
00085             f.seek(position)
00086             line = f.readline()
00087             record = SeqMap(line)
00088         finally:
00089             f.close()
00090         return record
00091 

Here is the call graph for this function:

Here is the caller graph for this function:

def Bio.SCOP.Raf.SeqMapIndex.getSeqMap (   self,
  residues 
)
Get the sequence map for a collection of residues.

residues -- A Residues instance, or a string that can be converted into
    a Residues instance.

Definition at line 92 of file Raf.py.

00092 
00093     def getSeqMap(self, residues):
00094         """Get the sequence map for a collection of residues.
00095 
00096         residues -- A Residues instance, or a string that can be converted into
00097                     a Residues instance.
00098         """
00099         if isinstance(residues, basestring):
00100             residues = Residues(residues)
00101 
00102         pdbid  = residues.pdbid
00103         frags = residues.fragments
00104         if not frags: frags =(('_','',''),) # All residues of unnamed chain
00105 
00106         seqMap = None
00107         for frag in frags:
00108             chainid = frag[0]
00109             if chainid=='' or chainid=='-' or chainid==' ' or chainid=='_':
00110                 chainid = '_'
00111             id = pdbid + chainid
00112             
00113             
00114             sm = self[id]
00115             
00116             #Cut out fragment of interest
00117             start = 0
00118             end = len(sm.res)
00119             if frag[1] : start = int(sm.index(frag[1], chainid))
00120             if frag[2] : end = int(sm.index(frag[2], chainid)+1)
00121             
00122             sm = sm[start:end]
00123 
00124             if seqMap == None:
00125                 seqMap = sm
00126             else:
00127                 seqMap += sm
00128                             
00129         return seqMap
00130 


Member Data Documentation

Definition at line 63 of file Raf.py.


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