def main(argv=(__name__)):
    """
    the protein should have charges and radii but the ligand need not
    """
    itf = oechem.OEInterface()

    if not oechem.OEConfigure(itf, InterfaceData):
        oechem.OEThrow.Fatal("Problem configuring OEInterface!")

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to parse command line")

    ligFile = itf.GetString("-l")
    ims = oechem.oemolistream()
    if not ims.open(ligFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % ligFile)
    lig = oechem.OEGraphMol()
    oechem.OEReadMolecule(ims, lig)

    contextFile = itf.GetString("-p")
    ims = oechem.oemolistream()
    if not ims.open(contextFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % contextFile)
    prot = oechem.OEGraphMol()
    oechem.OEReadMolecule(ims, prot)

    highRes = itf.GetBool("-high_res")
    GetSzmapEnergies(lig, prot, highRes)
Exemple #2
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-i")
    oname = itf.GetString("-o")

    ims = oechem.oemolistream()
    if not ims.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    oms = oechem.oemolostream()
    if not oms.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    inmol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ims, inmol):
        oechem.OEThrow.Fatal("Cannot read input file!")

    allSites = itf.GetBool("-a")
    splitCovalent = itf.GetBool("-c")
    separateResidues = itf.GetBool("-s")
    combineFilters = itf.GetBool("-pw")
    if combineFilters:
        SplitMolComplexCombineFilters(oms, inmol)
    elif allSites:
        SplitMolComplexAllSites(oms, inmol, splitCovalent)
    else:
        SplitMolComplex(oms, inmol, splitCovalent, separateResidues)

    oms.close()
Exemple #3
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    imstr = oechem.oemolistream(itf.GetString("-in"))
    omstr = oechem.oemolostream(itf.GetString("-out"))

    receptors = []
    for receptor_filename in itf.GetStringList("-receptors"):
        receptor = oechem.OEGraphMol()
        if not oedocking.OEReadReceptorFile(receptor, receptor_filename):
            oechem.OEThrow.Fatal("Unable to read receptor from %s" %
                                 receptor_filename)
        receptors.append(receptor)

    poser = oedocking.OEPosit()
    for receptor in receptors:
        poser.AddReceptor(receptor)

    for mcmol in imstr.GetOEMols():
        print("posing", mcmol.GetTitle())
        result = oedocking.OESinglePoseResult()
        ret_code = poser.Dock(result, mcmol)
        if ret_code == oedocking.OEDockingReturnCode_Success:
            posedMol = result.GetPose()
            oechem.OESetSDData(posedMol, poser.GetName(),
                               str(result.GetProbability()))
            oechem.OESetSDData(posedMol, "Receptor Index",
                               str(result.GetReceptorIndex()))
            oechem.OEWriteMolecule(omstr, posedMol)
        else:
            errMsg = oedocking.OEDockingReturnCodeGetName(ret_code)
            oechem.OEThrow.Warning("%s: %s" % (mcmol.GetTitle(), errMsg))
    return 0
