def Apply(self): from DockPrep import prep if self.addHydVar.get(): import AddH addHFunc = AddH.hbondAddHydrogens else: addHFunc = None kw = self.applyKeywords self.applyKeywords = {} rotamerLib = rotamerPreserve = None if self.incompleteVar.get(): incompleteVal = self.incompleteOpt.get() if type(incompleteVal) != str: rotamerLib = incompleteVal.importName rotamerPreserve = True incompleteVal = "rotamers" prefs[INCOMPLETE_SC] = incompleteVal else: incompleteVal = None prep(self.molListBox.getvalue(), addHFunc=addHFunc, addCharges=self.addChargesVar.get(), runSaveMol2Dialog=self.writeMol2Var.get(), mutateMSE=self.mutMseVar.get(), mutate5BU=self.mut5buVar.get(), mutateUMS=self.mutUmsVar.get(), mutateCSL=self.mutCslVar.get(), delSolvent=self.delSolventVar.get(), delIons=self.delIonsVar.get(), delAltLocs=self.delAltLocsVar.get(), incompleteSideChains=incompleteVal, rotamerLib=rotamerLib, rotamerPreserve=rotamerPreserve, **kw)
def main(): print sys.argv if len(sys.argv) != 3: # if no input print "ERROR: Wrong number of inputs" print "syntax: chimera --nogui --script \"chimera_dockprep.py pdbinput output_prefix\"" print len(sys.argv) return #models = openModels.list(modelTypes=[chimera.Molecule]) input_pdb = sys.argv[1] output_prefix = sys.argv[2] print "pdb input = " + input_pdb print "output prefix = " + output_prefix #runCommand("open " + input_pdb) #models = chimera.openModels.list(modelTypes=[chimera.Molecule]) #model = models model = openModels.open(input_pdb) #runCommand("del @H,H?,H??,H???") # remove all hydrogens writeMol2(model, output_prefix + "before_dockprep.mol2") prep(model) runCommand("write 0 " + output_prefix + ".pdb") writeMol2(model, output_prefix + ".mol2") runCommand("del HC") # remove all non-polar hydrogens runCommand("write 0 " + output_prefix + "_polarH.pdb") runCommand("del @H,H?,H??,H???") # remove all hydrogens runCommand("write 0 " + output_prefix + "_noH.pdb")
def runDockPrep(): models = chimera.openModels.list(modelTypes=[chimera.Molecule]) prep(models) #prep(models, hisScheme=None, mutateMSE=True, mutate5BU=True, mutateUMS=True, # mutateUMS=True, mutateCSL=True, delSolvent=True, delIons=False, # delLigands=False, delAltLocs=True, incompleteSideChains='rotamers', # nongui=False, rotamerLib='Dunbrack', rotamerPreserve=True, # memorize=False, memorizeName=None) return
def main(): print sys.argv if len(sys.argv) != 3 and len(sys.argv) != 4: # if no input print "ERROR: Wrong number of inputs" print "syntax: chimera --nogui --script \"chimera_dockprep.py pdbinput output_prefix keepH\"" print len(sys.argv) return #models = openModels.list(modelTypes=[chimera.Molecule]) input_pdb = sys.argv[1] output_prefix = sys.argv[2] if len(sys.argv) == 4: if (sys.argv[3] == 'yes'): keepH = True elif (sys.argv[3] == 'no'): keepH = False else: print("keepH must be yes or no, setting it to no.") keepH = False else: keepH = False print "pdb input = " + input_pdb print "output prefix = " + output_prefix #runCommand("open " + input_pdb) #models = chimera.openModels.list(modelTypes=[chimera.Molecule]) #model = models model = openModels.open(input_pdb) if not (keepH): runCommand("del @H,H?,H??,H???") # remove all hydrogens writeMol2(model, output_prefix+"before_dockprep.mol2") prep(model) runCommand("write 0 "+output_prefix+".pdb") writeMol2(model, output_prefix+".mol2") runCommand("del HC") # remove all non-polar hydrogens runCommand("write 0 "+output_prefix+"_polarH.pdb") runCommand("del @H,H?,H??,H???") # remove all hydrogens runCommand("write 0 "+output_prefix+"_noH.pdb")
def add_hydrogens_prep(): """ Performs DockPrep on the currently-loaded protein in Chimera Arguments: None Requires: A protein must be opened in Chimera ( e.g. 'runCommand("open " + file_name))' must have already run It is also recommended that the loaded protein has already been cleaned with clean_protein() If surface computation is run after this function, the surface computation may fail due to the added hydrogens Returns: Void Effect: Modifies the structure in the following ways: 1. Adds hydrogens 2. Mutates non-standard AAs to standard AAs 3. Modifies incomplete side chains 4. Deletes solven molecules """ # Add hydrogen atoms/charges, mutate MSE and other non-standard # AAs to standard, and perform other basic DockPrep operations. models = chimera.openModels.list(modelTypes=[chimera.Molecule]) # try: prep( models, addHFunc=AddH.hbondAddHydrogens, hisScheme=None, mutateMSE=True, mutate5BU=True, mutateUMS=True, mutateCSL=True, delSolvent=True, delIons=False, delLigands=False, delAltLocs=True, incompleteSideChains="rotamers", nogui=True, rotamerLib=defaults[INCOMPLETE_SC], rotamerPreserve=True, memorize=False, memorizeName=None, )
resname_states_dict["GLU"] = ["GLU", "GLH1", "GLH2"] resname_states_dict["ASP"] = ["ASP", "ASH1", "ASH2"] rc("open %s" % args.RECEPTOR) # load the receptor rc("open %s" % args.LIGAND) # load the ligand if args.DOCKPREP: import chimera from Addions import initiateAddions from DockPrep import prep from AddCharge import estimateFormalCharge models = chimera.openModels.list(modelTypes=[chimera.Molecule]) print( "Preparing receptor for docking and calculating ligand AM1 charges (may be slow)." ) prep(models, nogui=True, method='am1') # Select the residues to be protonated if args.RADIUS > 0: rc("sel #1 z<%f & ~ #1" % args.RADIUS) elif args.RADIUS == 0: rc("sel #0") residues = currentResidues() # get the residue of the pocket residue_states = {} protonatable_resids = [] protonatable_resnames = [] for r in residues: if r.type in ["GLU", "GLH"]: states = resname_states_dict["GLU"] protonatable_resids.append(str(r.id)) protonatable_resnames.append(r.type)
#chdir("receptors") # change to the receptors file directory for pdb in listdir("."): if pdb.endswith("_aligned.pdb"): continue if pdb.endswith("_noH.pdb"): continue if not pdb.endswith("_mod2.pdb"): #originally was .pdb before pdb2pqr.py continue #if pdb == "1gzm.pdb": # don't need to do the pdb used for align # continue runCommand("open " + pdb) runCommand("open 1gzm.pdb") runCommand("mmaker #1 #0") runCommand("write relative #1 #0 " + pdb[:-4] + "_aligned.pdb") runCommand("close all") pdb = pdb[:-4] + "_aligned.pdb" runCommand("open " + pdb) from DockPrep import prep models = chimera.openModels.list(modelTypes=[chimera.Molecule]) prep(models) from WriteMol2 import writeMol2 writeMol2(models, pdb[:-4]+ "_charged.mol2") runCommand("select H") runCommand("del sel") runCommand("write format pdb 0 " + pdb[:-4] + "_noH.pdb") runCommand("close all")
import chimera from DockPrep import prep models = chimera.openModels.list(modelTypes=[chimera.Molecule]) prep(models) from WriteMol2 import writeMol2 writeMol2(models, "dp.mol2")
def makeAllMeshes(proID, jobID, peptideLen=40, pocketDist=5.0): global curResID global curProID global meshDir global pocketMap global resCount global curJobID #Insure input is a 4 character protein ID proID = proID[0:4] #Create a new directory for the protein meshDir = proID + 'Mesh' curProID = proID curJobID = jobID # os.mkdir(meshDir) # os.system("chmod 777 " + meshDir) try: #Fetch protein from the PDB runCommand('open ' + proID) #Initial prep for pocket search runCommand('delete solvent') runCommand('delete :HOH') #Open protein model model = openModels.list(modelTypes=[Molecule])[0] RES_LIST = model.residues resCount = len(RES_LIST) #Pocket finding procedure chains = [] counts = [] index = 0 print 'Counting Chain Lengths................' for res in RES_LIST: curChain = str(res.id.chainId) if len(chains) == 0: chains.append(curChain) counts.append(1) if curChain != chains[index]: index = index + 1 chains.append(curChain) counts.append(1) else: counts[index] = counts[index] + 1 print 'Finding Peptide Ligand Pockets................' for i, chain in enumerate(chains): if counts[i] < peptideLen: #Less than X amino acids = peptide runCommand('~select') runCommand('select ligand & :.' + chain) #Check if actually ligand runCommand('select selected zr<' + str(pocketDist)) #Select pocket runCommand('~select :/isHet zr<' + str(pocketDist)) #De-select ligand runCommand('~select ligand') residues = selection.currentResidues() #Store pocket in memory for res in residues: if res in pocketMap: pocketMap[res].append('|' + chain) else: pocketMap[res] = [chain] print 'Finding non-Peptide Ligand Pockets................' for res in RES_LIST: if res.isHet: #Check if "heterogenous residue" which includes ligands curResID = str(res.id) runCommand('~select') runCommand('select :' + curResID + ' & ligand') #Check if actually ligand runCommand('select selected zr<' + str(pocketDist)) #Select pocket runCommand('~select :' + curResID) residues = selection.currentResidues() #Store pocket in memory for pocketRes in residues: if pocketRes in pocketMap: pocketMap[pocketRes].append('|' + res.type + '-' + curResID) else: pocketMap[pocketRes] = [res.type + '-' + curResID] print 'Dock Prep................' prep(openModels.list(modelTypes=[Molecule])) runCommand('delete ligand') print '\nRunning Delphi................' runCommand('~select') runCommand('write format pdb 0 ' + proID + curJobID + '.pdb') #Write delphi-ready protein with hydrogens #Create delphi parameter file f = open('./param_' + curJobID, 'w') f.write('in(pdb,file="' + proID + curJobID + '.pdb")\n') #Input/Output files f.write('in(siz,file="amber.siz")\n') f.write('in(crg,file="amber.crg")\n') f.write('out(phi,file="' + proID + curJobID + '.phi")\n') f.write('indi=2\n') #Interior dielectric constant f.write('exdi=80.0\n') #Exterior dielectric constant (water) f.write('prbrad=1.4\n') f.write('salt=0.15\n') #Salt concentration and radius f.write('ionrad=2.0\n') # f.write('nonit=20\n') #Non-linear iterations f.close() os.system("./DELPHI_2004_LINUX_v2/delphi_static param_" + curJobID) #Run delphi # print '\nExporting Mesh................' runCommand('select #0') runCommand('surface') #runCommand('export format X3D ./' + proID + '.x3d') # Prints raw X3D file. print '\nOpening Delphi Data................' runCommand('open ' + proID + curJobID + '.phi') runCommand('scolor #0 volume #1 cmap -1,red:0,white:1,blue;') print '\nRemoving Temp Files................' os.remove("./" + proID + curJobID + '.pdb') os.remove("./" + proID + curJobID + '.phi') os.remove('./param_' + curJobID) print '\nDONE: ' + proID except: f = open("./" + 'ErrorLog' + curJobID + '.txt', 'w') f.write(proID + ' error: ' + str(sys.exc_info()[0]) + str(sys.exc_info()[1]) + '\n') f.close() raise return
def makeAllMeshes(proID, jobID, peptideLen=40, pocketDist=5.0): global curResID global curProID global meshDir global pocketMap global resCount global curJobID #Insure input is a 4 character protein ID proID = proID[0:4] #Create a new directory for the protein meshDir = proID + 'Mesh' curProID = proID curJobID = jobID # os.mkdir(meshDir) # os.system("chmod 777 " + meshDir) try: #Fetch protein from the PDB runCommand('open '+ proID) #Initial prep for pocket search runCommand('delete solvent') runCommand('delete :HOH') #Open protein model model = openModels.list(modelTypes=[Molecule])[0] RES_LIST = model.residues resCount = len(RES_LIST) #Pocket finding procedure chains = [] counts = [] index = 0 print 'Counting Chain Lengths................' for res in RES_LIST: curChain = str(res.id.chainId) if len(chains) == 0: chains.append(curChain) counts.append(1) if curChain != chains[index]: index = index + 1 chains.append(curChain) counts.append(1) else: counts[index] = counts[index] + 1 print 'Finding Peptide Ligand Pockets................' for i, chain in enumerate(chains): if counts[i] < peptideLen: #Less than X amino acids = peptide runCommand('~select') runCommand('select ligand & :.' + chain) #Check if actually ligand runCommand('select selected zr<' + str(pocketDist)) #Select pocket runCommand('~select :/isHet zr<' + str(pocketDist)) #De-select ligand runCommand('~select ligand') residues = selection.currentResidues() #Store pocket in memory for res in residues: if res in pocketMap: pocketMap[res].append('|' + chain) else: pocketMap[res] = [chain] print 'Finding non-Peptide Ligand Pockets................' for res in RES_LIST: if res.isHet: #Check if "heterogenous residue" which includes ligands curResID = str(res.id) runCommand('~select') runCommand('select :' + curResID + ' & ligand') #Check if actually ligand runCommand('select selected zr<' + str(pocketDist)) #Select pocket runCommand('~select :' + curResID) residues = selection.currentResidues() #Store pocket in memory for pocketRes in residues: if pocketRes in pocketMap: pocketMap[pocketRes].append('|' + res.type + '-' + curResID) else: pocketMap[pocketRes] = [res.type + '-' + curResID] print 'Dock Prep................' prep(openModels.list(modelTypes=[Molecule])) runCommand('delete ligand') print '\nRunning Delphi................' runCommand('~select') runCommand('write format pdb 0 '+ proID + curJobID + '.pdb') #Write delphi-ready protein with hydrogens #Create delphi parameter file f = open('./param_' + curJobID, 'w') f.write('in(pdb,file="'+ proID + curJobID + '.pdb")\n') #Input/Output files f.write('in(siz,file="amber.siz")\n') f.write('in(crg,file="amber.crg")\n') f.write('out(phi,file="'+ proID + curJobID + '.phi")\n') f.write('indi=2\n') #Interior dielectric constant f.write('exdi=80.0\n') #Exterior dielectric constant (water) f.write('prbrad=1.4\n') f.write('salt=0.15\n') #Salt concentration and radius f.write('ionrad=2.0\n') # f.write('nonit=20\n') #Non-linear iterations f.close() os.system("./DELPHI_2004_LINUX_v2/delphi_static param_" + curJobID) #Run delphi # print '\nExporting Mesh................' runCommand('select #0') runCommand('surface') #runCommand('export format X3D ./' + proID + '.x3d') # Prints raw X3D file. print '\nOpening Delphi Data................' runCommand('open '+ proID + curJobID + '.phi') runCommand('scolor #0 volume #1 cmap -1,red:0,white:1,blue;') print '\nRemoving Temp Files................' os.remove("./" + proID + curJobID + '.pdb') os.remove("./" + proID + curJobID + '.phi') os.remove('./param_' + curJobID) print '\nDONE: ' + proID except: f = open("./" + 'ErrorLog' + curJobID + '.txt', 'w') f.write(proID + ' error: ' + str(sys.exc_info()[0]) + str(sys.exc_info()[1]) + '\n') f.close() raise
import chimera import sys import re from DockPrep import prep from DockPrep import AddH from WriteMol2 import writeMol2 # ref: http://mailman.docking.org/pipermail/dock-fans/2007-May/001043.html models = chimera.openModels.list(modelTypes=[chimera.Molecule]) prep(models, addHFunc=AddH.hbondAddHydrogens) root = models[0].name.replace(".pdb", "") if len(sys.argv) == 2: d = re.sub("/$", "", sys.argv[1]) + "/" else: d = "" writeMol2(models, d + root + "_prepped.mol2") # ref: http://plato.cgl.ucsf.edu/pipermail/chimera-users/2011-March/006134.html chimera.runCommand("surf") surf = chimera.openModels.list(modelTypes=[chimera.MSMSModel])[0] from WriteDMS import writeDMS writeDMS(surf, d + root + ".dms")
rc("sel #0.2") # select the ligand ligres = currentResidues()[0] ligres.type = 'LIG' # change the resname of the ligand to 'LIG' rc("combine #0.1 modelId 1" ) # create a new molecule containing just the receptor rc("combine #0.2 modelId 2" ) # create a new molecule containing just the ligand rc("del #0") if args.REC_NET_CHARGE != None: rec_charge = args.REC_NET_CHARGE else: # We will estimate the receptor's net charge. For this we need to DockPrep the receptor (is fast). models = chimera.openModels.list(modelTypes=[chimera.Molecule]) # For a full list of DockPrep options, look into file Chimera-alpha_py2.7/share/DockPrep/__init__.py prep([models[0]], nogui=True, method=args.CHARGE_METHOD, addHFunc=addHFunc) rec_charge = estimateFormalCharge( models[0].atoms ) # DockPred does not assign charges to receptor atoms, only to ligand atoms print("Receptor's net charge =", rec_charge) # Now that we calculated the charges of the protein and the ligand, we just need the complex rc("combine #1,2 modelId 3" ) # create a new molecule containing the protein-ligand complex rc("del #1-2") pdb = args.COMPLEX.replace(".pdb", "_prep.pdb") elif args.RECEPTOR and args.LIGAND: rc("open %s" % args.RECEPTOR) # load the receptor if args.REC_NET_CHARGE == None: standardize_terminal_protein_residues( args.RECEPTOR, "#0"
import chimera from DockPrep import prep import Midas import sys import os PDB_file = sys.argv[1] lig_name = sys.argv[2] num = sys.argv[3] ligand = chimera.openModels.open("%s_%s_CH%s.pdb" % (PDB_file, lig_name, num)) prep(ligand, addCharges=False) #prep(ligand,addCharges=True) Midas.write(ligand, None, PDB_file + "_" + lig_name + "_ADDH_CH" + num + ".pdb") print("success!")
ligres = currentResidues()[0] ligres.type = 'LIG' # change the resname of the ligand to 'LIG' rc("combine #0,1 modelId 2" ) # create a new molecule containing the protein-ligand complex rc("combine #2 modelId 3" ) # create a new molecule containing the protein-ligand complex rc("del #0-2") pdb = os.path.splitext(os.path.basename( args.RECEPTOR))[0] + "_" + os.path.splitext( os.path.basename(args.LIGAND))[0] + "_prep.pdb" print( "Preparing receptor for docking and calculating ligand '%s' charges (may be slow)." % args.CHARGE_METHOD) models = chimera.openModels.list(modelTypes=[chimera.Molecule]) prep(models, nogui=True, method=args.CHARGE_METHOD) net_charge = estimateFormalCharge(models[0].atoms) # Neutralize system if args.NEUTRALIZE: if net_charge < 0: initiateAddions(models, "Na+", "neutralize", chimera.replyobj.status) elif net_charge > 0: initiateAddions(models, "Cl-", "neutralize", chimera.replyobj.status) if net_charge != 0: # change the resids of the ions, which by default they are all 1 rc("sel ~ions") existing_resids = [ int(str(r.id).split('.')[0]) for r in currentResidues() ]
## PDB_FILE SHOULD THE COMPLETE PATH OF THE FILE ## REPLACE BNZ with LIGAND resname ## USAGE: Chimera --nogui --script "prep_prot_lig.py 4w52.pdb BNZ" import chimera from DockPrep import prep import Midas import sys import os PDB_file = sys.argv[1] lig_name = sys.argv[2] os.system('grep ATOM %s > %s_clean.pdb'%(PDB_file,PDB_file[:-4])) os.system('grep %s %s > %s.pdb'%(lig_name,PDB_file,lig_name)) protein=chimera.openModels.open('%s_clean.pdb'%PDB_file[:-4]) ligand=chimera.openModels.open('%s.pdb'%lig_name) prep(protein,addHFunc=None,addCharges=False) prep(ligand) Midas.write(protein,None,"protein_clean.pdb") Midas.write(ligand,None,"ligand_wH.pdb")