コード例 #1
0
ファイル: OEDocking.py プロジェクト: sukritsingh/kinoml
def create_box_receptor(
    protein: oechem.OEGraphMol,
    box_dimensions: Tuple[float, float, float, float, float, float],
) -> oechem.OEGraphMol:
    """
    Create a box receptor for docking.
    Parameters
    ----------
    protein: oechem.OEGraphMol
        An OpenEye molecule holding a prepared protein structure.
    box_dimensions: tuple of float
        The box dimensions in the order of xmax, ymax, zmax, xmin, ymin, zmin.
    Returns
    -------
    receptor: oechem.OEGraphMol
        An OpenEye molecule holding a receptor with defined binding site via box dimensions.
    """
    from openeye import oedocking

    # create receptor
    box = oedocking.OEBox(*box_dimensions)
    receptor = oechem.OEGraphMol()
    oedocking.OEMakeReceptor(receptor, protein, box)

    return receptor
コード例 #2
0
def main(argv=[__name__]):
    path = "receptor_pdbs/*.pdb"  #input: pdbs from clustering
    files = glob.glob(path)
    for i in files:
        centroid_number = i[-5:-4]
        imstr = oechem.oemolistream(i)
        proteinStructure = oechem.OEGraphMol()
        oechem.OEReadMolecule(imstr, proteinStructure)
        coordinates_dictionary = oechem.OEMolBase.GetCoords(proteinStructure)
        x_coord = []
        y_coord = []
        z_coord = []
        for key in coordinates_dictionary:
            x = coordinates_dictionary[key][0]
            y = coordinates_dictionary[key][1]
            z = coordinates_dictionary[key][2]
            x_coord.append(x)
            y_coord.append(y)
            z_coord.append(z)
        x_max = max(x_coord)
        x_min = min(x_coord)
        y_max = max(y_coord)
        y_min = min(y_coord)
        z_max = max(z_coord)
        z_min = min(z_coord)
        box = oedocking.OEBox(
            x_max, y_max, z_max, x_min, y_min,
            z_min)  #Box set using max and min coordinates of entire protein
        receptor = oechem.OEGraphMol()
        oedocking.OEMakeReceptor(receptor, proteinStructure, box)
        oedocking.OEWriteReceptorFile(receptor, "receptor_oebs/receptor" +
                                      str(centroid_number) +
                                      ".oeb")  #output: receptor oebs
    return 0
コード例 #3
0
def create_receptor(protein_pdb_path, box):
    """Create an OpenEye receptor from a PDB file.

    Parameters
    ----------
    protein_pdb_path : str
        Path to the receptor PDB file.
    box : 1x6 array of float
        The minimum and maximum values of the coordinates of the box
        representing the binding site [xmin, ymin, zmin, xmax, ymax, zmax].

    Returns
    -------
    receptor : openeye.oedocking.OEReceptor
        The OpenEye receptor object.

    """
    input_mol_stream = oechem.oemolistream(protein_pdb_path)
    protein_oemol = oechem.OEGraphMol()
    oechem.OEReadMolecule(input_mol_stream, protein_oemol)

    box = oedocking.OEBox(*box)
    receptor = oechem.OEGraphMol()
    oedocking.OEMakeReceptor(receptor, protein_oemol, box)

    return receptor
コード例 #4
0
def create_box_receptor(protein,
                        xmax,
                        ymax,
                        zmax,
                        xmin,
                        ymin,
                        zmin,
                        receptor_save_path=None):
    """
    Create a box receptor for docking.

    Parameters
    ----------
    protein: oechem.OEGraphMol
        An oechem.OEGraphMol object holding a prepared protein structure.

    xmax: float or int
        Maximal number in x direction.

    ymax: float or int
        Maximal number in y direction.

    zmax: float or int
        Maximal number in z direction.

    xmin: float or int
        Minimal number in x direction.

    ymin: float or int
        Minimal number in x direction.

    zmin: float or int
        Minimal number in z direction.

    receptor_save_path: str
        File path for saving created receptor. If receptor_save_path is not provided, receptor will not be saved.

    Returns
    -------
    receptor: oechem.OEGraphMol
        An oechem.OEGraphMol object holding a receptor with defined binding site via box dimensions.
    """
    # Standard libraries
    import pathlib

    # External libraries
    from openeye import oechem, oedocking

    # create receptor
    box = oedocking.OEBox(xmax, ymax, zmax, xmin, ymin, zmin)
    receptor = oechem.OEGraphMol()
    oedocking.OEMakeReceptor(receptor, protein, box)

    # save receptor
    if receptor_save_path is not None:
        oedocking.OEWriteReceptorFile(
            receptor, str(pathlib.Path(receptor_save_path).absolute()))

    return receptor
