Example #1
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()
Example #2
0
def main():
    """
creates a poly-glycine variant of a pdbfile by removing all sidechains
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.add_option("-r",
                      dest="replace",
                      help="replace",
                      action="store_true")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

    if not options.pdbfile or not options.outfile:
        parser.print_help()
        sys.exit()

    selection = Selection()
    selection.makeSelection("BB")

    protein = Molecule()
    protein.readPDB(options.pdbfile)
    newmol = selection.apply_selection(protein)
    for chain in newmol.chain:
        for res in chain.residue:
            res.name = "GLY"

    newmol.writePDB(options.outfile)
Example #3
0
def main():
    """
reports the maximal distance between two sets of atoms
	"""

    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.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 = Molecule()
    probe = Molecule()

    target.readPDB(options.target)
    mysel = None
    tlist = []
    if options.selection:
        mysel = Selection()
        mysel.makeSelection(options.selection)
        target = mysel.apply_selection(target)
    tlist = target.atomList()
    nlist = len(tlist)

    plist = []
    for probefile in probes:
        maxdist = 0.0
        probe.readPDB(probefile)

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

        plist = probe.atomList()

        if len(plist) != nlist:
            print "differing number of atoms"
            sys.exit()

        for i in range(nlist):
            dist = tlist[i].distance(plist[i])
            if dist > maxdist:
                maxdist = dist

        print probefile, maxdist
        probe.clear()
Example #4
0
def main():
    """
reads in a pdbfile and writes out the protein sequence
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-P", dest="pdblist", help="pdblist")
    parser.add_option("-t",
                      dest="transpose",
                      help="transpose",
                      action="store_true")
    parser.add_option("-n", dest="number", help="number", action="store_true")
    parser.add_option("-r", dest="range", help="range")
    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()

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

    seq_min = 1
    seq_max = 1
    if options.range:
        (min, max) = string.split(arg, "-")
        seq_min = int(min)
        seq_max = int(max)

    protein = Molecule()
    Seq = ""
    for pdb in pdbfiles:
        protein.readPDB(pdb)
        if options.selection:
            newmol = sele.apply_selection(protein)
            Seq = newmol.sequence()
        else:
            Seq = protein.sequence()

        if options.range:
            Seq = Seq[seq_min:seq_max]

        if options.transpose:
            for i in range(len(Seq)):
                print Seq[i]
        else:
            print Seq

        protein.clear()
Example #5
0
def GenerateOffspring(parents):
    offspring = []
    while (len(offspring) != len(parents)):
        parentA, parentB = Selection.Selection(parents)
        childA, childB = Crossover.Crossover(parentA, parentB)
        childA = Mutation.Mutation(childA)
        childB = Mutation.Mutation(childB)
        offspring.append(childA)
        offspring.append(childB)
    return offspring
Example #6
0
def main():
    """
list the hydrogen bonds in a protein that have a score less than a given threshold
	"""

    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("-S",
                      dest="summary",
                      help="summary",
                      action="store_true")
    parser.add_option("-x", dest="cutoff", help="cutoff", default=-0.3)
    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)

    protein = Enzyme()
    HBN = HBnetwork()
    for pdbfile in pdbfiles:
        protein.readPDB(pdbfile)
        newprot = protein
        if options.selection:
            newprot = sele.apply_selection(protein)

        HBN.createNetwork(newprot)
        HBN.findHbonds(cutoff=float(options.cutoff))

        found = False
        if options.summary:
            print pdbfile, len(HBN.hbonds)
            found = True
        else:
            for hb in HBN.hbonds:
                print pdbfile, hb
                found = True

        if not found:
            print pdbfile, "NONE"

        protein.clear()
        HBN.clear()
