Ejemplo n.º 1
0
 def parsepdb(self,lines):
     """
      Parses a PDB file, which is contained in lines (a list of lines)
     """
     import PDBparser
     Y=PDBparser.PDBparser(lines,self.parse_terms)
     Y.parse()
     self.atoms=Y.atoms
     self.Update()
     self.attribute=Y.attribute        
     return
Ejemplo n.º 2
0
 def readpdb(self,filename=None,data=None,parse=1,readmodels=1,use_NMRnumber=True):
     """
     # Reads a pdb file and lets PDBparser.parse do the parsing
     """
     import os
     if data != None:
         import StringIO
         stream = StringIO.StringIO(data)            
         self.lines = stream.readlines()            
     elif os.path.isfile(filename):
         if not silent:
             print 'Reading: ',filename
         fd=open(filename)
         self.lines=fd.readlines()
         fd.close()
     else:
         raise FileNotFoundError(filename)            
     if parse:
         import PDBparser
         Y=PDBparser.PDBparser(self.lines,self.parse_terms)
         Y.readmodels=readmodels
         if not use_NMRnumber:
             Y.ignore_NMRmodel=True
         #
         Y.parse()
         self.atoms=Y.atoms
         if hasattr(Y,'spacegroup'):
             self.spacegroup=Y.spacegroup # Transfer spacegroup info
         else:
             self.spacegroup='Unknown'
         self.header=''
         if hasattr(Y,'header'):
             self.header=Y.header
         #
         # Transfer crystal symmetry info
         #
         self.scale=Y.scale
         self.orig=Y.orig
         self.cryst=Y.cryst
         #
         # Update
         #
         self.Update()
         self.attribute=Y.attribute
         if not silent:
             print 'Read file with %3d residues and %5d atoms' %(len(self.residues.keys()),len(self.atoms.keys()))
     return    
Ejemplo n.º 3
0
 def addpdblines(self,lines):
     """Add the atoms in lines to the current set of atoms"""
     import PDBparser
     Y=PDBparser.PDBparser(lines,self.parse_terms)
     Y.parse()
     error=False
     for atom in Y.atoms.keys():
         if not self.atoms.has_key(atom):
             self.atoms[atom]=Y.atoms[atom]
         else:
             print 'Name clash for',atom
             error=True
     if not error:
         self.Update()
         self.attribute=Y.attribute        
         return
     else:
         print 'Protool does not allow name clashes'
         import os
         os._exit(0)