def test_circuitWithGenes(self): circuit = makeFullTestCircuit() self.assertEqual(circuit.printAllPartsWithGeneNames()['TOP'], ['P', 'i', 'T']) self.assertEqual(circuit.printAllPartsWithGeneNames()['BOTTOM'], ['t', 'P', 'G.3.1', 'i', 't']) circuit1 = enz.induceCircuit(enzyme1, circuit) self.assertEqual(circuit1.printAllPartsWithGeneNames()['TOP'], ['P', 't', 'P', 'G.3.1', 'i']) self.assertEqual(circuit1.printAllPartsWithGeneNames()['BOTTOM'], ['i', 'T', 't']) circuit2 = enz.induceCircuit(enzyme2, circuit1) self.assertEqual(circuit2.printAllPartsWithGeneNames()['TOP'], ['P', 'T', 'G.3.1', 'i']) self.assertEqual(circuit2.printAllPartsWithGeneNames()['BOTTOM'], ['i', 't', 'P', 't']) circuit3 = enz.induceCircuit(enzyme2, circuit) self.assertEqual(circuit3.printAllPartsWithGeneNames()['TOP'], ['P', 'i']) self.assertEqual(circuit3.printAllPartsWithGeneNames()['BOTTOM'], ['G.3.1', 'i', 't']) circuit4 = enz.induceCircuit(enzyme1, circuit3) self.assertEqual(circuit4.printAllPartsWithGeneNames()['TOP'], ['P', 'G.3.1', 'i']) self.assertEqual(circuit4.printAllPartsWithGeneNames()['BOTTOM'], ['i', 't'])
def __init__(self): self.design = Enzyme() self.native = Molecule() useRosettaRadii() #cmd.set("seq_view", 1) #cmd.set("seq_view_label_mode", 3) self.nativeFile = "" self.designFile = "" self.rosetta = rosetta_engine() self.rosetta.setMolecule(self.design)
def test_circuit_path2(self): circuit2 = makeCircuit3State() ##The original circuit self.assertEqual(circuit2.printCircuit(), [1,'D',2,'[',3,'(',4,'-[',5,'(',6,'-D',7]) ##Circuit when exposed to Ara circuitC = enz.induceCircuit(enzyme1, circuit2) self.assertEqual(circuitC.printCircuit(), [1,'D',-6,'-(',-5,'[',3,'(',4,'-[',-2,'-D',7]) ##Circuit when exposed to ATc after Ara circuitD = enz.induceCircuit(enzyme2, circuitC) self.assertEqual(circuitD.printCircuit(), [1,'D',-6,'-(',-3,'-[',5,'(',4,'-[',-2,'-D',7])
def test_circuit_path1(self): circuit1 = makeCircuit3State() ##The original circuit self.assertEqual(circuit1.printCircuit(), [1,'D',2,'[',3,'(',4,'-[',5,'(',6,'-D',7]) ##Circuit when exposed to ATc circuitA = enz.induceCircuit(enzyme2, circuit1) self.assertEqual(circuitA.printCircuit(), [1,'D',2,'[',3,'(',6,'-D',7]) ##Curcuit when exposed to Ara after ATc circuitB = enz.induceCircuit(enzyme1, circuitA) self.assertEqual(circuitB.printCircuit(), [1,'D',-6,'-(',-3,'-[',-2,'-D',7])
def test_circuitWith3Genes(self): circuit = make3GeneTestCircuit() self.assertEqual(circuit.printOnlyExpressed(), ['G.5.1', 'G.7.1']) circuit1 = enz.induceCircuit(enzyme1, circuit) self.assertEqual(circuit1.printOnlyExpressed(), ['G.7.1']) circuit2 = enz.induceCircuit(enzyme2, circuit1) self.assertEqual(circuit2.printOnlyExpressed(), ['G.7.1', 'G.1.1']) circuit3 = enz.induceCircuit(enzyme2, circuit) self.assertEqual(circuit3.printOnlyExpressed(), ['G.5.1']) circuit4 = enz.induceCircuit(enzyme1, circuit3) self.assertEqual(circuit4.printOnlyExpressed(), ['G.5.1', 'G.1.1'])
def test_simpleCircuit(self): ##Create the circuit circuit = makeSimpleCicuit() self.assertEqual(circuit.printCircuit(), [1,'D',2,'-D',3]) newCircuit = enz.induceCircuit(enzyme1,circuit) self.assertEqual(newCircuit.printCircuit(), [1,'D',-2,'-D',3])
def main(): """ reads a rosetta output pdbfile and reports residues that have a total Eres > cutoff """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-o", dest="outfile", help="outfile") parser.add_option("-O", dest="outlist", help="outlist") parser.add_option("-r", dest="replace", help="replace", action="store_true") parser.add_option("-t", dest="type", help="atom type", default="CS1 ") parser.add_option("-T", dest="type2", help="atom type", default="CS2 ") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() outfiles = [] if options.outlist: outfiles = files_from_list(options.outlist) elif options.outfile: outfiles.append(options.outfile) elif options.replace: for file in pdbfiles: outfiles.append(file) else: parser.print_help() sys.exit() if len(pdbfiles) != len(outfiles): print "number of pdbfiles and output files differ" sys.exit() mymol = Enzyme() for i in range(len(pdbfiles)): pdbfile = pdbfiles[i] outfile = outfiles[i] mymol.readPDB(pdbfile) lig = mymol.ligand lig.removeAtomsContaining(options.type) lig.removeAtomsContaining(options.type2) mymol.writePDB(outfile) mymol.clear()
def main(): """ removes the ligand """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-o", dest="outfile", help="outfile") parser.add_option("-O", dest="outlist", help="outlist") parser.add_option("-r", dest="replace", help="replace", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() outfiles = [] if options.outlist: outfiles = files_from_list(options.outlist) elif options.outfile: outfiles.append(options.outfile) elif options.replace: for file in pdbfiles: outfiles.append(file) else: parser.print_help() sys.exit() enz = Enzyme() for i in range(len(pdbfiles)): enz.readPDB(pdbfiles[i]) for j in range(1, len(enz.chain)): enz.chain[j] = 0 enz.chain.remove(0) enz.writePDB(outfiles[i]) enz.clear()
def main(): """ prints the list of catalytic residues in the enzme. (name and position) """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.set_description(main.__doc__) (options,args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) seq = "" pos = "" for cat in protein.catalytic: seq += cat.name + "-" for cat in protein.catalytic: pos += cat.file_id + " " print pdbfile,seq,pos protein.clear()
def test_3StateCircuit(self): circuit = makeCircuit3State() self.assertEqual( circuit.printCircuit(), [5, 'D', 5, '[', 1, '(', -7, '-[', 5, '(', -10, '-D', -10]) self.assertEqual(circuit.printAllParts()['TOP'], ['G', 'i']) self.assertEqual(circuit.printAllParts()['BOTTOM'], ['P', 'P', 'T', 'i']) ##Induce the circuit with enzyme1 and validate circuit1 = enz.induceCircuit(enzyme1, circuit) self.assertEqual( circuit1.printCircuit(), [5, 'D', 10, '-(', -5, '[', 1, '(', -7, '-[', -5, '-D', -10]) self.assertEqual(circuit1.printAllParts()['TOP'], ['P', 'G', 'i']) self.assertEqual(circuit1.printAllParts()['BOTTOM'], ['P', 'T', 'i']) ##Induce the circuit with enzyme2 and validate circuit2 = enz.induceCircuit(enzyme2, circuit1) self.assertEqual( circuit2.printCircuit(), [5, 'D', 10, '-(', -1, '-[', 5, '(', -7, '-[', -5, '-D', -10]) self.assertEqual(circuit2.printAllParts()['TOP'], ['P', 'i']) self.assertEqual(circuit2.printAllParts()['BOTTOM'], ['P', 'T', 'G', 'i']) ##Induce the circuit with enzyme2 and validate that it is correct circuit3 = enz.induceCircuit(enzyme2, circuit) self.assertEqual(circuit3.printCircuit(), [5, 'D', 5, '[', 1, '(', -10, '-D', -10]) self.assertEqual(circuit3.printAllParts()['TOP'], ['G', 'i']) self.assertEqual(circuit3.printAllParts()['BOTTOM'], ['P', 'P', 'i']) ##Inducde the circuit with enzyme1 and validate it circuit4 = enz.induceCircuit(enzyme1, circuit3) self.assertEqual(circuit4.printCircuit(), [5, 'D', 10, '-(', -1, '-[', -5, '-D', -10]) self.assertEqual(circuit4.printAllParts()['TOP'], ['P', 'i']) self.assertEqual(circuit4.printAllParts()['BOTTOM'], ['P', 'G', 'i'])
def main(): """ reports the ligand score (Eatr + Erep + EhbSC) """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() protein = Enzyme() for file in pdbfiles: protein.readPDB(file) lig = protein.ligand if lig == None: print "no ligand found for file:", file sys.exit() tot = lig.Erep + lig.Eatr + lig.EhbSC print file, lig.Erep, lig.Eatr, lig.EhbSC, tot protein.clear()
def main(): """ performs a simple clash check (hard spheres) """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-s", dest="scale", help="scale (0.60)", default=0.60) parser.add_option("-S", dest="sele", help="selection") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdbfile: pdbfiles.append(options.pdbfile) elif options.pdblist: pdbfiles = files_from_list(options.pdblist) else: parser.print_help() sys.exit() myscale = float(options.scale) mymol = Enzyme() sele = None if options.sele: sele = Selection() sele.makeSelection(options.sele) for pdbfile in pdbfiles: mymol.readPDB(pdbfile) if options.sele: reslist = sele.apply_selection(mymol).residueList() else: reslist = mymol.residueList() nres = len(reslist) bFail = False for i in range(nres): for j in range(i + 1, nres): if (bResidue_Residue_clash_check(reslist[i], reslist[j], myscale)): print pdbfile, reslist[i].file_id, reslist[ j].file_id, "FAIL" bFail = True break if bFail: break mymol.clear()
def test_simpleCircuit(self): ##Create the circuit circuit = makeSimpleCircuit() self.assertEqual(circuit.printCircuit(), [1, 'D', 2, '-D', 3]) ##Check the the expression profile is as expected self.assertEqual(circuit.printAllParts()['TOP'], ['G', 'i', 'G', 'P', 't', 'P']) self.assertEqual(circuit.printAllParts()['BOTTOM'], ['T', 'i', 'i']) self.assertEqual(circuit.printOnlyExpressed(), []) circuit1 = enz.induceCircuit(enzyme1, circuit) self.assertEqual(circuit1.printAllParts()['TOP'], ['G', 'i', 'i', 't', 'P']) self.assertEqual(circuit1.printAllParts()['BOTTOM'], ['T', 'G', 'P', 'i'])
def main(): """ reports the distance between two selected atoms in a pdbfile """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("--s1", dest="selection1", help="selection1") parser.add_option("--s2", dest="selection2", help="selection2") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() if not options.selection1 or not options.selection2: parser.print_help() sys.exit() sele1 = Selection() sele2 = Selection() sele1.makeSelection(options.selection1) sele2.makeSelection(options.selection2) protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) mol1 = sele1.apply_selection(protein) mol2 = sele2.apply_selection(protein) alist1 = mol1.atomList() alist2 = mol2.atomList() if len(alist1) != 1: print "selection 1 does not specify 1 atom" print alist1 sys.exit() if len(alist2) != 1: print "selection 2 does not specify 1 atom" sys.exit() atm1 = alist1[0] atm2 = alist2[0] dist = atm1.distance(atm2) print pdbfile, ":", atm1.name, "->", atm2.name, ":", dist protein.clear()
def main(): """ reports the hydrogen bonds made to catalytic residues in an enzyme """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-c", dest="catalytic", help="catalytic") parser.add_option("-x", dest="cutoff", help="cutoff", default=-0.3) parser.add_option("-m", dest="mabo", help="mabo", action="store_true") parser.add_option("-n", dest="count", help="report counts", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() if not options.catalytic: parser.print_help() sys.exit() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() enz = Enzyme() icat = int(options.catalytic) HBN = HBnetwork() for pdbfile in pdbfiles: enz.readPDB(pdbfile) cres = enz.catalytic[icat - 1] if cres == None: print "cannot find catalytic residue" sys.exit() HBN.createNetwork(enz) HBN.findHbonds(float(options.cutoff)) hlist = HBN.getHbondsToResidue(cres) if options.count: print pdbfile, len(hlist) else: for hb in hlist: print pdbfile, hb HBN.clear() enz.clear()
def main(): """ reports the scores for a catalytic residue format: Erep,Eatr,Esol,EhbBB,EhbSC """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-c", dest="catalytic", help="catalytic residue") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() if not options.catalytic: parser.print_help() sys.exit() cres = int(options.catalytic) cres -= 1 protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) if cres > len(protein.catalytic): print "accessing catalytic residue out of bounds" sys.exit() catres = protein.catalytic[cres] print pdbfile, catres.name, catres.Erep, catres.Eatr, catres.Esol, catres.EhbBB, catres.EhbSC protein.clear()
def build5StateCircuit(parts): ##Create the recombination sites site1 = rs.RecognitionSite('D', 1) site2 = rs.RecognitionSite('[', 1) site3 = rs.RecognitionSite('(', 1) site4 = rs.RecognitionSite('[', -1) site5 = rs.RecognitionSite('(', 1) site6 = rs.RecognitionSite('D', -1) sites = [site1, site2, site3, site4, site5, site6] ##Instantiate the circuit circuit = gc.GeneticCircuit([]) numberOfParts = len(parts) for pI in range(numberOfParts): ##p is a number if parts[pI] < 0: circuit.addComponent(part.Part(abs(parts[pI]), -1)) else: circuit.addComponent(part.Part(parts[pI], 1)) ##Add the site as long as its not the last part if (pI + 1 < numberOfParts): circuit.addComponent(sites[pI]) ##Want to return all the induced circuits as well enzyme1 = enz.Enzyme('ATc') enzyme1.addSiteToRecognize('(') enzyme2 = enz.Enzyme('Ara') enzyme2.addSiteToRecognize('[') enzyme2.addSiteToRecognize('D') c1 = circuit c2 = enz.induceCircuit(enzyme1, c1) c3 = enz.induceCircuit(enzyme2, c1) c4 = enz.induceCircuit(enzyme2, c2) c5 = enz.induceCircuit(enzyme1, c3) return [c1, c2, c3, c4, c5]
def main(): """ checks the shape complementarity of the ligand in an enzyme """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() protein = Enzyme() sele = Selection() sele.makeSelection("element=C,N,O,S") tmp_pdbfile = "_tmpscpdb.pdb" input_file = "_sc_input" output_file = "_sc_output" try: SC_INPUT = open(input_file, 'w') except: print "unable to create temporary SC_INPUT" sys.exit() SC_INPUT.write("molecule 1\n") SC_INPUT.write("chain A\n") SC_INPUT.write("molecule 2\n") SC_INPUT.write("chain B\n") SC_INPUT.write("END\n") SC_INPUT.close() for pdbfile in pdbfiles: protein.readPDB(pdbfile) if protein.numChains() != 2: print pdbfile + ": not enough chains", protein.numChains() protein.clear() continue protein.chain[0].name = "A" protein.chain[1].name = "B" newprot = sele.apply_selection(protein) newprot.writePDB(tmp_pdbfile) protein.clear() newprot.clear() commands.getoutput("sc XYZIN " + tmp_pdbfile + " SCRADII rosetta_radii.lib < " + input_file + " > " + output_file) ans = commands.getoutput("grep 'Shape complementarity statistic Sc' " + output_file) cols = ans.split() if len(cols) < 5: continue medSC = float(cols[5]) ans = commands.getoutput("grep 'molecule 2 after trim' " + output_file) cols = ans.split() if len(cols) < 11: continue ndots1 = float(cols[10]) print pdbfile, medSC, ndots1, medSC * ndots1 commands.getoutput("rm -f " + output_file) commands.getoutput("rm -f " + tmp_pdbfile) commands.getoutput("rm -f " + input_file)
def main(): """ creates a new pdbfile from a given selection (almost pymol-like selection format) """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-o", dest="outfile", help="outfile") parser.add_option("-O", dest="outlist", help="outlist") parser.add_option("-s", dest="selection", help="selection") parser.add_option("-r", dest="replace", help="replace", action="store_true") parser.add_option("-i", dest="inverse", help="inverse", action="store_true") parser.add_option("-n", dest="renumber", help="don't renumber residues", action="store_true") parser.add_option("-c", dest="count", help="report atom count only", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] outfiles = [] if not options.selection: parser.print_help() sys.exit() if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() bFileOutput = True if options.outlist: outfiles = files_from_list(options.outlist) elif options.outfile: outfiles.append(options.outfile) elif options.replace: for file in pdbfiles: outfiles.append(file) else: bFileOutput = False selection = Selection() selection.makeSelection(options.selection) protein = Enzyme() resRenumber = True if options.renumber: resRenumber = False for i in range(len(pdbfiles)): protein.readPDB(pdbfiles[i]) newmol = selection.apply_selection(protein) if options.count: print newmol.numAtoms() elif bFileOutput: newmol.writePDB(outfiles[i], resRenumber) else: for atm in newmol.atomList(): print atm protein.clear() newmol.clear()
def main(): """ program that checks to see if histidine binding to ligand is in the right place if not it switches the tautomer by default the proton is expected to be pointing AWAY from the ligand. this behaviour is changed with the -inverse option """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-o", dest="outfile", help="outfile") parser.add_option("-O", dest="outlist", help="outlist") parser.add_option("-r", dest="replace", help="replace", action="store_true") parser.add_option("-i", dest="inverse", help="inverse", action="store_true") parser.add_option("-v", dest="virtual", help="virtual", action="store_true") parser.add_option("-c", dest="catalytic", help="catalytic") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() outfiles = [] if options.outlist: outfiles = files_from_list(options.outlist) elif options.outfile: outfiles.append(options.outfile) elif options.replace: for file in pdbfiles: outfiles.append(file) else: parser.print_help() sys.exit() if len(outfiles) != len(pdbfiles): print "differing number of files" sys.exit() mycat = None for i in range(len(pdbfiles)): #protein = Molecule() protein = Enzyme() protein.readPDB(pdbfiles[i]) if options.catalytic: icat = int(options.catalytic) - 1 if icat < 0 or icat >= len(protein.catalytic): print "accessing catalytic out of bounds" sys.exit() mycat = protein.catalytic[icat] chainB = extractCatResidues(protein) if len(chainB) == 0: print "NO CATALYTIC RESIDUES FOR", pdbfiles[i] sys.exit() hislist = [] for res in chainB: if res == None: print "missing catalytic residue" continue if res.name == "HIS": if mycat == None: hislist.append(res) elif res == mycat: hislist.append(res) #his = res if len(hislist) == 0: print "cannot find histidine in catalytic residues" sys.exit() for his in hislist: print his.file_id NDstate = True if his.atomExists(" HD1"): proton = his.getAtom(" HD1") elif his.atomExists(" HE2"): proton = his.getAtom(" HE2") NDstate = False else: print "histidine is not protonated" hetlist = protein.getHeteroAtoms() mind = 1000.0 for res in hetlist: cpres = res.clone() cpres.removeAtomsContaining("V") dist = closestApproachToResidue(proton, cpres) mind = min(mind, dist) bPoint = False if mind < 4.0: bPoint = True bChanged = False # --- if pointing and we don't want that: --- # if bPoint and not options.inverse: switchHisTautomer(his) bChanged = True # --- if not pointing and we don't want that: --- # if not bPoint and options.inverse: switchHisTautomer(his) bChanged = True if bChanged: print "changed", pdbfiles[i] NDstate = not NDstate if options.virtual: hetatms = protein.getHeteroAtoms() for myres in hetatms: for atm in myres: if atm == None: break if atm.name == "VHNE": if not NDstate: atm.name = "VHND" continue if atm.name == "VHND": if NDstate: atm.name = "VHNE" continue protein.writePDB(outfiles[i], resRenumber=False, atomRenumber=False)
def main(): """ prints the number of CB's that are near atoms in a given selection """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-c", dest="catalytic", help="catalytic") parser.add_option("-s", dest="selection", help="selection") parser.add_option("-x", dest="cutoff", help="distance cutoff", default=5.0) parser.add_option("-d", dest="directionality", help="directionality") parser.add_option("-S", dest="scaffold", help="scaffold") parser.set_description(main.__doc__) (options,args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() if not options.selection and not options.catalytic: parser.print_help() sys.exit() sele1 = Selection() if options.selection: sele1.makeSelection(options.selection) sele2 = Selection() sele2.makeSelection("name= CA , CB ") if options.catalytic: cres = int(options.catalytic) cres -= 1 if options.directionality: direction = float(options.directionality) scaffold = None if options.scaffold: scaffold = Molecule() scaffold.readPDB(options.scaffold) cutoff = float(options.cutoff) protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) atmlist = [] if options.catalytic: if cres >= len(protein.catalytic): print "accessing catalytic residue out of bounds" sys.exit() atmlist = protein.catalytic[cres].atom if options.selection: mol1 = sele1.apply_selection(protein) atmlist = mol1.atomList() if len(atmlist) == 0: print "selection does not specify any atoms" sys.exit() if options.scaffold: mol2 = sele2.apply_selection(scaffold) else: mol2 = sele2.apply_selection(protein) CBs = mol2.residueList() taken = {} if options.catalytic: com = protein.catalytic[cres].com() for atm in atmlist: for myres in CBs: cb = myres.getAtom(" CB ") if cb == None: continue icb = int(cb.file_id) if icb in taken.keys(): continue dist = atm.distance(cb) if dist < cutoff: if options.directionality: if not isResPointingToPoint(myres, com, direction): continue taken[icb] = 1 # subtract 1 from taken as it includes self print pdbfile,len(taken)-1 protein.clear()
def main(): """ reads a rosetta output pdbfile and reports residues that have a total Eres > cutoff """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-x", dest="cutoff", help="cutoff", default=3.0) parser.add_option("-s", dest="summary", help="summary", action="store_true") parser.add_option("-c", dest="catalytic", help="only catalytic residues", action="store_true") parser.add_option("-l", dest="ligand", help="only ligand", action="store_true") parser.add_option("-C", dest="catall", help="catalytic and ligand", action="store_true") parser.add_option("-t", dest="total", help="total", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() cutoff = float(options.cutoff) bCat = False if options.catalytic or options.ligand or options.catall: bCat = True protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) tot_value = 0 catres = [] if options.catalytic or options.catall: for cat in protein.catalytic: catres.append(cat) if options.ligand or options.catall: catres.append(protein.ligand) for chn in protein.chain: for res in chn.residue: if bCat: if not res in catres: continue if res.Erep > cutoff: tot_value += res.Eres if options.summary: print pdbfile break if not options.total: print pdbfile, res.name, res.file_id, res.Eres if options.total: print pdbfile, tot_value protein.clear()
def main(): """ reports the angle between three uniquely identified atoms in a pdbfile """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("--s1", dest="selection1", help="selection1") parser.add_option("--s2", dest="selection2", help="selection2") parser.add_option("--s3", dest="selection3", help="selection3") parser.add_option("--s4", dest="selection4", help="selection4") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() if not options.selection1 or not options.selection2: parser.print_help() sys.exit() sele1 = Selection() sele2 = Selection() sele3 = Selection() sele4 = Selection() sele1.makeSelection(options.selection1) sele2.makeSelection(options.selection2) sele3.makeSelection(options.selection3) sele4.makeSelection(options.selection4) protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) mol1 = sele1.apply_selection(protein) mol2 = sele2.apply_selection(protein) mol3 = sele3.apply_selection(protein) mol4 = sele4.apply_selection(protein) alist1 = mol1.atomList() alist2 = mol2.atomList() alist3 = mol3.atomList() alist4 = mol4.atomList() if len(alist1) != 1: print "selection 1 does not specify 1 atom" sys.exit() if len(alist2) != 1: print "selection 2 does not specify 1 atom" sys.exit() if len(alist3) != 1: print "selection 3 does not specify 1 atom" sys.exit() if len(alist4) != 1: print "selection 4 does not specify 1 atom" sys.exit() atm1 = alist1[0] atm2 = alist2[0] atm3 = alist3[0] atm4 = alist4[0] tor = vector3d.torsion(atm1.coord, atm2.coord, atm3.coord, atm4.coord) print pdbfile, ":", atm1.name, "->", atm2.name, "->", atm3.name, "->", atm4.name, ":", tor protein.clear()
def main(): """ reports a list of unique matches. This is defined by the identity of the catalytic residues and the position of space of the ligand (discreteness defined by the "fineness" option) """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-f", dest="fineness", help="fineness (0.25)", default=0.25) parser.add_option("-s", dest="seq_only", help="sequence only", action="store_true") parser.add_option("--heavy_atom_only", dest="heavy_only", help="only heavy atoms considered", action="store_true") parser.add_option("-r", dest="report", help="report unique matches only", action="store_true") parser.add_option("-i", dest="inverse", help="inverse", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() protein = Enzyme() fineness = float(options.fineness) seen = {} for pdbfile in pdbfiles: name = "" protein.readPDB(pdbfile) com = vector3d() if options.heavy_only: natom = 0 for atm in protein.chain[0].atomList(): if atm.element != "H": com.x += atm.coord.x com.y += atm.coord.y com.z += atm.coord.z natom += 1 if natom > 0: com /= float(natom) else: com = protein.chain[0].com() lcom = protein.ligand.com() # get absolute value of ligand coordinates rcom = vector3d() nat = 0 for atm in protein.ligand.atom: rcom.x += math.fabs(atm.coord.x - lcom.x) rcom.y += math.fabs(atm.coord.y - lcom.y) rcom.z += math.fabs(atm.coord.z - lcom.z) nat += 1 if nat == 0: print "no ligand atoms founds" sys.exit() for cat in protein.catalytic: name += cat.aa1() + str(int(cat.file_id)) + "_" # get the ligand position if not options.seq_only: lpoint = (lcom - com) / fineness rcom /= fineness name += str(int(lpoint.x)) + "_" name += str(int(lpoint.y)) + "_" name += str(int(lpoint.z)) + "_" name += str(int(rcom.x)) + "_" name += str(int(rcom.y)) + "_" name += str(int(rcom.z)) if options.report: if options.inverse: if name in seen.keys(): print pdbfile, name else: if not (name in seen.keys()): print pdbfile, name else: print pdbfile, name seen[name] = 1 protein.clear()
import Part as part import RecognitionSite as rs import GeneticCircuit as gc import Enzyme as enz ##Create the enzymes enzyme1 = enz.Enzyme('Ara') enzyme1.addSiteToRecognize('[') enzyme1.addSiteToRecognize('D') enzyme2 = enz.Enzyme('ATc') enzyme2.addSiteToRecognize('(') circuit = gc.GeneticCircuit([]) site1 = rs.RecognitionSite('D', 1) site2 = rs.RecognitionSite('[', 1) site3 = rs.RecognitionSite('(', 1) site4 = rs.RecognitionSite('[', -1) site5 = rs.RecognitionSite('(', 1) site6 = rs.RecognitionSite('D', -1) ##Overwrite the parts in this circuit part1_1 = part.Part(1, 1) part2_1 = part.Part(3, 1) part3_1 = part.Part(5, 1) part4_1 = part.Part(7, 1) part5_1 = part.Part(9, 1) part6_1 = part.Part(11, 1) part7_1 = part.Part(13, 1) circuit.addComponent(part1_1)
def main(): """ reports the buried unsatisfied hydrogen bonds in a pdbfile. REQUIRES NACCESS """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-s", dest="selection", help="selection") parser.add_option("-c", dest="catalytic", help="catalytic") parser.add_option("-x", dest="cutoff", help="surface area cutoff", default=5.0) parser.add_option("-X", dest="hcutoff", help="hbond energy ctuoff", default=-0.1) parser.add_option("-r", dest="report", help="report number only", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() protein = Enzyme() HBN = HBnetwork() surfout = Molecule() sele = Selection() sele_string = "" if options.selection: sele.makeSelection(options.selection) sele_string += options.selection for pdbfile in pdbfiles: outlist = [] protein.readPDB(pdbfile) catid = -1 if options.catalytic: icat = int(options.catalytic) - 1 if icat >= len(protein.catalytic): print "accessing catalytic out of bounds" continue catres = protein.catalytic[icat] catid = int(catres.file_id) HBN.createNetwork(protein) HE = float(options.hcutoff) HBN.findHbonds(cutoff=HE) unsat = HBN.unsatisfiedHbonds() get_surface_area(pdbfile, "surf") surfout.readPDB("surf.asa") if surfout.numResidues == 0: print "surf.asa not found" sys.exit() if options.selection: newMol = sele.apply_selection(mol=surfout) surfout.clear() newMol.clone(surfout) for atm in unsat: myres = surfout.getResidue(int(atm.resi)) if myres == None: continue myatm = myres.getAtom(atm.name) if myatm == None: continue if catid != -1: if int(myres.file_id) != catid: continue if myatm.occupancy <= float(options.cutoff): outlist.append(myatm) if options.report: print pdbfile, len(outlist) else: for atm in outlist: print atm protein.clear() HBN.clear() surfout.clear() # clear out intermediate files os.system("rm -f surf.log") os.system("rm -f surf.pdb") os.system("rm -f surf.rsa") os.system("rm -f surf.asa")
def main(): """ uses Will's packing 'holes' and reports the number of holes near a given selection """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-s", dest="selection", help="selection") parser.add_option("-c", dest="catalytic", help="catalytic") parser.add_option("-x", dest="cutoff", help="hole radius cuotoff", default="1.4") parser.add_option("-r", dest="radius", help="radius around selection", default="4.0") parser.add_option("-v", dest="verbose", help="print holes", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() sele = Selection() if options.selection: sele.makeSelection(options.selection) hole_sele = Selection() hole_sele.makeSelection("resn=WSS") hole_radius = float(options.cutoff) protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) holes = hole_sele.apply_selection(protein).atomList() if len(holes) == 0: print pdbfile, "no packing information found" protein.clear() continue catres = [] if options.selection: protein = sele.apply_selection(protein) elif options.catalytic: if len(protein.catalytic) == 0: print "no catalytic information found!" sys.exit() catindex = int(options.catalytic) - 1 if catindex < 0 or catindex >= len(protein.catalytic): print "accessing catalytic residue out of bounds: ", catindex sys.exit() catres = protein.catalytic[catindex] if options.catalytic: protList = catres.atom else: protList = protein.atomList() surrounding = atomsAroundAtoms(atms=protList, atomList=holes, cutoff=float(options.radius)) # filter based on radius of sphere outholes_b = [] outholes = [] for atm in surrounding: if atm.bfactor > hole_radius: if not atm.occupancy in outholes_b: outholes.append(atm) outholes_b.append(atm.occupancy) print pdbfile, len(outholes) if options.verbose: for atm in outholes: print atm print "------------------------------------------------------" protein.clear()
def main(): """ prints a list of mutations between a designed sequence and a native sequence """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-n", dest="native", help="native") parser.add_option("-t", dest="type", help="type") parser.add_option("-T", dest="origType", help="original type") parser.add_option("-s", dest="summary", help="print pdbfile only", action="store_true") parser.add_option("-c", dest="count", help="count", action="store_true") parser.set_description(main.__doc__) (options,args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() if not options.native: parser.print_help() sys.exit() native = Enzyme() native.readPDB(options.native) protein = Enzyme() natseq = native.sequence() for pdbfile in pdbfiles: nmut = 0 mut_found = False protein.readPDB(pdbfile) mutseq = protein.sequence() mysize = min(len(natseq), len(mutseq)) for i in range(mysize): if natseq[i] != mutseq[i]: if options.type: if not (mutseq[i] in options.type): continue if options.origType: if not (natseq[i] in options.origType): continue mut_found = True nmut += 1 if not options.summary: print i+1,natseq[i],"->",mutseq[i] if options.summary and mut_found: if options.count: print pdbfile,nmut else: print pdbfile protein.clear() native.clear()
def main(): """ reports the residues with polar sidechain atoms contacting a given selection """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-s", dest="selection", help="selection") parser.add_option("-c", dest="catalytic", help="catalytic") parser.add_option("-x", dest="cutoff", help="cutoff (default 3.5)", default=3.5) parser.add_option("-n", dest="number", help="number only", action="store_true") parser.add_option("--charged_only", dest="charged", help="charged residues only", action="store_true") parser.add_option("--ignore_catalytic", dest="no_cat", help="ignore catalytic residues", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() cutoff = float(options.cutoff) if not options.selection and not options.catalytic: parser.print_help() sys.exit() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() sele = Selection() if options.selection: sele.makeSelection(options.selection) protein = Enzyme() protSel = Selection() protSel.makeSelection("SC;type=ATOM ") for pdbfile in pdbfiles: protein.readPDB(pdbfile) if options.catalytic: icat = int(options.catalytic) if icat == 0 or icat > len(protein.catalytic): print "accessing catalytic out of bounds" sys.exit() mysel = protein.catalytic[icat - 1].atomList() else: mysel = sele.apply_selection(protein).atomList() protAtoms = protSel.apply_selection(protein) nearby_atoms = atomsAroundAtoms(mysel, protAtoms, cutoff=cutoff) reslist = [] for atm in nearby_atoms: if options.no_cat: catFound = False for cat in protein.catalytic: if int(atm.resi) == int(cat.file_id): catFound = True break if catFound: continue if not atm.parentResidue in reslist: reslist.append(atm.parentResidue) if options.number: print pdbfile, len(reslist) else: for res in reslist: #if options.charged: # if res.name != "ARG" and res.name != "LYS" and res.name != "GLU" and res.name != "ASP": # continue if res.name == "PHE" or res.name == "TRP" or res.name == "TYR" or res.name == "MET": print res.file_id, res.name protein.clear()
def main(): """ reads a rosetta output pdbfile and reports residues that have a lig_dun > cutoff """ parser = OptionParser() parser.add_option("-p", dest="pdbfile", help="pdbfile") parser.add_option("-P", dest="pdblist", help="pdblist") parser.add_option("-x", dest="cutoff", help="cutoff", default=3.0) parser.add_option("-s", dest="summary", help="summary", action="store_true") parser.add_option("-c", dest="catalytic", help="catalytic residues") parser.add_option("-l", dest="ligand", help="only ligand", action="store_true") parser.add_option("-n", dest="name", help="residue name (unique)") parser.add_option("-C", dest="catall", help="catalytic and ligand", action="store_true") parser.set_description(main.__doc__) (options, args) = parser.parse_args() pdbfiles = [] if options.pdblist: pdbfiles = files_from_list(options.pdblist) elif options.pdbfile: pdbfiles.append(options.pdbfile) else: parser.print_help() sys.exit() cutoff = float(options.cutoff) bCat = False if options.catalytic or options.ligand or options.catall: bCat = True protein = Enzyme() for pdbfile in pdbfiles: protein.readPDB(pdbfile) tot_value = 0 tot_atr = 0 max_val = -1 catres = [] if options.catall: for cat in protein.catalytic: catres.append(cat) if options.catalytic: icat = int(options.catalytic) - 1 if icat >= len(protein.catalytic): print pdbfile, "catalytic out of bounds" sys.exit() catres.append(protein.catalytic[icat]) if options.ligand or options.catall: catres.append(protein.ligand) if options.name: bCat = True catres = protein.getResiduesByName(options.name) if len(catres) != 1: print "too many catalytic residues" sys.exit() for chn in protein.chain: for res in chn.residue: if bCat: if not res in catres: continue edun = res.Edun if edun > cutoff: tot_value += edun max_val = max(max_val, edun) if options.summary: print pdbfile break else: print pdbfile, res.file_id, res.name, edun #print pdbfile,tot_value,max_val protein.clear()