def testCreateStoreOE(self): """Test case - build persistent store of OE molecules using the contents of the persistent store of chemical component defintions. """ startTime = time.time() self.__lfh.write( "\nStarting OePersistFullDictTests testCreateStoreOE at %s\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()))) try: myPersist = PdbxPersist(self.__verbose, self.__lfh) indexD = myPersist.getIndex(dbFileName=self.__persistStorePathCC) # noqa: F841 pylint: disable=unused-variable myPersist.open(dbFileName=self.__persistStorePathCC) containerNameList = myPersist.getStoreContainerIndex() oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) molList = [] for ccId in containerNameList: ccAt = myPersist.fetchObject(containerName=ccId, objectName="chem_comp_atom") ccBnd = myPersist.fetchObject(containerName=ccId, objectName="chem_comp_bond") if ccAt is None or ccBnd is None: continue # oem.set(ccId, dcChemCompAtom=ccAt, dcChemCompBond=ccBnd) oem.build3D() if self.__debug: self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) molD = {} molD["name"] = ccId molD["oeb"] = oem.serialize() molList.append(molD) myPersist.close() # oeP = OePersist(self.__verbose, self.__lfh) oeP.setMoleculeList(moleculeList=molList) oeP.store(dbFileName=self.__storePath) mL = oeP.getIndex(dbFileName=self.__storePath) # if self.__debug: self.__lfh.write( "OePersistTests(testCreateStore) molecule list %r\n" % mL) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail() endTime = time.time() self.__lfh.write( "\nCompleted OePersistFullDictTests testCreateStoreOE at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime))
def testSerialize3D(self): """Test case - build OE molecule using 3D data in the definition source data file then serialize and deserialize this molecule. """ self.__lfh.write("\nStarting OeBuildMolTests testSerialize3D\n") try: oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) for pth in self.__pathList: myReader = PdbxIoAdapter(self.__verbose, self.__lfh) ok = myReader.read(pdbxFilePath=pth) myReader.write( pdbxFilePath=os.path.join(self.__testoutput, "TMP.cif")) for container in myReader.getContainerList(): oem.set(container.getName(), dcChemCompAtom=container.getObj("chem_comp_atom"), dcChemCompBond=container.getObj("chem_comp_bond")) oem.build3D(coordType="model") self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) oeS = oem.serialize() # self.__lfh.write("Serialized string length = %d\n" % len(oeS)) # oemD = OeBuildMol(verbose=self.__verbose, log=self.__lfh) ok = oemD.deserialize(oeS) self.__lfh.write("Deserialized status = %s\n" % ok) self.__lfh.write("Deserialized SMILES (canonical) = %s\n" % oemD.getCanSMILES()) self.__lfh.write("Deserialized SMILES (isomeric) = %s\n" % oemD.getIsoSMILES()) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail()
def testCreateStoreOE(self): """Test case - build persistent store of serialized OE molecules using the contents of the chemical dictionary persistent store containing all of chemical component defintions. ***NOTE - This will display diagnostics from OE toolkit for molecules with problematic features. These issues will not impact the shape search. """ startTime = time.time() self.__lfh.write( "\nStarting OeShapeSearchtests testCreateCoreOE at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime())) try: # Get handle for myPersist = PdbxPersist(self.__verbose, self.__lfh) indexD = myPersist.getIndex(dbFileName=self.__persistStorePathCC) # noqa: F841 pylint: disable=unused-variable myPersist.open(dbFileName=self.__persistStorePathCC) containerNameList = myPersist.getStoreContainerIndex() oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh) molList = [] for ccId in containerNameList: ccAt = myPersist.fetchObject(containerName=ccId, objectName="chem_comp_atom") ccBnd = myPersist.fetchObject(containerName=ccId, objectName="chem_comp_bond") if ccAt is None or ccBnd is None: continue # oem.set(ccId, dcChemCompAtom=ccAt, dcChemCompBond=ccBnd) ok = oem.build3D() if ok: if self.__debug: self.__lfh.write("Title = %s\n" % oem.getTitle()) self.__lfh.write("SMILES (canonical) = %s\n" % oem.getCanSMILES()) self.__lfh.write("SMILES (isomeric) = %s\n" % oem.getIsoSMILES()) molD = {} molD["name"] = ccId molD["oeb"] = oem.serialize() molList.append(molD) else: self.__lfh.write( "+WARN - failed to build OE molecule for %s\n" % ccId) myPersist.close() # oeP = OePersist(self.__verbose, self.__lfh) oeP.setMoleculeList(moleculeList=molList) oeP.store(dbFileName=self.__storePath) mL = oeP.getIndex(dbFileName=self.__storePath) # if self.__debug: self.__lfh.write( "OePersistTests(testCreateStore) molecule list %r\n" % mL) except: # noqa: E722 pylint: disable=bare-except traceback.print_exc(file=self.__lfh) self.fail() endTime = time.time() self.__lfh.write( "\nCompleted OeShapeSearchtests testCreateOEStore at %s (%d seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime))