Back to index

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

List of all members.

Public Member Functions

def __init__
def index
def __getitem__
def append
def extend
def __iadd__
def __add__
def getAtoms

Public Attributes

 pdbid
 pdb_datestamp
 version
 flags
 res

Private Member Functions

def _process

Detailed Description

An ASTRAL RAF (Rapid Access Format) Sequence Map.

This is a list like object; You can find the location of particular residues
with index(), slice this SeqMap into fragments, and glue fragments back
together with extend().

pdbid -- The PDB 4 character ID

pdb_datestamp -- From the PDB file

version -- The RAF format version. e.g. 0.01

flags -- RAF flags. (See release notes for more information.)

res -- A list of Res objects, one for each residue in this sequence map

Definition at line 131 of file Raf.py.


Constructor & Destructor Documentation

def Bio.SCOP.Raf.SeqMap.__init__ (   self,
  line = None 
)

Definition at line 149 of file Raf.py.

00149 
00150     def __init__(self, line=None):
00151         self.pdbid = ''
00152         self.pdb_datestamp = ''
00153         self.version = ''
00154         self.flags = ''
00155         self.res = []
00156         if line:
00157             self._process(line)
00158         


Member Function Documentation

def Bio.SCOP.Raf.SeqMap.__add__ (   self,
  other 
)

Definition at line 234 of file Raf.py.

00234 
00235     def __add__(self, other):
00236         s = copy(self)
00237         s.extend(other)
00238         return s

def Bio.SCOP.Raf.SeqMap.__getitem__ (   self,
  index 
)

Definition at line 200 of file Raf.py.

00200 
00201     def __getitem__(self, index):
00202         if not isinstance(index, slice):
00203             raise NotImplementedError
00204         s = copy(self)
00205         s.res = s.res[index]
00206         return s

Here is the caller graph for this function:

def Bio.SCOP.Raf.SeqMap.__iadd__ (   self,
  other 
)

Definition at line 230 of file Raf.py.

00230 
00231     def __iadd__(self, other):
00232         self.extend(other)
00233         return self

Here is the call graph for this function:

def Bio.SCOP.Raf.SeqMap._process (   self,
  line 
) [private]
Parses a RAF record into a SeqMap object.

Definition at line 159 of file Raf.py.

00159 
00160     def _process(self, line):
00161         """Parses a RAF record into a SeqMap object.
00162         """
00163         header_len = 38
00164  
00165         line = line.rstrip()  # no trailing whitespace        
00166 
00167         if len(line)<header_len: 
00168             raise ValueError("Incomplete header: "+line)
00169 
00170         self.pdbid = line[0:4]
00171         chainid = line[4:5]
00172         
00173         self.version = line[6:10]
00174 
00175         #Raf format versions 0.01 and 0.02 are identical for practical purposes
00176         if(self.version != "0.01" and  self.version !="0.02"):
00177             raise ValueError("Incompatible RAF version: "+self.version)
00178 
00179         self.pdb_datestamp = line[14:20]
00180         self.flags = line[21:27]
00181 
00182         for i in range(header_len, len(line), 7):
00183             f = line[i : i+7]
00184             if len(f)!=7:
00185                 raise ValueError("Corrupt Field: ("+f+")")
00186             r = Res()
00187             r.chainid = chainid
00188             r.resid =  f[0:5].strip()
00189             r.atom = normalize_letters(f[5:6])
00190             r.seqres = normalize_letters(f[6:7])
00191 
00192             self.res.append(r)
00193 

Here is the call graph for this function:

def Bio.SCOP.Raf.SeqMap.append (   self,
  res 
)
Append another Res object onto the list of residue mappings.

Definition at line 207 of file Raf.py.

00207 
00208     def append(self, res):
00209         """Append another Res object onto the list of residue mappings."""
00210         self.res.append(res)

def Bio.SCOP.Raf.SeqMap.extend (   self,
  other 
)
Append another SeqMap onto the end of self.

Both SeqMaps must have the same PDB ID, PDB datestamp and
RAF version.  The RAF flags are erased if they are inconsistent. This
may happen when fragments are taken from different chains.

