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()
Esempio n. 2
0
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()
Esempio n. 3
0
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()
Esempio n. 4
0
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()
Esempio n. 5
0
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()
Esempio n. 6
0
def main():
    """
	finds the rms between two pdbfiles without superimposing
	"""

    parser = OptionParser()
    parser.add_option("-t", dest="target", help="target")
    parser.add_option("-p", dest="probe", help="probe")
    parser.add_option("-P", dest="probelist", help="probelist")
    parser.add_option("-s", dest="selection", help="selection")
    parser.add_option("-c",
                      dest="centroid",
                      help="center only",
                      action="store_true")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

    if not options.target:
        parser.print_help()
        sys.exit()

    probes = []
    if options.probelist:
        probes = files_from_list(options.probelist)
    elif options.probe:
        probes.append(options.probe)
    else:
        parser.print_help()
        sys.exit()

    target = Enzyme()
    probe = Enzyme()

    target.readPDB(options.target)
    mysel = None
    if options.selection:
        mysel = Selection()
        mysel.makeSelection(options.selection)
        target = mysel.apply_selection(target)

    for probefile in probes:
        probe.readPDB(probefile)

        if options.selection:
            probe = mysel.apply_selection(probe)

        if options.centroid:
            tar_com = target.com()
            prb_com = probe.com()
            rms = tar_com.distance(prb_com)
        else:
            rms = fit(target, probe)
        print probefile, rms
        probe.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()
Esempio n. 8
0
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()
Esempio n. 9
0
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()
Esempio n. 10
0
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()
Esempio n. 11
0
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()
Esempio n. 12
0
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()
Esempio n. 13
0
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()
Esempio n. 14
0
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)
Esempio n. 15
0
def main():
    """
	finds the rms between two pdbfiles without superimposing
	"""

    parser = OptionParser()
    parser.add_option("-t", dest="target", help="target")
    parser.add_option("-p", dest="probe", help="probe")
    parser.add_option("-P", dest="probelist", help="probelist")
    parser.add_option("-c", dest="catalytic", help="catalytic residue")
    parser.add_option("-H",
                      dest="heavy",
                      help="heavy atom only",
                      action="store_true")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

    if not options.target:
        parser.print_help()
        sys.exit()

    probes = []
    if options.probelist:
        probes = files_from_list(options.probelist)
    elif options.probe:
        probes.append(options.probe)
    else:
        parser.print_help()
        sys.exit()

    if not options.catalytic:
        parser.print_help()
        sys.exit()

    target = Enzyme()
    probe = Enzyme()

    target.readPDB(options.target)

    icat = int(options.catalytic) - 1
    if icat > len(target.catalytic):
        print "accessing catalytic residue out of bounds"
        sys.exit()

    tar_cat = target.catalytic[icat]
    tlist = []
    if options.heavy:
        for atm in tar_cat.atom:
            if atm.element != "H":
                tlist.append(atm)
    else:
        tlist = tar_cat.atom

    for probefile in probes:
        probe.readPDB(probefile)

        if icat > len(probe.catalytic):
            print "accessing catalytic residue out of bounds"
            sys.exit()

        prb_cat = probe.catalytic[icat]
        plist = []
        if options.heavy:
            for atm in prb_cat.atom:
                if atm.element != "H":
                    plist.append(atm)
        else:
            plist = prb_cat.atom

        rms = fitAtomList(tlist, plist)
        print probefile, rms
        probe.clear()