コード例 #5
0
def create_receptor(output_name, pdb_file, bp_min, bp_max):
    check_oeb = output_name
    proteinStructure = oechem.OEGraphMol()
    ifs = oechem.oemolistream(pdb_file)
    ifs.SetFormat(oechem.OEFormat_PDB)
    oechem.OEReadMolecule(ifs, proteinStructure)

    box = oedocking.OEBox(*bp_max, *bp_min)

    receptor = oechem.OEGraphMol()
    s = oedocking.OEMakeReceptor(receptor, proteinStructure, box)
    oedocking.OEWriteReceptorFile(receptor, check_oeb)
コード例 #6
0
    def __init__(self, pdb_file, xmax, ymax, zmax, xmin, ymin, zmin):
        self.receptor = oechem.OEGraphMol()
        self.scorers = oedocking.OEScore(oedocking.OEScoreType_Chemgauss4)

        proteinStructure = oechem.OEGraphMol()
        ifs = oechem.oemolistream(pdb_file)
        ifs.SetFormat(oechem.OEFormat_PDB)
        oechem.OEReadMolecule(ifs, proteinStructure)

        box = oedocking.OEBox(xmax, ymax, zmax, xmin, ymin, zmin)

        receptor = oechem.OEGraphMol()
        s = oedocking.OEMakeReceptor(receptor, proteinStructure, box)
        self.scorers.Initialize(receptor)
コード例 #7
0
ファイル: ScoreBox.py プロジェクト: qjstuart/gitflow-exercise
def main(argv=[__name__]):
    if len(argv) != 3:
        oechem.OEThrow.Usage("%s <receptor> <ligand>" % argv[0])

    # @ <SNIPPET-SCORE-BOX-1>
    protein = oechem.OEGraphMol()
    imstr = oechem.oemolistream(argv[1])
    oechem.OEReadMolecule(imstr, protein)

    pose = oechem.OEGraphMol()
    imstr.open(argv[2])
    oechem.OEReadMolecule(imstr, pose)

    addbox = 4.0
    box = oedocking.OEBox()
    oedocking.OESetupBox(box, pose, addbox)

    oescore = oedocking.OEScore()
    oescore.Initialize(protein, box)
コード例 #8
0
    def __init__(self, pdb_file, xmax, ymax, zmax, xmin, ymin, zmin):
        self.receptor = oechem.OEGraphMol()
        self.scorers = {
            'Shapegauss': oedocking.OEScore(oedocking.OEScoreType_Shapegauss),
            'Chemscore': oedocking.OEScore(oedocking.OEScoreType_Chemscore),
            'Chemgauss': oedocking.OEScore(oedocking.OEScoreType_Chemgauss),
            'Chemgauss3': oedocking.OEScore(oedocking.OEScoreType_Chemgauss3),
            'Chemgauss4': oedocking.OEScore(oedocking.OEScoreType_Chemgauss4),
        }

        proteinStructure = oechem.OEGraphMol()
        ifs = oechem.oemolistream(pdb_file)
        ifs.SetFormat(oechem.OEFormat_PDB)
        oechem.OEReadMolecule(ifs, proteinStructure)

        box = oedocking.OEBox(xmax, ymax, zmax, xmin, ymin, zmin)

        receptor = oechem.OEGraphMol()
        s = oedocking.OEMakeReceptor(receptor, proteinStructure, box)
        for _, score in self.scorers.items():
            assert (s != False)
            score.Initialize(receptor)
コード例 #9
0
def make_receptor( pdb):
    from openeye import oedocking, oechem
    import os.path

    file_name = str(os.path.basename(pdb))
    check_oeb = conf['cache'] + file_name.split(".")[0] + ".oeb"
    if os.path.isfile(check_oeb):
        g = oechem.OEGraphMol()
        oedocking.OEReadReceptorFile(g, check_oeb)
        return g
    else:
        proteinStructure = oechem.OEGraphMol()
        ifs = oechem.oemolistream(pdb)
        ifs.SetFormat(oechem.OEFormat_PDB)
        oechem.OEReadMolecule(ifs, proteinStructure)

        box = oedocking.OEBox(*conf['bp_max'], *conf['bp_min'])

        receptor = oechem.OEGraphMol()
        s = oedocking.OEMakeReceptor(receptor, proteinStructure, box)
        oedocking.OEWriteReceptorFile(receptor, check_oeb)
        assert (s != False)
        return receptor
