コード例 #1
0
    def testLoadFiles(self):
        """Test case - create batch load files for all chemical component definition data files -"""
        self.__lfh.write("\nStarting ChemCompLoaderTests testLoadFiles\n")
        startTime = time.time()
        try:
            ccsd = ChemCompSchemaDef()
            sml = SchemaDefLoader(schemaDefObj=ccsd,
                                  ioObj=self.__ioObj,
                                  dbCon=None,
                                  workPath=".",
                                  cleanUp=False,
                                  warnings="default",
                                  verbose=self.__verbose,
                                  log=self.__lfh)
            pathList = self.__makeComponentPathList()

            containerNameList, tList = sml.makeLoadFiles(pathList,
                                                         append=False)
            for tId, fn in tList:
                self.__lfh.write("\nCreated table %s load file %s\n" %
                                 (tId, fn))
            #

            endTime1 = time.time()
            self.__lfh.write("\nBatch files created in %.2f seconds\n" %
                             (endTime1 - startTime))
            self.open(dbName=ccsd.getDatabaseName())
            sdl = SchemaDefLoader(schemaDefObj=ccsd,
                                  ioObj=self.__ioObj,
                                  dbCon=self.__dbCon,
                                  workPath=".",
                                  cleanUp=False,
                                  warnings="default",
                                  verbose=self.__verbose,
                                  log=self.__lfh)

            sdl.loadBatchFiles(loadList=tList,
                               containerNameList=containerNameList,
                               deleteOpt="all")
            self.close()
            endTime2 = time.time()
            self.__lfh.write("\nLoad completed in %.2f seconds\n" %
                             (endTime2 - endTime1))
        except:  # noqa: E722  pylint: disable=bare-except
            traceback.print_exc(file=self.__lfh)
            self.fail()
        endTime = time.time()
        self.__lfh.write(
            "\nCompleted ChemCompLoaderTests testLoadFiles at %s (%.2f seconds)\n"
            % (time.strftime("%Y %m %d %H:%M:%S",
                             time.localtime()), endTime - startTime))
コード例 #2
0
 def testConnect(self):
     """Test case - for creating a test connection"""
     self.__lfh.write("\nStarting ChemCompLoaderTests testConnect\n")
     startTime = time.time()
     try:
         ccsd = ChemCompSchemaDef()
         self.open(dbName=ccsd.getDatabaseName())
         self.close()
     except:  # noqa: E722  pylint: disable=bare-except
         traceback.print_exc(file=self.__lfh)
         self.fail()
     endTime = time.time()
     self.__lfh.write(
         "\nCompleted ChemCompLoaderTests testConnect at %s (%.2f seconds)\n"
         % (time.strftime("%Y %m %d %H:%M:%S",
                          time.localtime()), endTime - startTime))
コード例 #3
0
 def loadBatchFilesMulti(self, dataList, procName, optionsD, workingDir):  # pylint: disable=unused-argument
     ccsd = ChemCompSchemaDef()
     self.open(dbName=ccsd.getDatabaseName())
     sdl = SchemaDefLoader(schemaDefObj=ccsd,
                           ioObj=self.__ioObj,
                           dbCon=self.__dbCon,
                           workPath=".",
                           cleanUp=False,
                           warnings="default",
                           verbose=self.__verbose,
                           log=self.__lfh)
     #
     sdl.loadBatchFiles(loadList=dataList,
                        containerNameList=None,
                        deleteOpt=None)
     self.close()
     return dataList, dataList, []
コード例 #4
0
 def testSchemaCreate(self):
     """Create table schema for BIRD, chemical component, and PDBx data."""
     sd = BirdSchemaDef()
     self.__schemaCreate(schemaDefObj=sd)
     #
     sd = ChemCompSchemaDef()
     self.__schemaCreate(schemaDefObj=sd)
     #
     sd = PdbxSchemaDef()
     self.__schemaCreate(schemaDefObj=sd)