def main(argv=(__name__)):
    """
    the protein should have charges and radii but the ligand need not
    """
    itf = oechem.OEInterface()

    if not oechem.OEConfigure(itf, InterfaceData):
        oechem.OEThrow.Fatal("Problem configuring OEInterface!")

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to parse command line")

    ligFile = itf.GetString("-l")
    ims = oechem.oemolistream()
    if not ims.open(ligFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % ligFile)
    lig = oechem.OEGraphMol()
    oechem.OEReadMolecule(ims, lig)

    contextFile = itf.GetString("-p")
    ims = oechem.oemolistream()
    if not ims.open(contextFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % contextFile)
    prot = oechem.OEGraphMol()
    oechem.OEReadMolecule(ims, prot)

    outputFile = itf.GetString("-o")
    oms = oechem.oemolostream()
    if not oms.open(outputFile):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % outputFile)

    GenerateSzmapProbes(oms, itf.GetDouble("-prob"), lig, prot)
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    oemolprop.OEConfigureFilterParams(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    ftype = oemolprop.OEGetFilterType(itf)
    filt = oemolprop.OEFilter(ftype)

    ver = itf.GetInt("-verbose")
    oechem.OEThrow.SetLevel(ver)

    ostr = oechem.oeosstream()
    pwnd = False
    filt.SetTable(ostr, pwnd)

    headers = ostr.str().split(b'\t')
    ostr.clear()  # remove the header row from the stream

    for mol in ifs.GetOEGraphMols():
        filt(mol)

        fields = ostr.str().decode("UTF-8").split('\t')
        ostr.clear()  # remove this row from the stream

        tmpdct = dict(zip(headers, fields))
        print(mol.GetTitle(), tmpdct[b"Lipinski violations"])
Exemple #6
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)
    oedepict.OEConfigureReportOptions(itf)
    oedepict.OEConfigurePrepareDepictionOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    iname = itf.GetString("-in")
    ifs = oechem.oemolistream()
    ifs.SetConfTest(oechem.OEAbsoluteConfTest())  # VTL
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    oname = itf.GetString("-out")
    ext = oechem.OEGetFileExtension(oname)
    if ext != "pdf":
        oechem.OEThrow.Fatal("Output must be PDF format.")

    ofs = oechem.oeofstream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    if itf.HasString("-ringdict"):
        rdfname = itf.GetString("-ringdict")
        if not oechem.OEInit2DRingDictionary(rdfname):
            oechem.OEThrow.Warning("Cannot use user-defined ring dictionary!")

    ropts = oedepict.OEReportOptions()
    oedepict.OESetupReportOptions(ropts, itf)
    ropts.SetFooterHeight(25.0)
    report = oedepict.OEReport(ropts)

    popts = oedepict.OEPrepareDepictionOptions()
    oedepict.OESetupPrepareDepictionOptions(popts, itf)

    dopts = oedepict.OE2DMolDisplayOptions()
    oedepict.OESetup2DMolDisplayOptions(dopts, itf)
    dopts.SetDimensions(report.GetCellWidth(), report.GetCellHeight(),
                        oedepict.OEScale_AutoScale)

    for mol in ifs.GetOEMols():  # VTL ignore confs; dont use GetOEGraphMols
        print(mol.GetTitle())  # VTL
        cell = report.NewCell()
        oedepict.OEPrepareDepiction(mol, popts)
        disp = oedepict.OE2DMolDisplay(mol, dopts)
        oedepict.OERenderMolecule(cell, disp)

    font = oedepict.OEFont(oedepict.OEFontFamily_Default,
                           oedepict.OEFontStyle_Bold, 12,
                           oedepict.OEAlignment_Center, oechem.OEBlack)
    for pagenum, footer in enumerate(report.GetFooters()):
        text = "Page %d of %d" % (pagenum + 1, report.NumPages())
        oedepict.OEDrawTextToCenter(footer, text, font)

    oedepict.OEWriteReport(ofs, ext, report)

    return 0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    MMPAnalyzeProbe(itf)
Exemple #8
0
def main(argv=[__name__]):
    # import configuration file
    itf = oechem.OEInterface()
    oechem.OEConfigure(itf, InterfaceData)
    # add configuration for image size and display options
    oedepict.OEConfigureImageOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    ifname = itf.GetString("-in")
    ofname = itf.GetString("-out")

    ifs = oechem.oemolistream(ifname)
    mol = oechem.OEGraphMol()
    oechem.OEReadMolecule(ifs, mol)
    oedepict.OEPrepareDepiction(mol)

    width, height = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(itf)
    opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale)
    # set up display options from command line parameters
    oedepict.OESetup2DMolDisplayOptions(opts, itf)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(ofname, disp)
