def Model_Mutations_old(pdbfile, mol2files, mutations, max_overlap=0.5, return_score=False): """Model a number of mutations in a pdbfile when one or more ligands are present""" # # Initialise mutate routines # MUT = Mutate(max_bump=max_overlap) # # Read PDB file # import Protool P = Protool.structureIO() P.readpdb(pdbfile) P.remove_all_hydrogens() # # Read mol2 file # L = Protool.ligand(P) for mol2file in mol2files: print "Added %s with tag 'LIGAND'" % mol2file L.readmol2(mol2file, tag='LIGAND') # # Pass combined pdb file to mutate routines and mutate # MUT.new_PDB(P) import pKa.pKD_tools as pKD_tools total_bump = 0.0 # # Model # for mutation in mutations: # # Get info # resid = pKD_tools.get_resid_from_mut(mutation) newres = pKD_tools.get_newrestyp_from_mut(mutation) oldres = pKD_tools.get_oldrestyp_from_mut(mutation) bump_score = MUT.mutate(resid, newres, orgtype=oldres) if bump_score is None or bump_score is False or bump_score > max_overlap: print 'Cannot model this set of mutations - too many bumps' return False, 20.0 print 'Bump score for %s: %5.3f' % (mutation, bump_score) total_bump = total_bump + bump_score print 'Total bump score for all mutations: %5.3f' % (bump_score) if return_score: return MUT, bump_score return MUT
def Model_Mutations_old(pdbfile,mol2files,mutations,max_overlap=0.5,return_score=False): """Model a number of mutations in a pdbfile when one or more ligands are present""" # # Initialise mutate routines # MUT=Mutate(max_bump=max_overlap) # # Read PDB file # import Protool P=Protool.structureIO() P.readpdb(pdbfile) P.remove_all_hydrogens() # # Read mol2 file # L=Protool.ligand(P) for mol2file in mol2files: print "Added %s with tag 'LIGAND'" %mol2file L.readmol2(mol2file,tag='LIGAND') # # Pass combined pdb file to mutate routines and mutate # MUT.new_PDB(P) import pKa.pKD_tools as pKD_tools total_bump=0.0 # # Model # for mutation in mutations: # # Get info # resid=pKD_tools.get_resid_from_mut(mutation) newres=pKD_tools.get_newrestyp_from_mut(mutation) oldres=pKD_tools.get_oldrestyp_from_mut(mutation) bump_score=MUT.mutate(resid,newres,orgtype=oldres) if bump_score is None or bump_score is False or bump_score>max_overlap: print 'Cannot model this set of mutations - too many bumps' return False,20.0 print 'Bump score for %s: %5.3f' %(mutation,bump_score) total_bump=total_bump+bump_score print 'Total bump score for all mutations: %5.3f' %(bump_score) if return_score: return MUT,bump_score return MUT
def Model_Mutations(pdbfile, mol2files, mutations, max_overlap=0.5, max_totalbump=1.0, return_score=False, store_mutation_operations=False): """Model a number of mutations in a pdbfile when one or more ligands are present""" # # Check for stupidity # if max_overlap > max_totalbump: max_totalbump = max_overlap print 'Adjusted total bump cutoff to %5.2f' % max_totalbump # # Read PDB file # import Protool P = Protool.structureIO() P.readpdb(pdbfile) P.remove_all_hydrogens() # # Read mol2 file # L = Protool.ligand(P) for mol2file in mol2files: print "Added %s with tag 'LIGAND'" % mol2file L.readmol2(mol2file, tag='LIGAND') # # Get the pdb lines # pdblines = P.writepdb('junk.pdb', nowrite=True) # # Pass the lines to FFF # import FFF.FFFcontrol myFFF = FFF.FFFcontrol.FFF() myFFF.parse_lines(pdblines) #myFFF.soup_stat() Model = FFF.FFFcontrol.model_class(myFFF, Rotamerlib, FFFaadef_dir) # # Store the wild type PDB file # if store_mutation_operations: wt_lines = myFFF.make_pdblines('PDB') # import pKa.pKD_tools as pKD_tools total_bump = 0.0 for mutation in mutations: resid = pKD_tools.get_resid_from_mut(mutation) chainid = resid.split(':')[0] resid = resid.split(':')[1] # # Get rid of the leading zeros # done = False while not done: if resid[0] == '0' and len(resid) > 1: resid = resid[1:] else: done = True # newres = pKD_tools.get_newrestyp_from_mut(mutation) oldres = pKD_tools.get_oldrestyp_from_mut(mutation) opttype = 3 # Rotamer library energies = Model.Mutate(chainid, resid, newres, opttype, max_overlap) bump_score = energies[0] Sum = energies[1] Coulomb = energies[2] # total_bump = total_bump + bump_score print 'Bump score: %5.2f, total bump: %5.2f' % (bump_score, total_bump) if bump_score > max_overlap or total_bump > max_totalbump: print 'Cannot model this set of mutations - too many bumps' if return_score: return False, total_bump else: return False print 'Bump score for %s: %5.3f' % (mutation, bump_score) print 'Total bump score for all mutations: %5.3f' % (total_bump) class FFF_fix: def __init__(self, FFF): self.PI = FFF return # # Create the instance # FFF_instance = FFF_fix(myFFF) # # Keep track of the changes that were made to the PDB file # if store_mutation_operations: mut_lines = FFF_instance.PI.make_pdblines('PDB') import Protool WT = Protool.structureIO() WT.parsepdb(wt_lines) wt_atoms = sorted(WT.atoms.keys()) # MUT = Protool.structureIO() MUT.parsepdb(mut_lines) # mut_atoms = sorted(MUT.atoms.keys()) wt_count = 0 mutcount = 0 def coord_diff(atom1, atom2): diff = 0.0 for coord in ['X', 'Y', 'Z']: diff = diff + abs(atom1[coord] - atom2[coord]) return diff operations = [] for atom in wt_atoms: if not atom in mut_atoms: operations.append(['delete', atom, WT.atoms[atom]]) elif coord_diff(WT.atoms[atom], MUT.atoms[atom]) > 0.1: operations.append(['delete', atom, WT.atoms[atom]]) operations.append(['add', atom, MUT.atoms[atom]]) else: pass for atom in mut_atoms: if not atom in wt_atoms: operations.append(['add', atom, MUT.atoms[atom]]) # # Store these in FFF_fix # FFF_instance.mutate_operations = operations[:] # # Return the info # if (return_score): return FFF_instance, total_bump return FFF_instance
# Build hydrogens import Protool.hydrogens H=Protool.hydrogens.Hydrogens(P) H.build_all_HNs() # # Assign charges # import Protool.assign_parameters PQR=Protool.assign_parameters.assign_parameters(P) PQR.clear_all_charges_and_radii() PQR.set_all_radii() # # Try loading a ligand # import Protool.ligand L=Protool.ligand(P) L.readmol2('substrate_natural.mol2') # Charges are already set PQR.set_all_radii() tot=0.0 for residue in P.chains['L']: for atom in P.residues[residue]: tot=tot+P.atoms[atom]['CHARGE'] print 'Total charge on ligand before any modification; %5.1f' %tot BEFORE=APBS_calc(P,pdie=2.0) # # Now change the charge # charge_atom='L:0001:C1' P.atoms[charge_atom]['CHARGE']=1.0 AFTER=APBS_calc(P,pdie=2.0)
# Build hydrogens import Protool.hydrogens H = Protool.hydrogens.Hydrogens(P) H.build_all_HNs() # # Assign charges # import Protool.assign_parameters PQR = Protool.assign_parameters.assign_parameters(P) PQR.clear_all_charges_and_radii() PQR.set_all_radii() # # Try loading a ligand # import Protool.ligand L = Protool.ligand(P) L.readmol2('substrate_natural.mol2') # Charges are already set PQR.set_all_radii() tot = 0.0 for residue in P.chains['L']: for atom in P.residues[residue]: tot = tot + P.atoms[atom]['CHARGE'] print 'Total charge on ligand before any modification; %5.1f' % tot BEFORE = APBS_calc(P, pdie=2.0) # # Now change the charge # charge_atom = 'L:0001:C1' P.atoms[charge_atom]['CHARGE'] = 1.0 AFTER = APBS_calc(P, pdie=2.0)
def Model_Mutations(pdbfile,mol2files,mutations,max_overlap=0.5,max_totalbump=1.0,return_score=False,store_mutation_operations=False): """Model a number of mutations in a pdbfile when one or more ligands are present""" # # Check for stupidity # if max_overlap>max_totalbump: max_totalbump=max_overlap print 'Adjusted total bump cutoff to %5.2f' %max_totalbump # # Read PDB file # import Protool P=Protool.structureIO() P.readpdb(pdbfile) P.remove_all_hydrogens() # # Read mol2 file # L=Protool.ligand(P) for mol2file in mol2files: print "Added %s with tag 'LIGAND'" %mol2file L.readmol2(mol2file,tag='LIGAND') # # Get the pdb lines # pdblines=P.writepdb('junk.pdb',nowrite=True) # # Pass the lines to FFF # import FFF.FFFcontrol myFFF=FFF.FFFcontrol.FFF() myFFF.parse_lines(pdblines) #myFFF.soup_stat() Model=FFF.FFFcontrol.model_class(myFFF,Rotamerlib,FFFaadef_dir) # # Store the wild type PDB file # if store_mutation_operations: wt_lines=myFFF.make_pdblines('PDB') # import pKa.pKD_tools as pKD_tools total_bump=0.0 for mutation in mutations: resid=pKD_tools.get_resid_from_mut(mutation) chainid=resid.split(':')[0] resid=resid.split(':')[1] # # Get rid of the leading zeros # done=False while not done: if resid[0]=='0' and len(resid)>1: resid=resid[1:] else: done=True # newres=pKD_tools.get_newrestyp_from_mut(mutation) oldres=pKD_tools.get_oldrestyp_from_mut(mutation) opttype=3 # Rotamer library energies=Model.Mutate(chainid,resid,newres,opttype,max_overlap) bump_score=energies[0] Sum=energies[1] Coulomb=energies[2] # total_bump=total_bump+bump_score print 'Bump score: %5.2f, total bump: %5.2f' %(bump_score,total_bump) if bump_score>max_overlap or total_bump>max_totalbump: print 'Cannot model this set of mutations - too many bumps' if return_score: return False, total_bump else: return False print 'Bump score for %s: %5.3f' %(mutation,bump_score) print 'Total bump score for all mutations: %5.3f' %(total_bump) class FFF_fix: def __init__(self,FFF): self.PI=FFF return # # Create the instance # FFF_instance=FFF_fix(myFFF) # # Keep track of the changes that were made to the PDB file # if store_mutation_operations: mut_lines=FFF_instance.PI.make_pdblines('PDB') import Protool WT=Protool.structureIO() WT.parsepdb(wt_lines) wt_atoms=sorted(WT.atoms.keys()) # MUT=Protool.structureIO() MUT.parsepdb(mut_lines) # mut_atoms=sorted(MUT.atoms.keys()) wt_count=0 mutcount=0 def coord_diff(atom1,atom2): diff=0.0 for coord in ['X','Y','Z']: diff=diff+abs(atom1[coord]-atom2[coord]) return diff operations=[] for atom in wt_atoms: if not atom in mut_atoms: operations.append(['delete',atom,WT.atoms[atom]]) elif coord_diff(WT.atoms[atom],MUT.atoms[atom])>0.1: operations.append(['delete',atom,WT.atoms[atom]]) operations.append(['add',atom,MUT.atoms[atom]]) else: pass for atom in mut_atoms: if not atom in wt_atoms: operations.append(['add',atom,MUT.atoms[atom]]) # # Store these in FFF_fix # FFF_instance.mutate_operations=operations[:] # # Return the info # if (return_score): return FFF_instance,total_bump return FFF_instance