コード例 #5
0
    def testLoadChemCompExamples(self):
        startTime = time.time()
        self.__lfh.write("\nStarting SchemaDefLoaderDbTest testLoadChemCompExamples at %s\n" % time.strftime("%Y %m %d %H:%M:%S", time.localtime()))
        try:
            sd = ChemCompSchemaDef()
            self.__schemaCreate(schemaDefObj=sd)
            inputPathList = [os.path.join(self.__ccPath, fn) for fn in self.__ccFileList]
            sdl = SchemaDefLoader(schemaDefObj=sd, ioObj=self.__ioObj, dbCon=self.__dbCon, workPath=".", cleanUp=False, warnings="default", verbose=self.__verbose, log=self.__lfh)
            sdl.load(inputPathList=inputPathList, loadType="batch-insert", deleteOpt="selected")
        except:  # noqa: E722  pylint: disable=bare-except
            traceback.print_exc(file=self.__lfh)
            self.fail()

        endTime = time.time()
        self.__lfh.write(
            "\nCompleted SchemaDefLoaderDbTest testLoadChemCompExamples at %s (%.2f seconds)\n" % (time.strftime("%Y %m %d %H:%M:%S", time.localtime()), endTime - startTime)
        )
コード例 #6
0
    def testLoadFilesMulti(self):
        """Test case - create batch load files for all chemical component definition data files - (multiproc test)"""
        self.__lfh.write("\nStarting ChemCompLoaderTests testLoadFilesMulti\n")
        startTime = time.time()
        numProc = 8
        try:
            dataS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
            dataList = [a for a in dataS]
            mpu = MultiProcUtil(verbose=True)
            mpu.set(workerObj=self, workerMethod="makeComponentPathListMulti")
            _ok, _failList, retLists, _diagList = mpu.runMulti(
                dataList=dataList, numProc=numProc, numResults=1)
            pathList = retLists[0]
            endTime0 = time.time()
            self.__lfh.write("\nPath list length %d  in %.2f seconds\n" %
                             (len(pathList), endTime0 - startTime))

            # self.__lfh.write("\nPath list %r\n" % pathList[:20])
            # pathList=self.__makeComponentPathList()

            ccsd = ChemCompSchemaDef()
            sml = SchemaDefLoader(schemaDefObj=ccsd,
                                  ioObj=self.__ioObj,
                                  dbCon=None,
                                  workPath=".",
                                  cleanUp=False,
                                  warnings="default",
                                  verbose=self.__verbose,
                                  log=self.__lfh)

            #
            mpu = MultiProcUtil(verbose=True)
            mpu.set(workerObj=sml, workerMethod="makeLoadFilesMulti")
            _ok, _failList, retLists, _diagList = mpu.runMulti(
                dataList=pathList, numProc=numProc, numResults=2)
            #
            containerNameList = retLists[0]
            tList = retLists[1]

            for tId, fn in tList:
                self.__lfh.write("\nCreated table %s load file %s\n" %
                                 (tId, fn))
            #

            endTime1 = time.time()
            self.__lfh.write("\nBatch files created in %.2f seconds\n" %
                             (endTime1 - endTime0))
            self.open(dbName=ccsd.getDatabaseName())
            sdl = SchemaDefLoader(schemaDefObj=ccsd,
                                  ioObj=self.__ioObj,
                                  dbCon=self.__dbCon,
                                  workPath=".",
                                  cleanUp=False,
                                  warnings="default",
                                  verbose=self.__verbose,
                                  log=self.__lfh)
            #
            for tId, fn in tList:
                sdl.delete(tId,
                           containerNameList=containerNameList,
                           deleteOpt="all")
            self.close()
            #
            mpu = MultiProcUtil(verbose=True)
            mpu.set(workerObj=self, workerMethod="loadBatchFilesMulti")
            _ok, _failList, retLists, _diagList = mpu.runMulti(dataList=tList,
                                                               numProc=numProc,
                                                               numResults=1)

            endTime2 = time.time()
            self.__lfh.write("\nLoad completed in %.2f seconds\n" %
                             (endTime2 - endTime1))
        except:  # noqa: E722  pylint: disable=bare-except
            traceback.print_exc(file=self.__lfh)
            self.fail()
        endTime = time.time()
        self.__lfh.write(
            "\nCompleted ChemCompLoaderTests testLoadFilesMulti at %s (%.2f seconds)\n"
            % (time.strftime("%Y %m %d %H:%M:%S",
                             time.localtime()), endTime - startTime))
コード例 #7
0
 def testChemCompSchema(self):
     """Test case -  chemCompSchema test"""
     sd = ChemCompSchemaDef()
     self.__dotest(sd)