Exemple #9
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    ifs = oechem.oemolistream()

    inputFile = itf.GetString("-in")
    if not ifs.open(inputFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading" % inputFile)

    ofs = oechem.oemolostream()

    outFile = itf.GetString("-out")
    if not ofs.open(outFile):
        oechem.OEThrow.Fatal("Unable to open %s for writing" % outFile)

    chargeName = itf.GetString("-method")

    mol = oechem.OEMol()
    while oechem.OEReadMolecule(ifs, mol):
        if not AssignChargesByName(mol, chargeName):
            oechem.OEThrow.Warning("Unable to assign %s charges to mol %s" %
                                   (chargeName, mol.GetTitle()))
        oechem.OEWriteMolecule(ofs, mol)

    ifs.close()
    ofs.close()
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    oemedchem.OEConfigureMCSFragDatabaseOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    MCSFragIndex(itf)
Exemple #11
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    oemedchem.OEConfigureMatchedPairIndexOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    SerializeInput(itf)
Exemple #12
0
def main(argv=[__name__]):

    itf = oechem.OEInterface()
    oechem.OEConfigure(itf, InterfaceData)
    oedepict.OEConfigureImageWidth(itf, 400.0)
    oedepict.OEConfigureImageHeight(itf, 400.0)
    oedepict.OEConfigureImageGridParams(itf)
    oedepict.OEConfigurePrepareDepictionOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    oname = itf.GetString("-out")

    ext = oechem.OEGetFileExtension(oname)
    if not oedepict.OEIsRegisteredImageFile(ext):
        oechem.OEThrow.Fatal("Unknown image type!")

    ofs = oechem.oeofstream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    width, height = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(
        itf)
    image = oedepict.OEImage(width, height)

    rows = oedepict.OEGetImageGridNumRows(itf)
    cols = oedepict.OEGetImageGridNumColumns(itf)
    grid = oedepict.OEImageGrid(image, rows, cols)

    popts = oedepict.OEPrepareDepictionOptions()
    oedepict.OESetupPrepareDepictionOptions(popts, itf)

    dopts = oedepict.OE2DMolDisplayOptions()
    oedepict.OESetup2DMolDisplayOptions(dopts, itf)
    dopts.SetDimensions(grid.GetCellWidth(), grid.GetCellHeight(),
                        oedepict.OEScale_AutoScale)

    celliter = grid.GetCells()
    for iname in itf.GetStringList("-in"):
        ifs = oechem.oemolistream()
        if not ifs.open(iname):
            oechem.OEThrow.Warning("Cannot open %s input file!" % iname)
            continue

        for mol in ifs.GetOEGraphMols():
            if not celliter.IsValid():
                break

            oedepict.OEPrepareDepiction(mol, popts)
            disp = oedepict.OE2DMolDisplay(mol, dopts)
            oedepict.OERenderMolecule(celliter.Target(), disp)
            celliter.Next()

    oedepict.OEWriteImage(ofs, ext, image)

    return 0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    # @ <SNIPPET-ALTLOCFACT-FLAVOR>
    ims = oechem.oemolistream()
    ims.SetFlavor(oechem.OEFormat_PDB, oechem.OEIFlavor_PDB_ALTLOC)
    # @ </SNIPPET-ALTLOCFACT-FLAVOR>

    inputFile = itf.GetString("-in")
    if not ims.open(inputFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading." % inputFile)

    if not oechem.OEIs3DFormat(ims.GetFormat()):
        oechem.OEThrow.Fatal("%s is not in a 3D format." % inputFile)

    mol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ims, mol):
        oechem.OEThrow.Fatal("Unable to read %s." % inputFile)

    if not oechem.OEHasResidues(mol):
        oechem.OEPerceiveResidues(mol, oechem.OEPreserveResInfo_All)

    # @ <SNIPPET-ALTLOCFACT-PRIMARY>
    alf = oechem.OEAltLocationFactory(mol)
    if alf.GetGroupCount() != 0:
        alf.MakePrimaryAltMol(mol)
    # @ </SNIPPET-ALTLOCFACT-PRIMARY>

    # @ <SNIPPET-PLACE-HYDROGENS-BASIC>
    if oechem.OEPlaceHydrogens(mol):
        # ...
        # @ </SNIPPET-PLACE-HYDROGENS-BASIC>
        print("success")

    # @ <SNIPPET-PLACE-HYDROGENS-OPTIONS>
    opt = oechem.OEPlaceHydrogensOptions()
    opt.SetStandardizeBondLen(False)
    # @ </SNIPPET-PLACE-HYDROGENS-OPTIONS>

    # @ <SNIPPET-PLACE-HYDROGENS-DETAILS>
    # given molecule mol and OEPlaceHydrogensOptions opt...
    details = oechem.OEPlaceHydrogensDetails()
    if oechem.OEPlaceHydrogens(mol, details, opt):
        print(details.Describe())
    # @ </SNIPPET-PLACE-HYDROGENS-DETAILS>

    ims.close()
Exemple #14
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)
    oedepict.OEConfigureImageOptions(itf)
    oedepict.OEConfigurePrepareDepictionOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")

    ext = oechem.OEGetFileExtension(oname)
    if not oedepict.OEIsRegisteredImageFile(ext):
        oechem.OEThrow.Fatal("Unknown image type!")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    ofs = oechem.oeofstream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    mol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ifs, mol):
        oechem.OEThrow.Fatal("Cannot read input file!")

    if itf.HasString("-ringdict"):
        rdfname = itf.GetString("-ringdict")
        if not oechem.OEInit2DRingDictionary(rdfname):
            oechem.OEThrow.Warning("Cannot use user-defined ring dictionary!")

    popts = oedepict.OEPrepareDepictionOptions()
    oedepict.OESetupPrepareDepictionOptions(popts, itf)

    oedepict.OEPrepareDepiction(mol, popts)

    width, height = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(
        itf)
    dopts = oedepict.OE2DMolDisplayOptions(width, height,
                                           oedepict.OEScale_AutoScale)
    oedepict.OESetup2DMolDisplayOptions(dopts, itf)

    disp = oedepict.OE2DMolDisplay(mol, dopts)
    oedepict.OERenderMolecule(ofs, ext, disp)

    return 0
