Logo Search packages:      
Sourcecode: python-biopython version File versions

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 215 of file Raf.py.

00215                                                :
        """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.
        """
        #This code should be refactored when (if?) biopython gets a PDB parser 

        #The set of residues that I have to find records for. 
        resSet = {}
        for r in self.res :
            if r.atom=='X' : #Unknown residue type
                continue
            chainid = r.chainid
            if chainid == '_':
                chainid = ' '
            resid = r.resid
            resSet[(chainid,resid)] = r

        resFound = {}
        for line in pdb_handle.xreadlines() :
            if line.startswith("ATOM  ") or line.startswith("HETATM") :
                chainid = line[21:22]
                resid = line[22:27].strip()
                key = (chainid, resid)
                if resSet.has_key(key):
                    res = resSet[key]
                    atom_aa = res.atom
                    resName = line[17:20]
                    if to_one_letter_code.has_key(resName) :
                        if to_one_letter_code[resName] == atom_aa :
                            out_handle.write(line)
                            resFound[key] = res

        if len(resSet) != len(resFound) :
            #for k in resFound.keys():
            #    del resSet[k]
            #print resSet
                                     
            raise RuntimeError, 'I could not find at least one ATOM or ' \
               +'HETATM record for each and every residue in this sequence map.'
        
        
        
class Res :


Generated by  Doxygen 1.6.0   Back to index