Example #7
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():
    """
given a match output file creates an output file of the catalytic site only
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

    if not options.outfile or not options.pdbfile:
        parser.print_help()
        sys.exit()

    # read remark
    remark = re.compile("REMARK")
    try:
        pdb = open(options.pdbfile)
    except:
        print "unable to open pdbfile"
        sys.exit()

    resline = "resi="
    read = False
    for line in pdb.readlines():
        if remark.match(line):
            cols = line.split()
            resi = cols[5]
            if read:
                resline += ","
            resline += resi
            read = True

    pdb.close()

    selection = Selection()
    selection.makeSelection(resline)

    # ---   extract out the residue selections   --- #
    protein = Molecule()
    protein.readPDB(options.pdbfile)
    newmol = selection.apply_selection(protein)
    selection.clear()

    # ---   extract out the hetero atoms   --- #
    selection.makeSelection("type=HETATM")
    hetatm = selection.apply_selection(protein)
    reslist = hetatm.residueList()

    newchain = newmol.newChain()
    newchain.addResidueList(reslist)

    newmol.writePDB("dumb.pdb")
Example #9
0
def main():
    """
trims a grid for a given selection and cutoff values
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-s", dest="sele", help="sele")
    parser.add_option("-g", dest="grid", help="grid")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.add_option("-r",
                      dest="replace",
                      help="replace",
                      action="store_true")
    parser.add_option("-e",
                      dest="exclude",
                      help="exclude",
                      action="store_true")
    parser.add_option("-c", dest="cutoff", help="cutoff", default=3.0)
    (options, args) = parser.parse_args()

    if not options.pdbfile or not options.grid:
        parser.print_help()
        sys.exit()

    if options.outfile:
        outgrid = options.outfile
    elif options.replace:
        outgrid = options.grid
    else:
        parser.print_help()
        sys.exit()

    protein = Molecule()
    protein.readPDB(options.pdbfile)

    if options.sele:
        selection = Selection()
        selection.makeSelection(options.sele)
        newmol = selection.apply_selection(protein)
    else:
        newmol = protein.clone()

    mygrid = grid()
    mygrid.read(options.grid)

    atomlist = newmol.atomList()
    if options.exclude:
        gridTrimExclude(mygrid, atomlist, float(options.cutoff))
    else:
        gridTrimInclude(mygrid, atomlist, float(options.cutoff))

    mygrid.write(outgrid)
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()
Example #11
0
 def __init__(self, params):
     self.epochs = params['epochs']
     self.Crossover = Crossover(params['crossover_type'],
                                params['crossover_prob'])
     self.Population = Population(booth_function, params['population_size'],
                                  2, -10, 10,
                                  params['population_precision'])
     self.Mutation = Mutation(params['mutation_type'],
                              params['mutation_prob'])
     self.Inversion = Inversion(params['inversion_type'],
                                params['inversion_prob'])
     self.Selection = Selection(params['selection_type'],
                                params['selection_prob'])
     self.EliteStrategy = EliteStrategy(params['elite_prob'])
Example #12
0
def main():
    """
builds new atoms onto existing pdbfiles.  EXPERIMENTAL AND UNTESTED
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.add_option("--dist", dest="distance", help="distance")
    parser.add_option("--ang", dest="angle", help="angle")
    parser.add_option("--tor", dest="torsion", help="torsion")
    parser.add_option("-s", "--selection", dest="selection", help="selection")
    parser.add_option("-b", "--build", dest="build", help="build")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

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

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

    mol = Molecule()
    mol.readPDB(options.pdbfile)

    selector = Selection()
    selector.makeSelection(options.selection)
    mysel = selector.apply_selection(mol)

    builder = Builder()

    atomlist = mysel.atomList()
    if len(atomlist) != 3:
        print "must select three atoms. ", len(atomlist)

    newatom = Atom()
    newatom.name = "new"
    dist = float(options.distance)
    ang = float(options.angle)
    tor = float(options.torsion)
    builder.buildAtom(newatom, atomlist[0], atomlist[1], atomlist[2], dist,
                      ang, tor)

    mol.chain[0].residue[0].addAtom(newatom)
    mol.writePDB(options.outfile)
Example #13
0
def main():
    """
