Beispiel #1
0
    def _prepare_ligand_template(
        self, ligand_template: pd.Series, kinase_domain: oechem.OEGraphMol
    ) -> oechem.OEGraphMol:
        """
        Prepare a PDB structure containing the ligand template of interest.
        Parameters
        ----------
        ligand_template: pd.Series
            A data series containing entries 'pdb', 'chain', 'ligand' and 'alt'.
        kinase_domain: oechem.OEGraphMol
            An OpenEye molecule holding the kinase domain the ligand template structure should be superposed to.
        Returns
        -------
        : oechem.OEGraphMol
            An OpenEye molecule holding the prepared ligand structure.
        """
        from openeye import oechem
        from ..modeling.OEModeling import (
            read_molecules,
            select_chain,
            select_altloc,
            remove_non_protein,
            superpose_proteins,
        )
        from ..utils import FileDownloader

        logging.debug("Interpreting structure ...")
        ligand_template_structure = PDBProtein(ligand_template.pdb)
        if not ligand_template_structure.path.is_file():
            logging.debug(f"Downloading PDB entry {ligand_template.pdb} ...")
            FileDownloader.rcsb_structure_pdb(ligand_template.pdb)
        logging.debug("Reading structure ...")
        ligand_template_structure = read_molecules(ligand_template_structure.path)[0]

        logging.debug("Selecting chain ...")
        ligand_template_structure = select_chain(ligand_template_structure, ligand_template.chain)

        logging.debug("Selecting alternate location ...")
        ligand_template_structure = select_altloc(ligand_template_structure, ligand_template.alt)

        logging.debug("Removing everything but protein, water and ligand of interest ...")
        ligand_template_structure = remove_non_protein(
            ligand_template_structure, exceptions=[ligand_template.ligand], remove_water=False
        )

        logging.debug("Superposing structure on kinase domain ...")
        ligand_template_structure = superpose_proteins(kinase_domain, ligand_template_structure)

        logging.debug("Adding hydrogens ...")
        oechem.OEPlaceHydrogens(ligand_template_structure)
        split_options = oechem.OESplitMolComplexOptions()

        logging.debug("Extracting ligand ...")
        ligand_template_structure = list(
            oechem.OEGetMolComplexComponents(
                ligand_template_structure, split_options, split_options.GetLigandFilter()
            )
        )[0]

        return ligand_template_structure
Beispiel #2
0
def SplitMolComplexIterAllSitesLigName(oms, mol, ligName):
    # @ <SNIPPET-SPLIT-MOL-COMPLEX-ITER-LIGNAME-AND-ALL-SITES>
    opt = oechem.OESplitMolComplexOptions(ligName)
    allSites = 0
    opt.ResetFilters(allSites)

    for frag in oechem.OEGetMolComplexComponents(mol, opt):
        # ...
        # @ </SNIPPET-SPLIT-MOL-COMPLEX-ITER-LIGNAME-AND-ALL-SITES>
        oechem.OEWriteMolecule(oms, frag)
Beispiel #3
0
def SplitMolComplexIterLigName(oms, mol, ligName):
    # the ligand has been identified by name

    # @ <SNIPPET-SPLIT-MOL-COMPLEX-ITER-LIGNAME>
    # for input molecule mol and string ligName ...
    opt = oechem.OESplitMolComplexOptions(ligName)

    for frag in oechem.OEGetMolComplexComponents(mol, opt):
        # ...
        # @ </SNIPPET-SPLIT-MOL-COMPLEX-ITER-LIGNAME>
        oechem.OEWriteMolecule(oms, frag)
Beispiel #4
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()
Beispiel #5
0
def SplitMolComplexIter(oms, mol):
    # limiting lig, prot and wat to just near the first binding site
    # (a very common pattern)

    # @ <SNIPPET-SPLIT-MOL-COMPLEX-ITER-SIMPLE>
    # for input molecule mol ...
    for frag in oechem.OEGetMolComplexComponents(mol):
        # ...
        # @ </SNIPPET-SPLIT-MOL-COMPLEX-ITER-SIMPLE>
        oechem.OEWriteMolecule(oms, frag)

    # other api points illustrated below

    # @ <SNIPPET-SPLIT-MOL-COMPLEX-SPLIT-COVALENT>
    opt = oechem.OESplitMolComplexOptions()
    opt.SetSplitCovalent()
    # @ </SNIPPET-SPLIT-MOL-COMPLEX-SPLIT-COVALENT>

    # @ <SNIPPET-SPLIT-MOL-FILTER-SURFACE-WATERS>
    site = 1
    surfaceWaters = True
    opt.ResetFilters(site, surfaceWaters)
    opt.SetMaxSurfaceWaterDist(8.0)
Beispiel #6
0
def SplitMolComplexIterFilter(oms, mol):
    # @ <SNIPPET-SPLIT-MOL-COMPLEX-ADD-COFACTOR>
    db = oechem.OEResidueCategoryData()
    db.AddToDB(oechem.OEResidueDatabaseCategory_Cofactor, "MTQ")

    cat = oechem.OEMolComplexCategorizer()
    cat.SetResidueCategoryData(db)

    opt = oechem.OESplitMolComplexOptions()
    opt.SetCategorizer(cat)
    # @ </SNIPPET-SPLIT-MOL-COMPLEX-ADD-COFACTOR>

    # @ <SNIPPET-SPLIT-MOL-COMPLEX-ITER-FILTER>
    # for input molecule mol and options opt ...
    for l in oechem.OEGetMolComplexComponents(mol, opt, opt.GetLigandFilter()):
        # ...
        # @ </SNIPPET-SPLIT-MOL-COMPLEX-ITER-FILTER>
        oechem.OEWriteMolecule(oms, l)

    # @ <SNIPPET-SPLIT-MOL-COMPLEX-EXAMPLE-FILTER>
    ofilter = opt.GetOtherFilter()
    # @ </SNIPPET-SPLIT-MOL-COMPLEX-EXAMPLE-FILTER>
    rs = oechem.OERoles()
    ofilter(rs)