Esempio n. 16
0
def main():
    """
	creates a resfile from an enzyme
	"""

    parser = OptionParser()
    parser.add_option("-P", dest="pdblist", help="pdblist")
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.add_option("-O", dest="outlist", help="outlist")
    parser.add_option("--no_gly",
                      dest="no_gly",
                      help="no glycine at ss",
                      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)
    else:
        parser.print_help()
        sys.exit()

    nfiles = len(pdbfiles)
    if len(outfiles) != nfiles:
        print "number of files differ"
        parser.print_help()
        sys.exit()

    enz = Enzyme()
    resfile = Resfile()
    for ifile in range(nfiles):
        enz.clear()
        resfile.clear()

        enz.readPDB(pdbfiles[ifile])
        resfile.setMolecule(enz)

        if options.no_gly:
            natss = getSecondaryStructure(pdbfiles[ifile])
            if len(natss) < enz.protein.numResidues():
                print "number of residues and secondary structure do no match"
                sys.exit()

        prot = enz.protein
        lig = enz.ligand
        nres = len(prot.residue)

        designable = [False] * nres
        repackable = [False] * nres
        for i in range(nres):
            res = prot.residue[i]
            if enz.isCatalytic(res):
                resfile.setCatalytic(i)
            else:
                if res.name == "GLY":
                    CB = res.getAtom(" CA ")
                else:
                    CB = res.getAtom(" CB ")

                #if options.only_cat:
                # --- get distance to ligand --- #
                distCB = closestApproachToResidue(CB, lig)
                if distCB < 6.0:
                    designable[i] = True
                elif distCB < 8.0:
                    if isResPointingToRes(res, lig, cutoff=60):
                        designable[i] = True
                    else:
                        repackable[i] = True
                elif distCB < 10.0:
                    repackable[i] = True

                # --- get distance to residue
                focusedRes = None
                mindist = 5000
                for cres in enz.catalytic:
                    dist = closestApproachToResidue(CB, cres)
                    if dist < mindist:
                        focusedRes = cres
                        mindist = dist

                if focusedRes != None:
                    if mindist < 5.5:
                        if isResPointingToRes(res, focusedRes, cutoff=60):
                            designable[i] = True
                        else:
                            repackable[i] = True
                    elif mindist < 7.0:
                        repackable[i] = True

        for i in range(nres):
            res = enz.protein.residue[i]
            if designable[i]:
                if options.no_gly and res.name != "GLY":
                    if natss[i] == "H" or natss[i] == "E":
                        resfile.designNoGly(i)
                    else:
                        resfile.designOnly(i)
                else:
                    resfile.designOnly(i)
            elif repackable[i]:
                resfile.repackOnly(i)

        resfile.write(outfiles[ifile])