Exemple #15
0
def main(argv=[__name__]):

    itf = oechem.OEInterface()
    oechem.OEConfigure(itf, InterfaceData)
    oegraphsim.OEConfigureFingerPrint(
        itf, oegraphsim.OEGetFPType(oegraphsim.OEFPType_Tree))

    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    ifname = itf.GetString("-in")
    ffname = itf.GetString("-fpdb")

    if oechem.OEGetFileExtension(ffname) != "fpbin":
        oechem.OEThrow.Fatal(
            "Fingerprint database file should have '.fpbin' file extension!")

    idxfname = oechem.OEGetMolDatabaseIdxFileName(ifname)

    if not os.path.exists(idxfname):
        if not oechem.OECreateMolDatabaseIdx(ifname):
            oechem.OEThrow.Warning("Unable to create %s molecule index file" %
                                   idxfname)

    oechem.OEThrow.Info("Using %s index molecule file" % idxfname)

    moldb = oechem.OEMolDatabase()
    if not moldb.Open(ifname):
        oechem.OEThrow.Fatal("Cannot open molecule database file!")

    nrmols = moldb.GetMaxMolIdx()

    fptype = oegraphsim.OESetupFingerPrint(itf)
    oechem.OEThrow.Info("Using fingerprint type %s" % fptype.GetFPTypeString())

    opts = oegraphsim.OECreateFastFPDatabaseOptions(fptype)
    opts.SetTracer(oechem.OEDots(100000, 1000, "fingerprints"))
    oechem.OEThrow.Info("Generating fingerprints with %d threads" %
                        opts.GetNumProcessors())

    timer = oechem.OEWallTimer()
    if not oegraphsim.OECreateFastFPDatabaseFile(ffname, ifname, opts):
        oechem.OEThrow.Fatal("Cannot create fingerprint database file!")

    oechem.OEThrow.Info("%5.2f secs to generate %d fingerprints" %
                        (timer.Elapsed(), nrmols))

    return 0
def main(argv=[__name__]):

    # @ <SNIPPET-OECONFIGURECOLOR>
    itf = oechem.OEInterface()
    oedepict.OEConfigureColor(itf, "mycolor", "c",
                              "Example of using OEConfigureColor", "blue")
    # @ </SNIPPET-OECONFIGURECOLOR>

    if oechem.OECheckHelp(itf, argv):
        return True

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    color = oechem.OEGetColor(itf, "mycolor")
    print(str(color))
Exemple #17
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    # @ <SNIPPET-RESCORE-POSES-CONFIGURE>
    oedocking.OEScoreTypeConfigure(itf, "-score")
    # @ </SNIPPET-RESCORE-POSES-CONFIGURE>
    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    receptor = oechem.OEGraphMol()
    if not oedocking.OEReadReceptorFile(receptor, itf.GetString("-receptor")):
        oechem.OEThrow.Fatal("Unable to read receptor")
    imstr = oechem.oemolistream()
    if not imstr.open(itf.GetString("-in")):
        oechem.OEThrow.Fatal("Unable to open input file of ligands")
    omstr = oechem.oemolostream()
    if not omstr.open(itf.GetString("-out")):
        oechem.OEThrow.Fatal("Unable to open out file for rescored ligands")

    # @ <SNIPPET-RESCORE-POSES-GET-VALUE>
    scoreType = oedocking.OEScoreTypeGetValue(itf, "-score")
    # @ </SNIPPET-RESCORE-POSES-GET-VALUE>
    # @ <SNIPPET-RESCORE-POSES-SETUP-SCORE>
    score = oedocking.OEScore(scoreType)
    # @ </SNIPPET-RESCORE-POSES-SETUP-SCORE>
    # @ <SNIPPET-RESCORE-POSES-INITIALIZE>
    score.Initialize(receptor)
    # @ </SNIPPET-RESCORE-POSES-INITIALIZE>

    for ligand in imstr.GetOEMols():
        if itf.GetBool("-optimize"):
            # @ <SNIPPET-RESCORE-POSES-OPTIMIZE>
            score.SystematicSolidBodyOptimize(ligand)
            # @ </SNIPPET-RESCORE-POSES-OPTIMIZE>
        # @ <SNIPPET-RESCORE-POSES-ANNOTATE>
        score.AnnotatePose(ligand)
        # @ </SNIPPET-RESCORE-POSES-ANNOTATE>
        sdtag = score.GetName()
        # @ <SNIPPET-RESCORE-POSES-ASSIGN-SCORE>
        oedocking.OESetSDScore(ligand, score, sdtag)
        # @ </SNIPPET-RESCORE-POSES-ASSIGN-SCORE>
        # @ <SNIPPET-RESCORE-POSES-SCORE-SORTING>
        oechem.OESortConfsBySDTag(ligand, sdtag,
                                  score.GetHighScoresAreBetter())
        # @ </SNIPPET-RESCORE-POSES-SCORE-SORTING>
        oechem.OEWriteMolecule(omstr, ligand)

    return 0