prints a list of unsatisfied hydrogen bonds in a protein
	"""

    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.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 = Molecule()
    HBN = HBnetwork()

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

    for pdbfile in pdbfiles:
        protein.readPDB(pdbfile)
        HBN.createNetwork(protein)
        HBN.findHbonds()
        unsat = HBN.unsatisfiedHbonds()

        if options.selection:
            atmlist = sele.apply_selection(protein, return_mol=False)
            for atm in unsat:
                if atm in atmlist:
                    print atm
        else:
            for atm in unsat:
                print atm

        protein.clear()
        HBN.clear()
Example #14
0
    def generatePlayer(cls):
        """
        Desc: Class method, creates a character and fills in parameters with user input when called
        Input: None
        Output: Character() instance
        """
        mySelection = Selection()
        raceObj = mySelection.race_select()
        classObj = mySelection.class_select()
        print("What is your name?\n")

        return cls(
            input(">> "),  # name
            raceObj,  # race choice
            classObj,  # class choice
            classObj.statsList,  # stats
            raceObj.movesList  # moves
        )
def main():
    """
	switches tautomers of histidine in a selection of residues
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-o", dest="outfile", help="outfile")
    parser.add_option("-r",
                      dest="replace",
                      help="replace",
                      action="store_true")
    parser.add_option("-s", dest="selection", help="selection")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

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

    if options.outfile:
        outfile = options.outfile
    elif options.replace:
        outfile = options.pdbfile
    else:
        parser.print_help()
        sys.exit()

    sele = Selection()
    if options.selection:
        sele.makeSelection(options.selection)
    else:
        sele.makeSelection("resn=HIS")

    protein = Molecule()
    protein.readPDB(options.pdbfile)

    his_prot = sele.apply_selection(protein)
    his_list = his_prot.residueList()

    for his in his_list:
        switchHisTautomer(his)

    protein.writePDB(outfile, resRenumber=False, atomRenumber=False)
