def __getCCDefFile(self, ccPath, suppressHydrogens=False): """Fetch the molecule definition (ccPath) and build OE molecules for comparison and depiction. """ # oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ccId = oem.setChemCompPath(ccPath) oem.build2D() if self.__verbose: self.__lfh.write("+OEAlignDepilsct.__getCCDefFile() for %s\n" % ccId) self.__lfh.write(" Title = %s\n" % oem.getTitle()) self.__lfh.write(" SMILES = %s\n" % oem.getCanSMILES()) self.__lfh.write(" SMILES (stereo) = %s\n" % oem.getIsoSMILES()) self.__lfh.write(" Formula (Hill) = %s\n" % oem.getFormula()) self.__lfh.write(" InChI key = %s\n" % oem.getInChIKey()) self.__lfh.write(" InChI = %s\n" % oem.getInChI()) fD = {} fD = { "Formula": oem.getFormula(), "SMILES": oem.getCanSMILES(), "SMILES_STEREO": oem.getIsoSMILES(), "InChI": oem.getInChI(), "InChIKey": oem.getInChIKey() } if suppressHydrogens: return (ccId, oem.getGraphMolSuppressH(), fD) else: return (ccId, oem.getMol(), fD)
def __getMiscFile(self, ccPath, suppressHydrogens=False, importType="2D"): """Fetch a miscellaneous chemical file (ccPath) and build OE molecules for comparison and depiction. """ try: oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) if oem.importFile(ccPath, type=importType): if self.__verbose: self.__lfh.write("+OEAlignDepilsct.__getMiscFile()\n") self.__lfh.write(" Title = %s\n" % oem.getTitle()) self.__lfh.write(" SMILES = %s\n" % oem.getCanSMILES()) self.__lfh.write(" SMILES (stereo) = %s\n" % oem.getIsoSMILES()) self.__lfh.write(" Formula (Hill) = %s\n" % oem.getFormula()) self.__lfh.write(" InChI key = %s\n" % oem.getInChIKey()) self.__lfh.write(" InChI = %s\n" % oem.getInChI()) else: self.__lfh.write( "+OEAlignDepict.__getMiscFile() Read failed for %s\n" % ccPath) return None, None, None # # oem.build2D() ccId = oem.getTitle() if suppressHydrogens: tMol = oem.getGraphMolSuppressH() else: tMol = oem.getMol() molXyzL = [] if importType == "3D": for ii, atm in enumerate(tMol.GetAtoms()): xyzL = OEFloatArray(3) tMol.GetCoords(atm, xyzL) molXyzL.append( (ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), "%.3f" % xyzL[0], "%.3f" % xyzL[1], "%.3f" % xyzL[2])) fD = {} fD = { "Formula": oem.getFormula(), "SMILES": oem.getCanSMILES(), "SMILES_STEREO": oem.getIsoSMILES(), "InChI": oem.getInChI(), "InChIKey": oem.getInChIKey(), "xyz": molXyzL, } for ii, atm in enumerate(tMol.GetAtoms()): xyzL = OEFloatArray(3) tMol.GetCoords(atm, xyzL) if self.__verbose: self.__lfh.write( "OeAlignDepict.__getMiscFile - atom %d %s %s %s %s %r\n" % (ii, atm.GetIdx(), atm.GetAtomicNum(), atm.GetName(), atm.GetType(), xyzL)) return (ccId, tMol, fD) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) # self.fail() return None, None, None