Exemple #18
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    ims = oechem.oemolistream()
    ims.SetFlavor(oechem.OEFormat_PDB, oechem.OEIFlavor_PDB_ALTLOC)

    inputFile = itf.GetString("-in")
    if not ims.open(inputFile):
        oechem.OEThrow.Fatal("Unable to open %s for reading." % inputFile)

    if not oechem.OEIs3DFormat(ims.GetFormat()):
        oechem.OEThrow.Fatal("%s is not in a 3D format." % inputFile)

    mol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ims, mol):
        oechem.OEThrow.Fatal("Unable to read %s." % inputFile)

    if not oechem.OEHasResidues(mol):
        oechem.OEPerceiveResidues(mol, oechem.OEPreserveResInfo_All)

    alf = oechem.OEAltLocationFactory(mol)
    if alf.GetGroupCount() != 0:
        alf.MakePrimaryAltMol(mol)

    # in our example, we will select the first histidine
    selectedResidue = oechem.OEResidue()
    for atom in mol.GetAtoms():
        res = oechem.OEAtomGetResidue(atom)
        if oechem.OEGetResidueIndex(res) == oechem.OEResidueIndex_HIS:
            selectedResidue = res
            break

    # @ <SNIPPET-PLACE-HYDROGENS-PRED>
    # given predicate IsSameResidue, residue selectedResidue and molecule mol...
    opt = oechem.OEPlaceHydrogensOptions()
    opt.SetNoFlipPredicate(IsSameResidue(selectedResidue))

    if oechem.OEPlaceHydrogens(mol, opt):
        # selectedResidue will not be flipped...
        # @ </SNIPPET-PLACE-HYDROGENS-PRED>
        print("success")

    ims.close()
