Ejemplo n.º 1
0
def main():
  dlgs = glob('*.dlg')

  if len(dlgs) == 0:
    sys.exit(1)

  if os.path.exists('target') is False:
    os.mkdir('target')

  ligands = []
  receptors = []

  for filename in dlgs:
    dlg=filename[:-4]
    (lig, rec) = dlg.split('--____--')
    if not lig in ligands:
      ligands.append(lig)
    if not rec in receptors:
      receptors.append(rec)
  
  res = [[] for i in ligands]
  for i in range(len(res)):
    res[i] = ['' for j in receptors]

  for filename in dlgs:
    dlg=filename[:-4]
    (lig, rec) = dlg.split('--____--')

    d = Docking()
    d.readDlg(filename)

    lines = d.ligMol.parser.allLines
    for i in range(len(lines)):
      line = lines[i]
      if line.find("\n") == -1:
        d.ligMol.parser.allLines[i] = line + "\n"

    if not hasattr(d, 'clusterer'):
      d.clusterer = Clusterer(d.ch.conformations, sort="binding_energy")

    clist = [d.clusterer.data[int(i)] for i in d.clusterer.argsort]

    energy = clist[0].binding_energy

    res[ligands.index(lig)][receptors.index(rec)] = "%.2f" % energy

    d.ligMol.parser.allLines = d.ligMol.parser.write_with_new_coords(clist[0].getCoords())

    write_pdb(d.ligMol.parser.parse(), 'target/%s.pdb' % dlg)

  res_file = open('target/result.txt', 'w')
  print>>res_file, ",%s" % ",".join(receptors)
  for i in range(len(res)):
    print>>res_file, "%s,%s" % (ligands[i], ",".join(res[i]))
  res_file.close()
Ejemplo n.º 2
0
def parse_dlg(dlgfilename, num, result):
    global VERBOSE

    d = Docking()
    d.readDlg(dlgfilename)

    if num > 1:
        workdir = outdir + '/' + d.ligMol.name
        if os.path.exists(workdir) is False:
            os.mkdir(workdir)
    if num == 1:
        workdir = outdir

    if num > 1:
        log = {'name': d.ligMol.name, 'num': num, 'target': workdir}
        if VERBOSE:
            print log
        #print>>result, log

    lines = d.ligMol.parser.allLines
    for i in range(len(lines)):
        line = lines[i]
        if line.find("\n") == -1:
            d.ligMol.parser.allLines[i] = line + "\n"

    if not hasattr(d, 'clusterer'):
        d.clusterer = Clusterer(d.ch.conformations, sort='binding_energy')

    clist = []

    for i in d.clusterer.argsort:
        clist.append(d.clusterer.data[int(i)])

    energy_list = []
    for i in range(0, num):
        conf = clist[i]
        outfile = workdir + '/' + d.ligMol.name + '_' + str(i + 1) + '.pdb'
        energy = conf.binding_energy
        energy_list.append("%.2f" % energy)

        mylog = {'name': outfile, 'energy': energy}
        if VERBOSE:
            print mylog

        d.ligMol.parser.allLines = d.ligMol.parser.write_with_new_coords(
            conf.getCoords())

        write_pdb(d.ligMol.parser.parse(), outfile)

    print >> result, "%s,%s" % (d.ligMol.name, ','.join(energy_list))
Ejemplo n.º 3
0
    print "xml_list =", xml_list
    p = XMLParser()
    d = Docking(parser=p)
    for xml_file in xml_list:
        print "calling readXMLResults with", xml_file
        d.readXMLResults(xml_file, dpf = dpf_fn)
    ligMol = d.ligMol
    ligAts = ligMol.allAtoms
    #setup rmsd tool
    coords = ligAts.coords[:]
    atom_ct = len(ligAts)
    torsion_ct = len(ligMol.torTree.torsionMap)
    tors_penalty = torsion_ct * 0.2744

    cl = Clusterer(d.ch.conformations)
    d.clusterer = cl
    cl.make_clustering(rms_tolerance)
    ref_coords = cl.clustering_dict[rms_tolerance][0][0].getCoords()[:]

    # for building hydrogen bonds or reporting energy breakdown
    # setup receptor:
    if build_hydrogen_bonds or report_energy_breakdown:
        ligMol.buildBondsByDistance()
        receptor = Read(receptor_filename)[0]
        receptor.buildBondsByDistance()
    if build_hydrogen_bonds:
        hbondBuilder = HydrogenBondBuilder()
    if report_energy_breakdown:
        ms = MolecularSystem()
        ms.add_entities(receptor.allAtoms)
        ms.add_entities(ligMol.allAtoms)