def parseReference(self, fpdb, dry_out=None ): flushPrint("parsing "+fpdb+"...") m = PDBModel( fpdb ) solute_res = m.atom2resMask( N.logical_not( m.maskSolvent() ) ) self.lenres = self.lenres or N.sum( solute_res) assert isinstance( self.lenres, N.integer ) self.lenatoms = len( m ) - N.sum( m.maskH2O() ) assert isinstance( self.lenatoms, N.integer) if dry_out: m.remove( m.maskH2O() ) m.writePdb( dry_out ) flushPrint('done.\n')
def parseReference(self, fpdb, dry_out=None): flushPrint("parsing " + fpdb + "...") m = PDBModel(fpdb) solute_res = m.atom2resMask(N.logical_not(m.maskSolvent())) self.lenres = self.lenres or N.sum(solute_res) assert isinstance(self.lenres, N.integer) self.lenatoms = len(m) - N.sum(m.maskH2O()) assert isinstance(self.lenatoms, N.integer) if dry_out: m.remove(m.maskH2O()) m.writePdb(dry_out) flushPrint('done.\n')
class PymolModel: def __init__( self, model, modName ): """ @param model: model to view @type model: PDBModel @param modName: model name, will show up in PyMol @type modName: str """ self.fname = '' self.temporary = 0 self.struct = None if type( model ) is str: self.fname = model else: self.struct = model.clone() ## clone atom dicts self.temporary = 1 self.modName = modName if self.fname == '': self.fname = tempfile.mktemp( 'model') def addProperty( self, values, key='temperature_factor' ): """ Add extra value to each atom in Structure. The values will be written to either the B- (temperature_factor) or Q-factor 'occupancy' column in the temporary pdb-file. These values can then be used to display properties in PyMol via commands like 'color_b' and 'color_q'. See also L{addResProperty}. @param values: list of numbers, len( values ) == number of atoms @type values: [float] @param key: key for Atom.properties dictionary ('occupancy' OR 'temperature_factor') @type key: occupancy|temperature_factor """ if self.struct is None: self.struct = PDBModel( self.fname ) self.temporary = 1 self.struct[ key ] = values def addResProperty( self, values, key='temperature_factor'): """ Does the same thing as L{addProperty} but on the residue level, i.e adds extra value to each residue in Structure. (The same value is added to all atoms of a residue.) These values can then be used to display properties in PyMol via commands like 'color_b' and 'color_q'. @param values: list of numbers, len( values ) == number of residues @type values: [float] @param key: key for Atom.properties dictionary ('occupancy' OR 'temperature_factor') @type key: occupancy|temperature_factor """ try: if self.struct is None: self.struct = PDBModel( self.fname ) self.temporary = 1 self.struct[ key ] = self.struct.res2atomProfile( values ) except: print(T.lastError()) def writeIfNeeded( self ): """ Create pdb on disc if it's not already there or if it has to be changed. @return: filename of new or existing pdb @rtype: str """ if self.temporary: self.struct.writePdb( self.fname, 2 ) return self.fname