Example #16
0
def main():
    """
	finds the residue-based 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("-s", dest="selection", help="selection")
    parser.add_option("-c", dest="cutoff", help="cutoff")
    parser.set_description(main.__doc__)
    (options, args) = parser.parse_args()

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

    target = Molecule()
    probe = Molecule()

    target.readPDB(options.target)
    probe.readPDB(options.probe)

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

        target = mysel.apply_selection(target)
        probe = mysel.apply_selection(probe)

    rms = res_fit(target, probe)

    for line in rms:
        if options.cutoff:
            if float(line[1]) > float(options.cutoff):
                print line[0], line[1]
        else:
            print line[0], line[1]
Example #17
0
def main():
    """
	program that prints out selections from a pdbfile
	"""

    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-s", dest="selection", help="selection")
    (options, args) = parser.parse_args()

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

    protein = Molecule()
    protein.readPDB(options.pdbfile)

    sele = Selection()
    sele.makeSelection(options.selection)
    smol = sele.apply_selection(protein)
    reslist = smol.residueList()

    for res in reslist:
        print res
Example #18
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()
Example #19
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()
Example #20
0
def run(playlist_files):
    # Init pygame
    pygame.mixer.pre_init(44100, -16, 2, 2048) # setup mixer to avoid sound lag
    print "Init pygame, version = ", pygame.version.ver
    
    pygame.init()
    if not pygame.display.get_init():
        print "Error during pygame init."
        print "Quit."
        sys.exit(1)
    
    
    # Init Screen
    fullscreen = False
    if fullscreen:
        size = width, height = 1366,768
    else:
        size = width, height = 1366/2,760
    
    screen = pygame.display.set_mode(size, (pygame.FULLSCREEN | pygame.HWSURFACE if fullscreen else pygame.RESIZABLE))
    pygame.display.set_caption("Ardent'Scene studio")
    #pygame.mouse.set_visible(False)

    # Init modules
    DrawText.init()
    
    # Init entities
    ball = pygame.image.load(ressources_dir + "ball.gif")
    ballrect = ball.get_rect()
    speed = [20, 18]


    # ***
    cmanager = CManager.CManager()

    # ---
    tmanagers = Loader.load_playlists(playlist_files)
    tman_i = 0
    
    cur_tmanager = tmanagers[0]

    # ---
    keys = [pygame.K_a, pygame.K_z, pygame.K_e, 
            pygame.K_r, pygame.K_t, pygame.K_y, 
            pygame.K_u, pygame.K_i, pygame.K_o,
            pygame.K_p ]
    selection = Selection.Selection(keys, pygame.K_ASTERISK)
    
    # ---
    commands = [
            Commands.Play(cmanager, pygame.K_v),
            Commands.Stop(cmanager, pygame.K_n),
            Commands.Fadein(cmanager, pygame.K_g),
            Commands.Fadeout(cmanager, pygame.K_j),
            Commands.UpTracks(cmanager, pygame.K_DOWN),
            Commands.DownTracks(cmanager, pygame.K_UP)
            ]

    # to know when exiting the soft
    quitting = 0

    while 1:
        for event in pygame.event.get():
            if event.type == pygame.QUIT: 
                quit()
            # ---
            elif event.type == pygame.KEYDOWN:
                quitting = quitting-1
                if event.key == pygame.K_ESCAPE:
                    quit()
                elif event.key == pygame.K_BACKSPACE:
                    if quitting < 0:
                        quitting = 0
                    quitting = quitting + 2
                    if quitting >= 5:
                        quit()
                elif event.key == pygame.K_SPACE:
                    pass
                # select a track
                elif selection.is_selection(event.key):
                    selection.treat_key(event.key, cur_tmanager)
                # change current tmanager 
                elif event.key == pygame.K_LEFT:
                    if tman_i > 0:
                        print 'Previous playlist'
                        tman_i -= 1
                        cur_tmanager = tmanagers[tman_i]
                elif event.key == pygame.K_RIGHT:
                    if tman_i < len(tmanagers)-1:
                        print 'Next playlist'
                        tman_i += 1
                        cur_tmanager = tmanagers[tman_i]
                # execute a command
                else:
                    for cmd in commands:
                        if cmd.is_this_command(event.key):
                            cmd.execute(cur_tmanager)
            # ---
            elif event.type == pygame.locals.USEREVENT:
                print 'Event : Sound has finished'
                # Channel event
                cmanager.has_finished()
    
        ballrect = ballrect.move(speed)
        if ballrect.left < 0 or ballrect.right > width:
            speed[0] = -speed[0]
        if ballrect.top < 0 or ballrect.bottom > height:
            speed[1] = -speed[1]
    
        screen.fill(Color.black)
        screen.blit(ball, ballrect)
        cur_tmanager.draw(screen)
        draw_playlist_index(screen, tman_i)
        pygame.display.flip()
        pygame.time.delay(50)
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")
Example #22
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()
Example #23
0
def main():
	parser = OptionParser()
	parser.add_option("-t", dest="target", help="target")
	parser.add_option("-P", dest="probe", help="probe")
	parser.add_option("-s", dest="sele", help="sele")
	(options, args) = parser.parse_args()

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

	try:
		PROBE = open(options.probe, 'r')
	except:
		print "unable to open probe list"
		sys.exit()

	prbMol = Molecule()
	trgMol = Molecule()

	[trg_start, trg_end] = options.sele.split("-")

	sel     = Selection()
	sel_str = "resi=" + trg_start + ";name= N  , CA , C  , O  "
	sel.makeSelection(sel_str)
	trgMol.readPDB(options.target)
	target = sel.apply_selection(trgMol)

	[base, rest] = options.target.split(".")
	newMol = 0
	for line in PROBE.readlines():
		line = string.rstrip(line)

		[file, start, end] = line.split()
		[id, rest] = file.split("_",1)
		[tmp, num] = rest.split("SLH_")
		outfile = base + "_" + id + "_" + num
		size = int(end) - int(start) + 1
		start = int(start)-1
		prb_start = start+1
		prb_end   = int(end)+1

		print file
		
		prbMol.readPDB(file)
		sel_str = "resi=" + str(start) + ";name= N  , CA , C  , O  "
		sel.clear()
		sel.makeSelection(sel_str)

		probe = sel.apply_selection(prbMol)

		superimpose_molecule(target, probe, prbMol)

		iprb1 = prbMol.chain[0].getResidueIndex(prb_start)
		iprb2 = prbMol.chain[0].getResidueIndex(prb_end)

		if iprb1 == None or iprb2 == None:
			print "cannot get index of ",prb_start

		iprb1 = int(iprb1)
		iprb2 = int(iprb2)
		prbslice = prbMol.chain[0].residue[iprb1:iprb2]
		newMol = trgMol.clone()

		beg = int(trg_start)
		end = int(trg_end)
		newMol.chain[0].slice(beg+1,end-1)
		newMol.chain[0].insertResidues(prbslice, beg)
		newMol.addRemark("REMARK LOOP INSERTION " + str(beg+1) + " " + str(beg+size))
		newMol.writePDB(outfile)

		probe.clear()
		prbMol.clear()
		newMol.clear()
Example #24
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()
Example #25
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()
Example #26
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)
Example #27
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()
Example #28
0
def main():
    parser = OptionParser()
    parser.add_option("-p", dest="pdbfile", help="pdbfile")
    parser.add_option("-t", dest="TIMfile", help="TIMfile")
    (options, args) = parser.parse_args()

    if not options.pdbfile or not options.TIMfile:
        parser.print_help()
        sys.exit()

    # ===   read the TIMfile   === #
    try:
        TIMFILE = open(options.TIMfile, 'r')
    except:
        print "unable to open TIMfile"

    (basename, other) = options.pdbfile.split(".", 2)
    print "basename = ", basename

    Sel = Selection()
    protein = Molecule()
    protein.readPDB(options.pdbfile)

    cols = []
    stripped = 0
    nHLS = 0
    nSLH = 0
    for line in TIMFILE.readlines():
        line = string.strip(line)
        cols = line.split()
        if len(cols) == 0:
            if stripped:
                stripped.writePDB(outname)

            continue

        if cols[0] == "SLH":
            nSLH += 1
            startX = cols[2]
            endX = cols[3]

            Sel.clear()
            Sel.makeSelection("resi=" + str(startX) + "-" + str(endX))
            stripped = Sel.apply_selection(protein)
            outname = basename + "_SLH_" + str(nSLH) + ".pdb"

        if cols[0] == "HLS":
            nHLS += 1
            startX = cols[2]
            endX = cols[3]

            Sel.clear()
            Sel.makeSelection("resi=" + str(startX) + "-" + str(endX))
            stripped = Sel.apply_selection(protein)
            outname = basename + "_HLS_" + str(nHLS) + ".pdb"

        if cols[0] == "HELIX":
            startH = cols[2]
            endH = cols[3]
            myStart = int(startH) - int(startE) + 1
            myEnd = int(endH) - int(startE) + 1
            mySize = myEnd - myStart + 1
            stripped.addRemark("REMARK HELIX " + str(mySize) + " " +
                               str(myStart) + " " + str(myEnd))

        if cols[0] == "LOOP":
            startL = cols[2]
            endL = cols[3]
            myStart = int(startL) - int(startE) + 1
            myEnd = int(endL) - int(startE) + 1
            mySize = myEnd - myStart + 1
            #stripped.addRemark("REM LOOP  " + startL + " " + endL)
            stripped.addRemark("REMARK LOOP  " + str(mySize) + " " +
                               str(myStart) + " " + str(myEnd))

        if cols[0] == "SHEET":
            startE = cols[2]
            endE = cols[3]
            myEnd = int(endE) - int(startE) + 1
            mySize = myEnd
            #stripped.addRemark("REM SHEET " + startE + " " + endE)
            stripped.addRemark("REMARK SHEET " + str(mySize) + " 1 " +
                               str(myEnd))

    TIMFILE.close()
Example #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()
Example #30
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()