コード例 #10
0
def main(argv=[__name__]):
    if len(sys.argv) != 8:
        oechem.OEThrow.Usage("MakeReceptorFromBox.py \
                              <protein> <xmax> <ymax> <zmax> <xmin> <ymin> <zmin>"
                             )

    xmax = float(sys.argv[2])
    ymax = float(sys.argv[3])
    zmax = float(sys.argv[4])
    xmin = float(sys.argv[5])
    ymin = float(sys.argv[6])
    zmin = float(sys.argv[7])

    # @ <SNIPPET-MAKE-RECEPTOR-WITH-BOX-1>
    imstr = oechem.oemolistream(sys.argv[1])
    proteinStructure = oechem.OEGraphMol()
    oechem.OEReadMolecule(imstr, proteinStructure)

    box = oedocking.OEBox(xmax, ymax, zmax, xmin, ymin, zmin)
    receptor = oechem.OEGraphMol()
    oedocking.OEMakeReceptor(receptor, proteinStructure, box)
    # @ </SNIPPET-MAKE-RECEPTOR-WITH-BOX-1>

    oedocking.OEWriteReceptorFile(receptor, "receptor.oeb.gz")
コード例 #11
0
def PrepareReceptor(pdb,padding=4,outpath=""):
    """
    Prepares a receptor from a pdb with a crystalized ligand
    Padding controls the docking region.
    If outpath is given, PrepareReceptor will write an openeye binary (oeb) of the receptor structure. This will be faster than rebuilding the receptor every time.
    """
    print("STOP CALLING THIS FUNCTION")
    exit()
    com = oechem.OEGraphMol()
    ifs = oechem.oemolistream()
    if ifs.open(pdb):
        oechem.OEReadPDBFile(ifs, com)
        ifs.close()

    """
    Sorry, this requires some explanation. Openeye wasn't recognizing the previously docked ligand, so I tried to find other ways.
    The next blocks of code take our system and split it based on its connected components, for which its REQUIRED that our protein
      only has a single chain. It assumes that the last component is the ligand. It then creates the ligand (lig) and protein (prot)
      as separate molecules. Next, it finds the minimum and maximum 3D coordinates of the current ligand and produces a box around
      it with the specified padding. Finally it uses this box to create a 'receptor' object into which ligands can be docked.
    Only the receptor is returned.
    Openeye's docking shouldn't be this involved, but I couldn't get it to run the typical 'hybrid' docking without error.
    """
    oechem.OEDetermineConnectivity(com)
    nparts, connect = oechem.OEDetermineComponents(com)
    if(nparts != 2):
        print("ERR in dock_conf::prepareReceptor. PDB doesn't have 2 connected components")
        exit()
        ## TODO: What is a good way to catch errors?
    # Get apo
    pred = oechem.OEPartPredAtom(connect)
    pred.SelectPart(nparts)
    lig = oechem.OEGraphMol()
    oechem.OESubsetMol(lig, com, pred)
    print(lig)
    
    # Get protein
    pred = oechem.OEPartPredAtom(connect)
    pred.SelectPart(1)
    prot = oechem.OEGraphMol()
    oechem.OESubsetMol(prot, com, pred)
    
    # Get box dimensions by iterating over ligand
    x_min = y_min = z_min = float('inf')
    x_max = y_max = z_max = -float('inf')
    crd = lig.GetCoords()
    print("CRD", crd)
    for atm in crd:
        x,y,z = crd[atm]
        if x < x_min:
            x_min = x
        if y < y_min:
            y_min = y
        if z < z_min:
            z_min = z
        if x > x_max:
            x_max = x
        if y > y_max:
            y_max = y
        if z > z_max:
            z_max = z
    x_min -= padding
    y_min -= padding
    z_min -= padding
    x_max += padding
    y_max += padding
    z_max += padding
    print(x_min,y_min,z_max, y_max)
    # Now prepare the receptor
    receptor = oechem.OEGraphMol()
    box = oedocking.OEBox()
    box.Setup(x_max, y_max, z_max, x_min, y_min, z_min)
    oedocking.OEMakeReceptor(receptor, prot, box)
    
    if not outpath == "":
        oedocking.OEWriteReceptorFile(receptor,f'{outpath}/receptor.oeb')
    return receptor