示例#1
0
    def _get_design_unit(
        self,
        protein_structure: oechem.OEGraphMol,
        design_unit_identifier: str,
        electron_density: Union[oegrid.OESkewGrid, None] = None,
        ligand_name: Union[str, None] = None,
    ) -> oechem.OEDesignUnit:
        """
        Get an OpenEye design unit from a protein ligand complex.

        Parameters
        ----------
        protein_structure: oechem.OEGraphMol
            An OpenEye molecule holding the protein that might be in
            complex with a ligand.
        design_unit_identifier: str
            A unique identifier describing the design unit.
        electron_density: oegrid.OESkewGrid or None
            An OpenEye grid holding the electron density of the protein ligand complex.
        ligand_name: str or None
            Residue name of the ligand in complex with the protein structure.

        Returns
        -------
        : oechem.OEDesignUnit
            The design unit.
        """
        from openeye import oechem

        from ..modeling.OEModeling import prepare_complex, prepare_protein
        from ..utils import LocalFileStorage

        design_unit_path = LocalFileStorage.featurizer_result(
            self.__class__.__name__, f"{design_unit_identifier}_design_unit",
            "oedu")
        if design_unit_path.is_file():
            logging.debug("Reading design unit from file ...")
            design_unit = oechem.OEDesignUnit()
            oechem.OEReadDesignUnit(str(design_unit_path), design_unit)
        else:
            logging.debug("Generating design unit ...")
            if ligand_name is None:
                design_unit = prepare_protein(protein_structure,
                                              self.loop_db,
                                              cap_termini=False)
            else:
                design_unit = prepare_complex(
                    protein_structure,
                    electron_density,
                    self.loop_db,
                    ligand_name=ligand_name,
                    cap_termini=False,
                )
            logging.debug("Writing design unit ...")
            oechem.OEWriteDesignUnit(str(design_unit_path), design_unit)

        return design_unit
示例#2
0
    def deserialize(du_bytes):

        design_unit = oechem.OEDesignUnit()

        if not oechem.OEReadDesignUnitFromBytes(design_unit, du_bytes):
            raise ValueError(
                "It was not possible to deserialize the Design Unit")

        return design_unit
示例#3
0
    def _get_design_unit(
        self,
        complex_structure: oechem.OEGraphMol,
        design_unit_identifier: str,
        electron_density: Union[oegrid.OESkewGrid, None],
    ) -> oechem.OEDesignUnit:
        """
        Get an OpenEye design unit from a protein ligand complex.

        Parameters
        ----------
        complex_structure: oechem.OEGraphMol
            An OpenEye molecule holding the protein in complex with a ligand.
        design_unit_identifier: str
            A unique identifier describing the design unit.
        electron_density: oegrid.OESkewGrid or None
            An OpenEye grid holding the electron density of the protein ligand complex.

        Returns
        -------
        : oechem.OEDesignUnit
            The design unit.
        """
        from openeye import oechem

        from ..modeling.OEModeling import prepare_complex
        from ..utils import LocalFileStorage

        design_unit_path = LocalFileStorage.featurizer_result(
            self.__class__.__name__, f"{design_unit_identifier}_design_unit",
            "oedu")  # TODO: the file name needs to be unique
        if design_unit_path.is_file():
            logging.debug("Reading design unit from file ...")
            design_unit = oechem.OEDesignUnit()
            oechem.OEReadDesignUnit(str(design_unit_path), design_unit)
        else:
            logging.debug("Generating design unit ...")
            design_unit = prepare_complex(complex_structure, electron_density,
                                          self.loop_db)
            logging.debug("Writing design unit ...")
            oechem.OEWriteDesignUnit(str(design_unit_path), design_unit)

        return design_unit
示例#4
0
# NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE AND NONINFRINGEMENT. In no event shall OpenEye be
# liable for any damages or liability in connection with the Sample Code
# or its use.

import sys
from openeye import oechem
from openeye import oedepict
from openeye import oegrapheme

###############################################################
# USED TO GENERATE CODE SNIPPETS FOR THE GRAPHEME DOCUMENTATION
###############################################################

if len(sys.argv) != 2:
    oechem.OEThrow.Usage("%s <design unit>" % sys.argv[0])

filename = sys.argv[1]
# @ <SNIPPET-DRAW-IRIDIUM-DATA>
du = oechem.OEDesignUnit()
if not oechem.OEReadDesignUnit(filename, du):
    oechem.OEThrow.Fatal("Cannot read design unit!")

image = oedepict.OEImage(250, 250)

oegrapheme.OEDrawIridiumData(image, du)
oedepict.OEDrawBorder(image, oedepict.OELightGreyPen)
oedepict.OEWriteImage("DrawIridiumData.svg", image)
# @ </SNIPPET-DRAW-IRIDIUM-DATA>
oedepict.OEWriteImage("DrawIridiumData.pdf", image)
示例#5
0
def read_design_unit(fname):
    du = oechem.OEDesignUnit()
    oechem.OEReadDesignUnit(fname, du)
    return du
示例#6
0
    oechem.OEPlaceHydrogens(mol)
    return mol


def read_design_unit(fname):
    du = oechem.OEDesignUnit()
    oechem.OEReadDesignUnit(fname, du)
    return du


if len(sys.argv) != 3:
    oechem.OEThrow.Usage("{} <du file> <lig file>".format(sys.argv[0]))

du = read_design_unit(sys.argv[1])
lig = read_graph_mol(sys.argv[2])

# @ <SNIPPET-OEUpdateDesignUnit>
if not oechem.OEUpdateDesignUnit(du, lig,
                                 oechem.OEDesignUnitComponents_Ligand):
    oechem.OEThrow.Fatal(
        "Error: Could not add the ligand to the OEDesignUnit.")
# @ </SNIPPET-OEUpdateDesignUnit>

# @ <SNIPPET-OESubsetDesignUnit>
ligProtDU = oechem.OEDesignUnit()
components = oechem.OEDesignUnitComponents_Protein | oechem.OEDesignUnitComponents_Ligand
if not oechem.OESubsetDesignUnit(ligProtDU, du, components):
    oechem.OEThrow.Fatal(
        "Error: Could create a subset of the reference OEDesignUnit.")
# @ </SNIPPET-OESubsetDesignUnit>