Exemple #19
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    # @ <SNIPPET-DOCK-MOLECULES-CONFIGURE>
    oedocking.OEDockMethodConfigure(itf, "-method")
    oedocking.OESearchResolutionConfigure(itf, "-resolution")
    # @ </SNIPPET-DOCK-MOLECULES-CONFIGURE>
    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    imstr = oechem.oemolistream(itf.GetString("-in"))
    omstr = oechem.oemolostream(itf.GetString("-out"))

    receptor = oechem.OEGraphMol()
    if not oedocking.OEReadReceptorFile(receptor, itf.GetString("-receptor")):
        oechem.OEThrow.Fatal("Unable to read receptor")

    # @ <SNIPPET-DOCK-MOLECULES-GET-VALUE>
    dockMethod = oedocking.OEDockMethodGetValue(itf, "-method")
    dockResolution = oedocking.OESearchResolutionGetValue(itf, "-resolution")
    # @ </SNIPPET-DOCK-MOLECULES-GET-VALUE>
    # @ <SNIPPET-DOCK-MOLECULES-SETUP>
    dock = oedocking.OEDock(dockMethod, dockResolution)
    # @ </SNIPPET-DOCK-MOLECULES-SETUP>
    # @ <SNIPPET-DOCK-MOLECULES-INITIALIZE>
    dock.Initialize(receptor)
    # @ </SNIPPET-DOCK-MOLECULES-INITIALIZE>

    for mcmol in imstr.GetOEMols():
        print("docking", mcmol.GetTitle())
        dockedMol = oechem.OEGraphMol()
        # @ <SNIPPET-DOCK-MOLECULES-DOCK>
        retCode = dock.DockMultiConformerMolecule(dockedMol, mcmol)
        if (retCode != oedocking.OEDockingReturnCode_Success):
            oechem.OEThrow.Fatal("Docking Failed with error code " + oedocking.OEDockingReturnCodeGetName(retCode))

        # @ </SNIPPET-DOCK-MOLECULES-DOCK>
        sdtag = oedocking.OEDockMethodGetName(dockMethod)
        # @ <SNIPPET-DOCK-MOLECULES-ASSIGN-SCORE>
        oedocking.OESetSDScore(dockedMol, dock, sdtag)
        # @ </SNIPPET-DOCK-MOLECULES-ASSIGN-SCORE>
        # @ <SNIPPET-DOCK-MOLECULES-ANNOTATE>
        dock.AnnotatePose(dockedMol)
        # @ </SNIPPET-DOCK-MOLECULES-ANNOTATE>
        oechem.OEWriteMolecule(omstr, dockedMol)

    return 0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    rname = itf.GetString("-ref")
    fname = itf.GetString("-fit")
    oname = itf.GetString("-out")

    rifs = oechem.oemolistream()
    if not rifs.open(rname):
        oechem.OEThrow.Fatal("Cannot open reference molecule file!")

    refmol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(rifs, refmol):
        oechem.OEThrow.Fatal("Cannot read reference molecule!")

    fifs = oechem.oemolistream()
    if not fifs.open(fname):
        oechem.OEThrow.Fatal("Cannot open align molecule file!")

    ofs = oechem.oemolostream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")
    if not oechem.OEIs2DFormat(ofs.GetFormat()):
        oechem.OEThrow.Fatal("Invalid output format for 2D coordinates")

    oedepict.OEPrepareDepiction(refmol)

    mcss = oechem.OEMCSSearch(oechem.OEMCSType_Approximate)
    atomexpr = oechem.OEExprOpts_DefaultAtoms
    bondexpr = oechem.OEExprOpts_DefaultBonds
    mcss.Init(refmol, atomexpr, bondexpr)
    mcss.SetMCSFunc(oechem.OEMCSMaxBondsCompleteCycles())

    oechem.OEWriteConstMolecule(ofs, refmol)

    for fitmol in fifs.GetOEGraphMols():
        alignres = oedepict.OEPrepareAlignedDepiction(fitmol, mcss)
        if alignres.IsValid():
            oechem.OEThrow.Info("%s  mcs size: %d" % (fitmol.GetTitle(), alignres.NumAtoms()))
            oechem.OEWriteMolecule(ofs, fitmol)

    return 0
Exemple #21
0
def SetupInterface(argv, itf):
    oechem.OEConfigure(itf, InterfaceData)
    if oechem.OECheckHelp(itf, argv):
        return False
    if not oechem.OEParseCommandLine(itf, argv):
        return False
    infile = itf.GetString("-in")
    if not oechem.OEIsReadable(
            oechem.OEGetFileType(oechem.OEGetFileExtension(infile))):
        oechem.OEThrow.Warning("%s is not a readable input file" % infile)
        return False
    outfile = itf.GetString("-out")
    if not oegrid.OEIsWriteableGrid(
            oegrid.OEGetGridFileType(oechem.OEGetFileExtension(outfile))):
        oechem.OEThrow.Warning("%s is not a writable grid file" % outfile)
        return False
    return True
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)
    oedepict.OEConfigureImageOptions(itf)
    oedepict.OEConfigure2DMolDisplayOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")

    ext = oechem.OEGetFileExtension(oname)
    if not oedepict.OEIsRegisteredImageFile(ext):
        oechem.OEThrow.Fatal("Unknown image type!")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    if ifs.GetFormat() != oechem.OEFormat_MDL:
        oechem.OEThrow.Fatal("Input file is not an MDL query file")

    ofs = oechem.oeofstream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    mol = oechem.OEGraphMol()
    if not oechem.OEReadMDLQueryFile(ifs, mol):
        oechem.OEThrow.Fatal("Cannot read mdl query input file!")

    clearcoords, suppressH = False, False
    oedepict.OEPrepareDepiction(mol, clearcoords, suppressH)

    width, height = oedepict.OEGetImageWidth(itf), oedepict.OEGetImageHeight(
        itf)
    opts = oedepict.OE2DMolDisplayOptions(width, height,
                                          oedepict.OEScale_AutoScale)
    oedepict.OESetup2DMolDisplayOptions(opts, itf)

    disp = oedepict.OE2DMolDisplay(mol, opts)
    oedepict.OERenderMolecule(ofs, ext, disp)

    return 0
