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()
示例#2
0
    def testFetchOne(self):
        """Test case -  fetch all of the molecules in the persistent store one by one.  Each fetch reopens
        the store.
        """
        startTime = time.time()
        self.__lfh.write(
            "\nStarting OePersistFullDictTests testFetchOne at %s\n" %
            (time.strftime("%Y %m %d %H:%M:%S", time.localtime())))
        try:
            myPersist = OePersist(self.__verbose, self.__lfh)
            moleculeNameList = myPersist.getIndex(dbFileName=self.__storePath)
            #
            oem = OeBuildMol(verbose=self.__verbose, log=self.__lfh)
            for ccId in moleculeNameList:
                molD = myPersist.fetchOneMolecule(dbFileName=self.__storePath,
                                                  moleculeName=ccId)
                # name = molD['name']
                ok = oem.deserialize(molD["oeb"])
                if not ok:
                    self.__lfh.write("Deserialized status %s = %s\n" %
                                     (ccId, ok))
                    continue

                if self.__debug:
                    self.__lfh.write("Deserialized SMILES (canonical) = %s\n" %
                                     oem.getCanSMILES())
                    self.__lfh.write("Deserialized SMILES (isomeric)  = %s\n" %
                                     oem.getIsoSMILES())

        except:  # noqa: E722 pylint: disable=bare-except
            traceback.print_exc(file=self.__lfh)
            self.fail()

        endTime = time.time()
        self.__lfh.write(
            "\nCompleted OePersistFullDictTests testFetchOne at %s (%d seconds)\n"
            % (time.strftime("%Y %m %d %H:%M:%S",
                             time.localtime()), endTime - startTime))