Definition at line 211 of file Raf.py.

00211 
00212     def extend(self, other):
00213         """Append another SeqMap onto the end of self.
00214 
00215         Both SeqMaps must have the same PDB ID, PDB datestamp and
00216         RAF version.  The RAF flags are erased if they are inconsistent. This
00217         may happen when fragments are taken from different chains.
00218         """
00219         if not isinstance(other, SeqMap):
00220             raise TypeError("Can only extend a SeqMap with a SeqMap.")
00221         if self.pdbid != other.pdbid:
00222             raise TypeError("Cannot add fragments from different proteins")
00223         if self.version != other.version:
00224             raise TypeError("Incompatible rafs")
00225         if self.pdb_datestamp != other.pdb_datestamp:
00226             raise TypeError("Different pdb dates!")
00227         if self.flags != other.flags:
00228             self.flags = ''
00229         self.res += other.res

Here is the caller graph for this function:

def Bio.SCOP.Raf.SeqMap.getAtoms (   self,
  pdb_handle,
  out_handle 
)
Extract all relevant ATOM and HETATOM records from a PDB file.

The PDB file is scanned for ATOM and HETATOM records. If the
chain ID, residue ID (seqNum and iCode), and residue type match
a residue in this sequence map, then the record is echoed to the
output handle.

This is typically used to find the coordinates of a domain, or other
residue subset.

pdb_handle -- A handle to the relevant PDB file.

out_handle -- All output is written to this file like object.

Definition at line 239 of file Raf.py.

00239 
00240     def getAtoms(self, pdb_handle, out_handle):
00241         """Extract all relevant ATOM and HETATOM records from a PDB file.
00242 
00243         The PDB file is scanned for ATOM and HETATOM records. If the
00244         chain ID, residue ID (seqNum and iCode), and residue type match
00245         a residue in this sequence map, then the record is echoed to the
00246         output handle.
00247 
00248         This is typically used to find the coordinates of a domain, or other
00249         residue subset.
00250 
00251         pdb_handle -- A handle to the relevant PDB file.
00252         
00253         out_handle -- All output is written to this file like object.
00254         """
00255         #This code should be refactored when (if?) biopython gets a PDB parser 
00256 
00257         #The set of residues that I have to find records for. 
00258         resSet = {}
00259         for r in self.res:
00260             if r.atom=='X' : #Unknown residue type
00261                 continue
00262             chainid = r.chainid
00263             if chainid == '_':
00264                 chainid = ' '
00265             resid = r.resid
00266             resSet[(chainid,resid)] = r
00267 
00268         resFound = {}
00269         for line in pdb_handle.xreadlines():
00270             if line.startswith("ATOM  ") or line.startswith("HETATM"):
00271                 chainid = line[21:22]
00272                 resid = line[22:27].strip()
00273                 key = (chainid, resid)
00274                 if key in resSet:
00275                     res = resSet[key]
00276                     atom_aa = res.atom
00277                     resName = line[17:20]
00278                     if resName in to_one_letter_code:
00279                         if to_one_letter_code[resName] == atom_aa:
00280                             out_handle.write(line)
00281                             resFound[key] = res
00282 
00283         if len(resSet) != len(resFound):
00284             #for k in resFound.keys():
00285             #    del resSet[k]
00286             #print resSet
00287                                      
00288             raise RuntimeError('I could not find at least one ATOM or HETATM' \
00289                    +' record for each and every residue in this sequence map.')
00290 

def Bio.SCOP.Raf.SeqMap.index (   self,
  resid,
  chainid = "_" 
)

Definition at line 194 of file Raf.py.

00194 
00195     def index(self, resid, chainid="_"):
00196         for i in range(0, len(self.res)):
00197             if self.res[i].resid == resid and self.res[i].chainid == chainid:
00198                 return i
00199         raise KeyError("No such residue "+chainid+resid)


Member Data Documentation

Definition at line 153 of file Raf.py.

Definition at line 151 of file Raf.py.

Definition at line 150 of file Raf.py.

Definition at line 154 of file Raf.py.

Definition at line 152 of file Raf.py.


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