Exemple #23
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")
    smarts = itf.GetString("-smarts")

    qmol = oechem.OEQMol()
    if not oechem.OEParseSmarts(qmol, smarts):
        oechem.OEThrow.Fatal("Invalid SMARTS: %s" % smarts)
    oechem.OEGenerate2DCoordinates(qmol)

    ss = oechem.OESubSearch(qmol)
    if not ss.IsValid():
        oechem.OEThrow.Fatal("Unable to initialize substructure search!")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input molecule file!")

    ofs = oechem.oemolostream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")
    if not oechem.OEIs2DFormat(ofs.GetFormat()):
        oechem.OEThrow.Fatal("Invalid output format for 2D coordinates")

    for mol in ifs.GetOEGraphMols():
        oechem.OEPrepareSearch(mol, ss)

        alignres = oedepict.OEPrepareAlignedDepiction(mol, ss)
        if not alignres.IsValid():
            oechem.OEThrow.Warning(
                "Substructure is not found in input molecule!")
            oedepict.OEPrepareDepiction(mol)

        oechem.OEWriteMolecule(ofs, mol)

    return 0
Exemple #24
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)
    oechem.OEConfigureSplitMolComplexOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")

    ims = oechem.oemolistream()
    if not itf.GetUnsignedInt("-modelnum") == 1:
        ims.SetFlavor(
            oechem.OEFormat_PDB,
            oechem.OEGetDefaultIFlavor(oechem.OEFormat_PDB)
            & ~oechem.OEIFlavor_PDB_ENDM)
    if not ims.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    oms = oechem.oemolostream()
    if not oms.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    inmol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ims, inmol):
        oechem.OEThrow.Fatal("Cannot read input file!")

    opts = oechem.OESplitMolComplexOptions()
    oechem.OESetupSplitMolComplexOptions(opts, itf)

    if itf.GetBool("-verbose"):
        # don't bother counting sites unless we're going to print them
        numSites = oechem.OECountMolComplexSites(inmol, opts)
        oechem.OEThrow.SetLevel(oechem.OEErrorLevel_Verbose)
        oechem.OEThrow.Verbose("sites %d" % numSites)

    for frag in oechem.OEGetMolComplexComponents(inmol, opts):
        oechem.OEThrow.Verbose("frag %s" % frag.GetTitle())
        oechem.OEWriteMolecule(oms, frag)

    oms.close()
Exemple #25
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line.")

    ifname = itf.GetString("-in")
    ofname = itf.GetString("-out")
    stype = itf.GetString("-stype")
    sort = itf.GetBool("-sort")
    keeptitle = itf.GetBool("-keep-title")
    nrthreads = itf.GetUnsignedInt("-nrthreads")

    screentype = None
    if stype == "MOLECULE":
        screentype = oechem.OEGetSubSearchScreenType(
            oechem.OESubSearchScreenType_Molecule)
    elif stype == "MDL":
        screentype = oechem.OEGetSubSearchScreenType(
            oechem.OESubSearchScreenType_MDL)
    elif stype == "SMARTS":
        screentype = oechem.OEGetSubSearchScreenType(
            oechem.OESubSearchScreenType_SMARTS)
    if screentype is None:
        oechem.OEThrow.Fatal("stype %s is not supported" % stype)

    opts = oechem.OECreateSubSearchDatabaseOptions(screentype)
    opts.SetSortByBitCounts(sort)
    opts.SetKeepTitle(keeptitle)
    opts.SetNumProcessors(nrthreads)

    screenstr = screentype.GetName()
    infomsg = "Using %d processor(s) to generate database with '%s'"
    oechem.OEThrow.Info(infomsg % (opts.GetNumProcessors(), screenstr))

    tracer = oechem.OEConsoleProgressTracer()
    if not oechem.OECreateSubSearchDatabaseFile(ofname, ifname, opts, tracer):
        oechem.OEThrow.Fatal(
            "Substructure search database can not be generated!")

    return 0
