def frag_to_smiles(frags, mol): """ Convert fragments (AtomBondSet) to smiles string Parameters ---------- frags mol Returns ------- smiles: list of smiles strings """ smiles = {} for frag in frags: fragatompred = oechem.OEIsAtomMember(frag.GetAtoms()) fragbondpred = oechem.OEIsBondMember(frag.GetBonds()) fragment = oechem.OEGraphMol() adjustHCount = True oechem.OESubsetMol(fragment, mol, fragatompred, fragbondpred, adjustHCount) s = oechem.OECreateIsoSmiString(fragment) if s not in smiles: smiles[s] = [] smiles[s].append(frag) return smiles
def _sort_by_rotbond(ifs, outdir): """ Parameters ---------- ifs: str absolute path to molecule database outdir: str absolute path to where output files should be written. """ nrotors_map = {} moldb = oechem.OEMolDatabase(ifs) mol = oechem.OEGraphMol() for idx in range(moldb.GetMaxMolIdx()): if moldb.GetMolecule(mol, idx): nrotors = sum([bond.IsRotor() for bond in mol.GetBonds()]) if nrotors not in nrotors_map: nrotors_map[nrotors] = [] nrotors_map[nrotors].append(idx) # Write out a separate database for each num rotors for nrotor in nrotors_map: size = len(nrotors_map[nrotor]) ofname = os.path.join(outdir, 'nrotor_{}.smi'.format(nrotor)) ofs = utils.new_output_stream(ofname) utils.write_oedatabase(moldb, ofs, nrotors_map[nrotor], size)
def main(args): if len(args) != 3: oechem.OEThrow.Usage("%s <input> <output>" % args[0]) ifs = oechem.oemolistream() if not ifs.open(args[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % args[1]) ofs = oechem.oemolostream() if not ofs.open(args[2]): oechem.OEThrow.Fatal("Unable to open %s for writing" % args[2]) mol = oechem.OEMol() oechem.OEReadMolecule(ifs, mol) opts = oeszybki.OEFreeFormSolvOptions() opts.SetIonicState(oeszybki.OEFreeFormIonicState_Uncharged) res = oeszybki.OEFreeFormSolvResults() omol = oechem.OEGraphMol() if not oeszybki.OEEstimateSolvFreeEnergy(res, omol, mol, opts): oechem.OEThrow.Error( "Failed to calculate solvation free energy for molecule %s" % mol.GetTitle()) solvenergy = res.GetSolvationFreeEnergy() oechem.OEThrow.Info( "Solvation free energy for compound %s is %6.2f kcal/mol" % (mol.GetTitle(), solvenergy)) oechem.OEWriteMolecule(ofs, omol) return 0
def GetFragments(mol, minbonds, maxbonds): from openeye import oegraphsim frags = [] fptype = oegraphsim.OEGetFPType("Tree,ver=2.0.0,size=4096,bonds=%d-%d,atype=AtmNum,btype=Order" % (minbonds, maxbonds)) for abset in oegraphsim.OEGetFPCoverage(mol, fptype, True): fragatompred = oechem.OEIsAtomMember(abset.GetAtoms()) frag = oechem.OEGraphMol() adjustHCount = True oechem.OESubsetMol(frag, mol, fragatompred, adjustHCount) oechem.OEFindRingAtomsAndBonds(frag) frags.append(oechem.OEGraphMol(frag)) return frags
def get_modified_inchi_key(mol, atoms): """ Generates InChIKey for the input molecule. Passed atoms of the molecule are mutated (atomic number changed) based on the mapping defined in the function. @param mol: @param atoms: @type mol: OEGraphMol @type atoms: list[OEAtombase] @return: str """ copy_mol = oechem.OEGraphMol(mol) atom_map = { oechem.OEElemNo_C: oechem.OEElemNo_Pb, oechem.OEElemNo_N: oechem.OEElemNo_Bi, oechem.OEElemNo_O: oechem.OEElemNo_Po, oechem.OEElemNo_F: oechem.OEElemNo_At, oechem.OEElemNo_S: oechem.OEElemNo_Te, oechem.OEElemNo_Cl: oechem.OEElemNo_I, oechem.OEElemNo_P: oechem.OEElemNo_Sb, oechem.OEElemNo_Br: 117, oechem.OEElemNo_I: 118, } for ref_atom in atoms: copy_atom = copy_mol.GetAtom(oechem.OEHasAtomIdx(ref_atom.GetIdx())) if copy_atom is None: raise Exception("Null atom found") copy_atom.SetAtomicNum(atom_map[copy_atom.GetAtomicNum()]) return oechem.OECreateInChIKey(copy_mol)
def main(argv=[__name__]): if len(argv) != 3: oechem.OEThrow.Usage("%s <molfile.pdb> <out.srf>" % argv[0]) mol = oechem.OEGraphMol() ifs = oechem.oemolistream(argv[1]) oechem.OEReadMolecule(ifs, mol) if not oechem.OEHasResidues(mol): oechem.OEPerceiveResidues(mol, oechem.OEPreserveResInfo_All) serials = {} for atom in mol.GetAtoms(): res = oechem.OEAtomGetResidue(atom) serials[res.GetSerialNumber()] = atom outsurf = oespicoli.OESurface() center = oechem.OEFloatArray(3) for line in open(argv[1]): if line.startswith("ANISOU"): serno, factors = ParseFactors(line) if serno in serials: mol.GetCoords(serials[serno], center) surf = GetEllipsoidalSurface(center, factors) oespicoli.OEAddSurfaces(outsurf, surf) oespicoli.OEWriteSurface(argv[2], outsurf)
def _from_csv(): df = pd.read_csv(path) df_smiles = df.iloc[:, smiles_col] df_y = df.iloc[:, y_cols] if toolkit == "rdkit": from rdkit import Chem mols = [Chem.MolFromSmiles(smiles) for smiles in df_smiles] gs = [esp.HomogeneousGraph(mol) for mol in mols] elif toolkit == "openeye": from openeye import oechem mols = [ oechem.OESmilesToMol(oechem.OEGraphMol(), smiles) for smiles in df_smiles ] gs = [esp.HomogeneousGraph(mol) for mol in mols] ds = list(zip(gs, list(torch.tensor(df_y.values)))) random.seed(seed) random.shuffle(ds) return ds
def create_hint_receptor( protein: oechem.OEMolBase, hintx: Union[float, int], hinty: Union[float, int], hintz: Union[float, int], ) -> oechem.OEGraphMol: """ Create a hint receptor for docking. Parameters ---------- protein: oechem.OEMolBase An OpenEye molecule holding a prepared protein structure. hintx: float or int A number defining the hint x coordinate. hinty: float or int A number defining the hint y coordinate. hintz: float or int A number defining the hint z coordinate. Returns ------- receptor: oechem.OEGraphMol An OpenEye molecule holding a receptor with defined binding site via hint coordinates. """ from openeye import oedocking # create receptor receptor = oechem.OEGraphMol() oedocking.OEMakeReceptor(receptor, protein, hintx, hinty, hintz) return receptor
def main(argv=[__name__]): if len(argv) != 3: oechem.OEThrow.Usage("%s <reffile> <fitfile>" % argv[0]) reffs = oechem.oemolistream(argv[1]) fitfs = oechem.oemolistream(argv[2]) refmol = oechem.OEGraphMol() oechem.OEReadMolecule(reffs, refmol) # Prepare reference molecule for calculation # With default options this will remove any explicit hydrogens present prep = oeshape.OEOverlapPrep() prep.Prep(refmol) # Get appropriate function to calculate exact shape shapeFunc = oeshape.OEExactShapeFunc() shapeFunc.SetupRef(refmol) res = oeshape.OEOverlapResults() for fitmol in fitfs.GetOEGraphMols(): prep.Prep(fitmol) shapeFunc.Overlap(fitmol, res) print("title: %s exact tanimoto = %.2f" % (fitmol.GetTitle(), res.GetTanimoto()))
def test_smirff_energies_vs_parmatfrosst(verbose=False): """Test evaluation of energies from parm@frosst ffxml files versus energies of equivalent systems.""" from openeye import oechem prefix = 'AlkEthOH_' molecules = ['r118', 'r12', 'c1161', 'r0', 'c100', 'c38', 'c1266'] # Loop over molecules, load OEMols and prep for comparison/do comparison for molnm in molecules: f_prefix = os.path.join('molecules', prefix + molnm) mol2file = get_data_filename(f_prefix + '.mol2') prmtop = get_data_filename(f_prefix + '.top') crd = get_data_filename(f_prefix + '.crd') # Load special parm@frosst with parm99/parm@frosst bugs re-added for testing forcefield = ForceField( get_data_filename('forcefield/Frosst_AlkEtOH_parmAtFrosst.ffxml')) # Load OEMol mol = oechem.OEGraphMol() ifs = oechem.oemolistream(mol2file) flavor = oechem.OEIFlavor_Generic_Default | oechem.OEIFlavor_MOL2_Default | oechem.OEIFlavor_MOL2_Forcefield ifs.SetFlavor(oechem.OEFormat_MOL2, flavor) oechem.OEReadMolecule(ifs, mol) oechem.OETriposAtomNames(mol) # Do comparison results = compare_molecule_energies(prmtop, crd, forcefield, mol, verbose=verbose)
def main(argv=[__name__]): if len(argv) != 2: oechem.OEThrow.Usage("%s <molfile>" % argv[0]) epsin = 1.0 zap = oezap.OEZap() zap.SetInnerDielectric(epsin) zap.SetGridSpacing(0.5) area = oezap.OEArea() PrintHeader() mol = oechem.OEGraphMol() ifs = oechem.oemolistream() if not ifs.open(argv[1]): oechem.OEThrow.Fatal("Unable to open %s for reading" % argv[1]) while oechem.OEReadMolecule(ifs, mol): oechem.OEAssignBondiVdWRadii(mol) oechem.OEMMFFAtomTypes(mol) oechem.OEMMFF94PartialCharges(mol) zap.SetMolecule(mol) solv = zap.CalcSolvationEnergy() aval = area.GetArea(mol) coul = oezap.OECoulombicSelfEnergy(mol, epsin) PrintLine(mol.GetTitle(), solv, aval, coul) return 0
def annotate_with_assay_data(mols, assay_data_filename): """ Annotate the set of molecules with activity data using SD tags Parameters ---------- mols : list of OEMol List of molecules to annotate assay_data_filename Filename of CSV file containing activity data """ # Load assay data assayed_molecules = dict() with oechem.oemolistream(assay_data_filename) as ifs: for mol in ifs.GetOEGraphMols(): assayed_molecules[mol.GetTitle()] = oechem.OEGraphMol(mol) logging.info(f'Loaded data for {len(assayed_molecules)} assayed molecules') # Copy all SDData from assayed molecules that match title nmols_with_assay_data = 0 for mol in mols: if mol.GetTitle() in assayed_molecules: assayed_molecule = assayed_molecules[mol.GetTitle()] oechem.OECopySDData(mol, assayed_molecule) nmols_with_assay_data += 1 logging.info(f'Found assay data for {nmols_with_assay_data} / {len(mols)} molecules')
def createMolecule(self, mol, molTitle): ''' Get a OE residue, return a OE molecule ''' # Creating a new Res GraphMol newMol = oechem.OEGraphMol() newMol.SetTitle(molTitle) # Create every atom found in the OEHierResidue for atom in mol.GetAtoms(): newMol.NewAtom(atom) #---------------------------------------------# # Recreate the molecule from atom coordinates # #---------------------------------------------# # Using OpenEye's charge model. Works on molecules with fully specified # hydrogen counts. Charge determined based on atom valence. oechem.OEDetermineConnectivity(newMol) oechem.OEFindRingAtomsAndBonds(newMol) oechem.OEPerceiveBondOrders(newMol) oechem.OEAssignImplicitHydrogens(newMol) oechem.OEAssignFormalCharges(newMol) # Other things to consider # Set atom radius #oechem.OEAssignBondiVdWRadii(newMol) #oechem.OEAssignPartialCharges(newMol, # oechem.OECharges_None, # False, # False) return newMol
def __call__(self, item : str): ligand = oechem.OEGraphMol() ligand_name = oechem.oemolistream() ligand_name.openstring(item) oechem.OEReadPDBFile(ligand_name, ligand) return [scorer.ScoreLigand(ligand) for scorer in self.scorers]
def main(argv=[__name__]): itf = oechem.OEInterface(InterfaceData, argv) isomeric = itf.GetBool("-isomeric") kekule = itf.GetBool("-kekule") from3d = itf.GetBool("-from3d") if from3d: isomeric = True ifs = oechem.oemolistream() ifile = itf.GetString("-i") if not ifs.open(ifile): oechem.OEThrow.Fatal("Unable to open %s for reading" % ifile) if itf.HasString("-o"): ofile = itf.GetString("-o") try: ofs = open(ofile, 'w') except Exception: oechem.OEThrow.Fatal("Unable to open %s for writing" % ofile) else: ofs = sys.stdout mol = oechem.OEGraphMol() while oechem.OEReadMolecule(ifs, mol): if from3d: oechem.OE3DToInternalStereo(mol) smi = CanSmi(mol, isomeric, kekule) if mol.GetTitle(): smi += (" %s" % mol.GetTitle()) ofs.write("%s\n" % smi)
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 get_ani_mol(coordinates, species, smiles): """ Given smiles string and list of elements as reference, get the RDKit mol with xyz. """ mol = oechem.OEGraphMol() for symbol in species: mol.NewAtom(getattr(oechem, 'OEElemNo_' + symbol)) mol.SetCoords(coordinates.reshape([-1])) mol.SetDimension(3) oechem.OEDetermineConnectivity(mol) oechem.OEFindRingAtomsAndBonds(mol) oechem.OEPerceiveBondOrders(mol) smiles_can = oechem.OECreateCanSmiString(mol) ims = oechem.oemolistream() ims.SetFormat(oechem.OEFormat_SMI) ims.openstring(smiles) mol_ref = next(ims.GetOEMols()) smiles_ref = oechem.OECreateCanSmiString(mol_ref) assert smiles_can == smiles_ref g = hgfp.graph.from_oemol(mol, use_fp=True) return g, mol
def png_atoms_labeled(smiles, fname): """Write out png file of molecule with atoms labeled with their index. Parameters ---------- smiles: str SMILES fname: str absolute path and filename for png """ mol = oechem.OEGraphMol() oechem.OESmilesToMol(mol, smiles) oedepict.OEPrepareDepiction(mol) width, height = 300, 200 opts = oedepict.OE2DMolDisplayOptions(width, height, oedepict.OEScale_AutoScale) opts.SetAtomPropertyFunctor(oedepict.OEDisplayAtomIdx()) opts.SetAtomPropLabelFont(oedepict.OEFont(oechem.OEDarkGreen)) disp = oedepict.OE2DMolDisplay(mol, opts) return oedepict.OERenderMolecule(fname, disp)
def prepare(self): """[summary] # OESuppressHydrogens(self.__oeMol, retainPolar=False,retainStereo=True,retainIsotope=True) oechem.OESuppressHydrogens(self.__oeMol) """ self.__setupImage() for idx, cell in enumerate(self.__grid.GetCells()): ccId, oeMol, title = self._molTitleList[idx] logger.debug("Preparing %s %r", ccId, title) # if self._params["suppressHydrogens"]: # mol = oeMol.getGraphMolSuppressH() # OESuppressHydrogens(self.__oeMol, retainPolar=False,retainStereo=True,retainIsotope=True) mol = oechem.OESuppressHydrogens(oechem.OEGraphMol(oeMol)) else: mol = oeMol # if self.__useTitle and title: mol.SetTitle(title) self._opts.SetTitleHeight(5.0) else: mol.SetTitle("") # # oedepict.OEPrepareDepiction(mol) self._opts.SetDimensions(cell.GetWidth(), cell.GetHeight(), oedepict.OEScale_AutoScale) self._assignDisplayOptions() disp = oedepict.OE2DMolDisplay(mol, self._opts) oedepict.OERenderMolecule(cell, disp) if self._params["cellBorders"]: oedepict.OEDrawBorder(cell, oedepict.OEPen(oedepict.OEBlackPen))
def read_receptor(fragid, assembly_state, protonation_state): """ Read the receptor for the given fragment Parameters ---------- fragid : str The XChem fragment ID assembly_state : str Assembly state ['monomer', 'dimer'] protonation_state : str Protonation state ['neutral', 'charged'] Returns ------- receptor : OEReceptor The receptor """ from openeye import oechem receptor = oechem.OEGraphMol() suffix = '' if protonation_state=='neutral' else '-thiolate' receptor_filename = f'../../receptors/{assembly_state}/Mpro-{fragment}_0A_bound-receptor{suffix}.oeb.gz' from openeye import oedocking oedocking.OEReadReceptorFile(receptor, receptor_filename) logging.info(f' Receptor has {receptor.NumAtoms()} atoms.') return receptor
def create_box_receptor( protein: oechem.OEMolBase, box_dimensions: Tuple[float, float, float, float, float, float], ) -> oechem.OEGraphMol: """ Create a box receptor for docking. Parameters ---------- protein: oechem.OEMolBase 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
def RMSD(ref_mol2, query_mol2): """ From one input reference molecule and one input query molecule, the RMSD is computed and returned. Parameters --------- ref_mol2: str - mol2 file of the reference force field query_mol2: str - mol2 file of the query force field Returns ------- rms: float - RMSD in Angstroms """ # open reference molecule ifsRef = oechem.oemolistream(ref_mol2) print("Opening reference molecule:", ref_mol2) # check if the file exist if not ifsRef.open(ref_mol2): print("Unable to locate %s. Skipping." % ref_mol2.split('/')[-1]) # open query molecule #queryFile = ("/work/cluster/nthi/ForceField-Comparison/%s/%s/%s" % (homeDir, ffList, fName) ) print("Opening query molecule: ", query_mol2) if os.path.exists(query_mol2): ifsQuery = oechem.oemolistream(query_mol2) # set flavor for the input file flavor = oechem.OEIFlavor_Generic_Default | oechem.OEIFlavor_MOL2_Default | oechem.OEIFlavor_MOL2_Forcefield ifsRef.SetFlavor(oechem.OEFormat_MOL2, flavor) ifsQuery.SetFlavor(oechem.OEFormat_MOL2, flavor) # create "blank" object rmol = oechem.OEGraphMol() qmol = oechem.OEGraphMol() # load molecule from files oechem.OEReadMolecule(ifsRef, rmol) oechem.OEReadMolecule(ifsQuery, qmol) # calculate rmsd setting automorph, heavyOnly, and overlay to True rms = oechem.OERMSD(rmol, qmol, True, True, True) else: rms = -2 return rms
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
def DockConf(pdb_file, mol, MAX_POSES = 5): receptor = oechem.OEGraphMol() oedocking.OEReadReceptorFile(receptor, pdb_file) dock = oedocking.OEDock() dock.Initialize(receptor) lig = oechem.OEMol() err = dock.DockMultiConformerMolecule(lig,mol,MAX_POSES) return dock, lig, receptor
def load_oe_graph_mol(mol2_filepath): """Load a single OpenEye molecule from a mol2 file.""" # OpenEye flavors to use when loading mol2 files. flavor = oechem.OEIFlavor_Generic_Default | oechem.OEIFlavor_MOL2_Default | oechem.OEIFlavor_MOL2_Forcefield ifs = oechem.oemolistream(mol2_filepath) ifs.SetFlavor(oechem.OEFormat_MOL2, flavor) mol = oechem.OEGraphMol() molecules = [] while oechem.OEReadMolecule(ifs, mol): oechem.OETriposAtomNames(mol) molecules.append(oechem.OEGraphMol(mol)) # The script assumes we have only 1 molecule per mol2 file. assert len(molecules) == 1 return molecules[0]
def PrepareReceptorFromBinary(filename): """ If a receptor.oeb has been created, use this version. If not, run 'PrepareReceptor' and a receptor.oeb will be created. """ receptor = oechem.OEGraphMol() oedocking.OEReadReceptorFile(receptor,filename) return receptor
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 receptor_from_file(receptor_filename): receptor = oechem.OEGraphMol() if not oedocking.OEReadReceptorFile(receptor, receptor_filename): oechem.OEThrow.Fatal("Unable to read receptor") if not oedocking.OEReceptorHasBoundLigand(receptor): raise Exception("Receptor does not have bound ligand") return receptor
def from_smiles(smi:str) -> Mol: """ Create a molecule object from a smiles """ mol = oechem.OEGraphMol() oechem.OESmilesToMol(mol, smi) return Mol(mol)
def main(argv=[__name__]): if len(argv) not in [3, 4]: oechem.OEThrow.Usage( "%s <reference protein PDB> <fit protein PDB> [nowrite]" % argv[0]) # noqa do_write = True if len(argv) == 4: if argv[3] != "nowrite": oechem.OEThrow.Warning("%s is not a valid option.\n" % argv[3]) sys.exit(1) else: do_write = False ref_prot_file = argv[1] fit_prot_file = argv[2] ref_prot = oechem.OEGraphMol() fit_prot = oechem.OEGraphMol() ref_success = ReadProteinFromPDB(ref_prot_file, ref_prot) fit_success = ReadProteinFromPDB(fit_prot_file, fit_prot) if (not ref_success) or (not fit_success): oechem.OEThrow.Fatal("Unable to protein(s) from PDB file.") superposition = oespruce.OESecondaryStructureSuperposition( ref_prot, fit_prot) # noqa tanimoto = superposition.GetTanimoto() superposition.Transform(fit_prot) pdb_ext = ".pdb" str_pos = fit_prot_file.find(pdb_ext) base_name = fit_prot_file[0:str_pos] temp_dir = tempfile.mkdtemp() output_fit_file = os.path.join(temp_dir, base_name + "_sp.oeb.gz") print("Tanimoto score for the secondary structure fit of", fit_prot_file, "to", ref_prot_file, "is", tanimoto, ".\n") print("Writing superimposed fit protein to", output_fit_file) if do_write: ofs = oechem.oemolostream(output_fit_file) oechem.OEWriteMolecule(ofs, fit_prot)