Esempio n. 17
0
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)
Esempio n. 18
0
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 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")
Esempio n. 20
0
def main():
    """
adds a centroid
	"""

    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("-s", dest="selection", help="selection")
    parser.add_option("-w", dest="wobble", help="wobble", 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()

    nfiles = len(pdbfiles)
    if nfiles != len(outfiles):
        print "number of input and output files differ"
        sys.exit()

    if not options.selection:
        parser.print_help()
        sys.exit()

    mymol = Enzyme()
    sele = Selection()
    sele.makeSelection(options.selection)
    for i in range(nfiles):
        pdbfile = pdbfiles[i]
        outfile = outfiles[i]

        mymol.readPDB(pdbfile)
        alist = sele.apply_selection(mymol).atomList()

        if len(alist) == 0:
            print "pdbfile: no atoms"
            continue

        com = vector3d()
        for atm in alist:
            com += atm.coord

        com /= float(len(alist))

        newatm = mymol.ligand.newAtom()
        newatm.name = options.type
        newatm.coord.x = com.x
        newatm.coord.y = com.y
        newatm.coord.z = com.z
        newatm.kind = "HETATM"
        if options.wobble:
            newatm.coord.x += 0.001
            newatm.coord.y -= 0.001
            newatm.coord.z += 0.001

        mymol.writePDB(outfile)
        mymol.clear()
Esempio n. 21
0
def main():
    """
returns the surface area of a protein (or selection).
REQUIRES EXTERNAL BINARY "NACCESS".
This looks for naccess in ~/code/naccess/nacess
or in /net/local/bin/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("-t",
                      dest="total",
                      help="report total surface area",
                      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.selection and not options.catalytic:
#		parser.print_help()
#		sys.exit()

    sasafile = Molecule()
    sele = Selection()
    if options.selection:
        sele.makeSelection(options.selection)

    enz = Enzyme()

    outbase = "clean"
    outpdb = outbase + ".asa"
    for pdbfile in pdbfiles:

        if options.catalytic:
            enz.readPDB(pdbfile)
            icat = int(options.catalytic) - 1
            cres = int(enz.catalytic[icat].file_id)
            newsele = "resi=" + str(cres)
            if options.selection:
                newsele += ";" + options.selection
            sele.clear()
            sele.makeSelection(newsele)
            enz.clear()

        get_surface_area(pdbfile, outbase)
        sasafile.readPDB(outpdb)
        if options.selection or options.catalytic:
            atmlist = sele.apply_selection(sasafile).atomList()
        else:
            atmlist = sasafile.atomList()

        if options.total:
            tot_sas = 0.0
            for atm in atmlist:
                tot_sas += atm.occupancy
            print pdbfile, ":", tot_sas
        else:
            print pdbfile, ":"
            for atm in atmlist:
                #print atm
                print atm.file_id, atm.name, atm.resn, atm.resi, atm.occupancy, atm.bfactor

        sasafile.clear()
Esempio n. 22
0
def main():
    """
checks for shape complementarity for the enzyme
	"""

    parser = OptionParser()
    parser.add_option("-P", dest="pdblist", help="pdblist")
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    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()

    # --- read in dot information --- #
    home = os.environ["pyScriptsDir"]
    dotfile = home + "/data/sa64.dat"
    dotlib = DotLib()
    dotlib.read(dotfile)

    protein = Enzyme()
    for pdbfile in pdbfiles:
        protein.readPDB(pdbfile)
        ligAtoms = protein.ligand.atom

        atomlist = []
        for a in ligAtoms:
            if a.radius == 0:
                continue
            atomlist.append(a)

        # --- get nearby atoms --- #
        prot = protein.protein
        nearbyatoms = atomsAroundAtoms(atms=atomlist,
                                       atomList=prot.atomList(),
                                       cutoff=7.0)

        ligand_molsurf = MolSurface(dotlib)
        ligand_molsurf.setAtoms(atomlist)
        ligand_molsurf.extractSurface()
        mypnts = ligand_molsurf.identifyExposed(atomlist=nearbyatoms)
        ligand_molsurf.removePoints(mypnts, buffer=1.5)
        ligand_molsurf.extractNormals()
        #ligand_molsurf.printSurfacePoints(" O  ")
        #ligand_molsurf.printNormals(" N  ")
        #return

        active_molsurf = MolSurface(dotlib)
        active_molsurf.setAtoms(nearbyatoms)
        active_molsurf.extractSurface()
        active_molsurf.restrictToNearby(atomlist=atomlist, buffer=2.8)
        mypnts = active_molsurf.identifyExposed(atomlist)
        active_molsurf.removePoints(mypnts, buffer=1.5)
        active_molsurf.extractNormals()
        #active_molsurf.printSurfacePoints(" N  ")
        #active_molsurf.printNormals(" O  ")
        #return

        # --- get shape complementarity --- #
        S_ab = []
        for ilig in range(ligand_molsurf.numPoints()):
            xa = ligand_molsurf.points[ilig]
            # must be shielded from solvent
            iactive = active_molsurf.closestPoint(xa)
            if iactive == -1:
                continue

            xb = active_molsurf.points[iactive]
            na = ligand_molsurf.normals[ilig]
            tb = active_molsurf.normals[iactive]
            nb = vector3d(-tb.x, -tb.y, -tb.z)

            dist2 = -0.5 * xa.dist2(xb)
            dotp = na * nb
            ans = dotp * math.exp(dist2)
            S_ab.append(float(ans))

        S_ba = []
        for iAct in range(active_molsurf.numPoints()):
            xb = active_molsurf.points[iAct]
            # must be shielded from solvent
            ilig = ligand_molsurf.closestPoint(xb)
            if ilig == -1:
                continue

            xb = active_molsurf.points[iAct]
            nb = active_molsurf.normals[iAct]

            xa = ligand_molsurf.points[ilig]
            ta = ligand_molsurf.normals[ilig]
            na = vector3d(-ta.x, -ta.y, -ta.z)

            dist2 = -0.5 * xa.dist2(xb)
            dotp = math.fabs(na * nb)
            ans = dotp * math.exp(dist2)
            S_ba.append(float(ans))

        S_ab.sort()
        S_ba.sort()

        med_index_ab = len(S_ab) / 2
        med_index_ba = len(S_ba) / 2

        print med_index_ab
        print "Sab = ", S_ab[med_index_ab]

        SC = 0.5 * (S_ab[med_index_ab] + S_ba[med_index_ba])
        print "SC = ", SC

        protein.clear()
Esempio n. 23
0
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()
Esempio n. 24
0
def main():

	"""
reports cavities around selections
	"""

	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("-c", dest="catalytic", help="only catalytic residues")
	parser.add_option("-l", dest="ligand", help="only ligand", action="store_true")
	parser.add_option("-C", dest="catall", help="all catalytic residues", action="store_true")
	parser.add_option("-r", dest="radius", help="hole radius", default=1.4)
	parser.add_option("-s", dest="selection", help="selection")
	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

	re_cluster = re.compile("COMMENT CavClust")

	sele = Selection()
	if options.selection:
		sele.makeSelection(options.selection)

	protein = Enzyme()
	for pdbfile in pdbfiles:
		protein.readPDB(pdbfile)

		cat_id = []
		mysel = []
		if options.catalytic:
			icat = int(options.catalytic) -1
			if icat < 0 or icat >= len(protein.catalytic):
				print "accessing catalytic out of bounds"
				sys.exit()
			mysel.append(protein.catalytic[icat])
		elif options.catall:
			for cat in protein.catalytic:
				mysel.append(cat)

		if options.ligand:
			for res in protein.chain[0].residue:
				if res.name == "LG1":
					mysel.append(res)

		if options.selection:
			tmp = sele.apply_selection(protein)
			for chn in tmp.chain:
				for res in chn.residue:
					mysel.append(res)
				

		# get cavities
		cavities = []
		for chn in protein.chain:
			for res in chn.residue:
				if res.name == "WSS":
					cavities.append(res)

		cav_atom_list = []
		for res in cavities:
			for atm in res.atom:
				cav_atom_list.append(atm)

		sel_atom_list = []
		for res in mysel:
			for atm in res.atom:
				sel_atom_list.append(atm)

		nearby_cav_atoms = atomsAroundAtoms(sel_atom_list, atomList=cav_atom_list, cutoff=cutoff)
		cav_res = []
		for atm in nearby_cav_atoms:
			if not atm.parentResidue in cav_res:
				cav_res.append(atm.parentResidue)

		# get cavities
		chainZ = protein.getChain("Z")
		if chainZ == None:
			print "cant' find chain Z"
			sys.exit()

		pdb_cav_list = []
		icav = 1
		for res in chainZ.residue:
			if res in cav_res:
				pdb_cav_list.append(icav)
			icav += 1

		protein.clear()

		try:
			PDBFILE = open(pdbfile)
		except:
			print "can't open pdbfile"
			sys.exit()

		tot_vol = 0.0
		for line in PDBFILE.readlines():
			if re_cluster.match(line):
				cols = line.split()
				if int(cols[2]) in pdb_cav_list:
					tot_vol += float(cols[5])

		print pdbfile,len(cav_res),tot_vol

		PDBFILE.close()
Esempio n. 25
0
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()
Esempio n. 26
0
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("-s", dest="ids", help="atom ids (comma separated)")
    parser.add_option("-t", dest="type", help="atom type", default="CS1 ")
    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()

    if not options.ids:
        parser.print_help()
        sys.exit()

    ids = []
    cols = options.ids.split(",")
    for id in cols:
        ids.append(int(id))

    mymol = Enzyme()
    for i in range(len(pdbfiles)):
        pdbfile = pdbfiles[i]
        outfile = outfiles[i]
        mymol.readPDB(pdbfile)

        lig = mymol.ligand

        for id in ids:
            myatm = mymol.getAtom(id)
            if myatm == None:
                print "cant find atom:", id

            newatm = myatm.clone()
            newatm.name = options.type

            newatm.coord.x += 0.001
            newatm.coord.y -= 0.001
            newatm.coord.z += 0.001

            lig.addAtom(newatm)

        mymol.writePDB(outfile)
        mymol.clear()
Esempio n. 27
0
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()
Esempio n. 28
0
def main():
    """
solvates a histidine
	"""

    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("-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 "number of input and output files differ"
        sys.exit()

    if not options.catalytic:
        parser.print_help()
        sys.exit()

    icat = int(options.catalytic) - 1
    protein = Enzyme()
    for i in range(len(pdbfiles)):
        protein.readPDB(pdbfiles[i])
        if icat < 0 or icat >= len(protein.catalytic):
            print "accessing catalytic residue out of bounds"
            sys.exit()

        cat = protein.catalytic[icat]
        if cat.name != "HIS":
            print "catalytic residue is not a histidine"
            sys.exit()

        # check protonation state
        if cat.getAtom(" HD1") != None:
            A = cat.getAtom(" NE2")
            B = cat.getAtom(" CD2")
            C = cat.getAtom(" CG ")
        elif cat.getAtom(" HE2") != None:
            A = cat.getAtom(" ND1")
            B = cat.getAtom(" CE1")
            C = cat.getAtom(" NE2")
        else:
            print "unable to determine protonation state"
            sys.exit()

        if A == None or B == None or C == None:
            print "cannot find all 3 atoms"
            sys.exit()

        length = 2.98
        ang = 125.0
        tor = 180.0

        billder = Builder()
        crd = billder.dbuildAtom(A, B, C, length, ang, tor)
        newres = protein.chain[1].newResidue()
        newres.name = "LG2"

        newatm = newres.newAtom()
        newatm.coord.x = crd[0]
        newatm.coord.y = crd[1]
        newatm.coord.z = crd[2]
        newatm.name = "HOH "
        newatm.kind = "HETATM"

        protein.writePDB(outfiles[i])
        protein.clear()
Esempio n. 29
0
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()
Esempio n. 30
0
def main():

	"""
reads a rosetta output pdbfile and reports residues that have a lig_rep > 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", action="store_true")
	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.add_option("-t", dest="total", help="total", action="store_true")
	parser.add_option("-r", dest="radius", help="include residues within radius")
	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

	bRad = False
	if options.radius:
		bRad = True
		rad_cutoff = float(options.radius)

	protein = Enzyme()
	for pdbfile in pdbfiles:
		protein.readPDB(pdbfile)
		tot_value = 0
		tot_atr = 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)

		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:
			if bRad:
				ligAtms = protein.ligand.atom
				near_res = residuesAroundAtoms(ligAtms, protein, rad_cutoff)

			for res in chn.residue:

				if bCat and not bRad:
					if not res in catres:
						continue

				if bRad:
					if not res in catres:
						if not res in near_res:
							continue

				erep = res.Erep
				if erep > cutoff:
					tot_value += erep
					tot_atr += res.Eatr

					if options.summary:
						print pdbfile
						break

					if not options.total:
						myE = res.Erep + res.Eatr + res.EhbSC + res.Esol + res.Edun
						print pdbfile,res.name,res.file_id,res.Erep,res.Eatr,res.EhbSC,res.Esol,res.Edun,myE
			
		if options.total:
			print pdbfile,tot_value,tot_atr

		protein.clear()