Exemple #26
0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-i")
    oname = itf.GetString("-o")

    ims = oechem.oemolistream()
    if not ims.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    oms = oechem.oemolostream()
    if not oms.open(oname):
        oechem.OEThrow.Fatal("Cannot open output file!")

    inmol = oechem.OEGraphMol()
    if not oechem.OEReadMolecule(ims, inmol):
        oechem.OEThrow.Fatal("Cannot read input file!")

    allSites = itf.GetBool("-a")
    filterLigand = itf.GetBool("-f")

    # break out each scheme to better illustrate them
    if filterLigand:
        SplitMolComplexIterFilter(oms, inmol)
    elif itf.HasString("-l"):
        ligName = itf.GetString("-l")
        if allSites:
            SplitMolComplexIterAllSitesLigName(oms, inmol, ligName)
        else:
            SplitMolComplexIterLigName(oms, inmol, ligName)
    else:
        if allSites:
            SplitMolComplexIterAllSites(oms, inmol)
        else:
            SplitMolComplexIter(oms, inmol)

    oms.close()
Exemple #27
0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    oemolprop.OEConfigureFilterParams(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    ftype = oemolprop.OEGetFilterType(itf)
    filt = oemolprop.OEFilter(ftype)

    ver = itf.GetInt("-verbose")
    oechem.OEThrow.SetLevel(ver)

    oemolprop.OEWritePropertyDataToCSV(oname, ifs, filt)
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)
    oedepict.OEConfigureReportOptions(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    ifname = itf.GetString("-ringdict")
    ofname = itf.GetString("-out")

    if not oechem.OEIsValid2DRingDictionary(ifname):
        oechem.OEThrow.Fatal("Invalid ring dictionary file!")

    ringdict = oechem.OE2DRingDictionary(ifname)

    ropts = oedepict.OEReportOptions()
    oedepict.OESetupReportOptions(ropts, itf)

    oedepict.OEWrite2DRingDictionaryReport(ofname, ringdict, ropts)

    return 0
def main(argv=[__name__]):

    itf = oechem.OEInterface(InterfaceData)

    if oechem.OECheckHelp(itf, argv):
        return 0

    if not oechem.OEParseCommandLine(itf, argv):
        return 1

    ifs = oechem.oemolistream()
    if not ifs.open(itf.GetString("-i")):
        oechem.OEThrow.Fatal("Unable to open %s for reading" %
                             itf.GetString("-i"))

    ofs = oechem.oemolostream()
    if not ofs.open(itf.GetString("-o")):
        oechem.OEThrow.Fatal("Unable to open %s for writing" %
                             itf.GetString("-o"))

    omega = oeomega.OEOmega()
    maxConfs = 0
    omega.SetMaxConfs(maxConfs)
    omega.SetStrictStereo(False)
    omega.SetSampleHydrogens(True)
    omega.SetEnumNitrogen(oeomega.OENitrogenEnumeration_All)
    mol = oechem.OEMol()
    for mol in ifs.GetOEMols():
        #print( mol.GetTitle() )
        if not omega(mol):
            print("omega failed on %s" % mol.GetTitle())
        title = mol.GetTitle()
        oechem.OETriposAtomNames(mol)
        oequacpac.OEAssignPartialCharges(mol, oequacpac.OECharges_AM1BCCSym)
        oechem.OEWriteConstMolecule(ofs, mol)

    ofs.close()
    return 0
def main(argv=[__name__]):
    itf = oechem.OEInterface(InterfaceData)
    oemolprop.OEConfigureFilterParams(itf)

    if not oechem.OEParseCommandLine(itf, argv):
        oechem.OEThrow.Fatal("Unable to interpret command line!")

    iname = itf.GetString("-in")
    oname = itf.GetString("-out")

    ifs = oechem.oemolistream()
    if not ifs.open(iname):
        oechem.OEThrow.Fatal("Cannot open input file!")

    ofs = oechem.oemolostream()
    if not ofs.open(oname):
        oechem.OEThrow.Fatal("Cannot create output file!")

    fmt = ofs.GetFormat()
    if fmt not in [
            oechem.OEFormat_SDF, oechem.OEFormat_OEB, oechem.OEFormat_CSV
    ]:
        oechem.OEThrow.Fatal("Only SD, OEB, and CSV formats preserve SD data")

    ftype = oemolprop.OEGetFilterType(itf)
    filt = oemolprop.OEFilter(ftype)

    ver = itf.GetInt("-verbose")
    oechem.OEThrow.SetLevel(ver)

    pwnd = False
    filt.SetTable(oechem.oenul, pwnd)
    filt.SetSDTag(True)

    for mol in ifs.GetOEGraphMols():
        filt(mol)
        oechem.OEWriteMolecule(ofs, mol)