def testAnnotMtz2PdbxBadTimeout(self):
     """  Test mtz to pdbx conversion
     """
     logger.info("\nStarting %s %s\n" %
                 (self.__class__.__name__, sys._getframe().f_code.co_name))
     try:
         diagfn = "sf-convert-diags-bad-runaway.cif"
         ciffn = "sf-convert-datafile-bad-runaway.cif"
         dmpfn = "sf-convert-mtzdmp-bad-runaway.log"
         #
         dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                            siteId=self.__siteId,
                            verbose=True)
         dp.setDebugMode()
         mtzPath = os.path.join(self.__testFilePath,
                                self.__testFileMtzRunaway)
         dp.imp(mtzPath)
         dp.setTimeout(15)
         dp.op("annot-sf-convert")
         dp.expLog("sf-convert-runaway.log")
         dp.expList(dstPathList=[ciffn, diagfn, dmpfn])
         # dp.cleanup()
     except Exception as e:
         logger.exception("Failing with %s" % str(e))
         self.fail()
    def testAnnotOmitMapCalc(self):
        """  Test create density maps --
        """
        logger.info("\nStarting %s %s\n" %
                    (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            for pdbId in self.__testValidateIdList:
                of2fofc = pdbId + "_map-omit-2fofc_P1.map"
                offofc = pdbId + "_map-omit-fofc_P1.map"

                testFileXyz = pdbId + ".cif"
                testFileSf = pdbId + "-sf.cif"

                dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                                   siteId=self.__siteId,
                                   verbose=True)
                dp.setDebugMode()
                xyzPath = os.path.join(self.__testFilePath, testFileXyz)
                sfPath = os.path.join(self.__testFilePath, testFileSf)
                dp.imp(xyzPath)
                dp.addInput(name="sf_file_path", value=sfPath)
                dp.op("annot-make-maps")
                dp.expLog(pdbId + "-annot-make-maps.log")
                dp.expList(dstPathList=[of2fofc, offofc])
                # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
    def testChemicalShiftCoordinateCheck2(self):
        """Test upload check of one CS file  ---  Using a processed chemical shift file"""
        logger.info("\nStarting")
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                               siteId=self.__siteId,
                               verbose=True)
            dp.setDebugMode(flag=True)
            inpPath = os.path.join(self.__testFilePath, self.__testConcatCS)
            xyzPath = os.path.abspath(
                os.path.join(self.__testFilePath, self.__testFileNmrModel))
            outPath = "output-cs-file-concat.cif"
            chkPath = "cs-diag-atom-name-check-concat.cif"
            dp.imp(inpPath)
            dp.addInput(name="coordinate_file_path", value=xyzPath)
            dp.addInput(name="chemical_shifts_coord_check_file_path",
                        value=chkPath)

            dp.op("annot-chem-shifts-atom-name-check")
            dp.expLog("annot-chem-shifts-atom-name-check-concat.log")
            dp.exp(outPath)
            # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()
 def testAnnotDccReport(self):
     """  Test create DCC report -
     """
     logger.info("\nStarting %s %s\n" %
                 (self.__class__.__name__, sys._getframe().f_code.co_name))
     try:
         ofn = "dcc-report.cif"
         dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                            siteId=self.__siteId,
                            verbose=True)
         dp.setDebugMode()
         xyzPath = os.path.join(self.__testFilePath,
                                self.__testFileValidateXyz)
         sfPath = os.path.join(self.__testFilePath,
                               self.__testFileValidateSf)
         dp.imp(xyzPath)
         dp.addInput(name="sf_file_path", value=sfPath)
         dp.op("annot-dcc-report")
         dp.expLog("dcc-report.log")
         dp.exp(ofn)
         # dp.expList(dstPathList=[ofpdf,ofxml])
         dp.cleanup()
     except Exception as e:
         logger.exception("Failing with %s" % str(e))
         self.fail()
    def testUploadShiftListCheck(self):
        """Test upload check of one CS file  ---  Upload multiple files"""
        logger.info("\nStarting")
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                               siteId=self.__siteId,
                               verbose=True)
            dp.setDebugMode(flag=True)
            inpPath = os.path.join(self.__testFilePath, self.__testFileStarCs)
            outPath = "output-cs-file-full-2.cif"
            chkPath = "cs-diag-upload-check-2.cif"
            dp.addInput(name="chemical_shifts_file_path_list",
                        value=[inpPath, inpPath])
            dp.addInput(name="chemical_shifts_auth_file_name_list",
                        value=["cs_file_1", "cs_file_2"])
            dp.addInput(name="chemical_shifts_upload_check_file_path",
                        value=chkPath)

            dp.op("annot-chem-shifts-upload-check")
            dp.expLog("annot-chem-shifts-upload-check-2.log")
            dp.exp(outPath)
            # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()
Exemplo n.º 6
0
    def testChemicalShiftCoordinateCheck2Alt(self):
        """  Test upload check of one CS file  --- Using the wrong model to generate errors
        """
        logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
            dp.setDebugMode(flag=True)
            inpPath = os.path.join(self.__testFilePath, self.__testConcatCS)
            xyzPath = os.path.abspath(os.path.join(self.__testFilePath, self.__testFileNmrModelAlt))
            outPath = "output-cs-file-concat-alt.cif"
            chkPath = "cs-diag-atom-name-check-concat-alt.cif"
            dp.imp(inpPath)
            dp.addInput(name="coordinate_file_path", value=xyzPath)
            dp.addInput(name="chemical_shifts_coord_check_file_path", value=chkPath)

            dp.op("annot-chem-shifts-atom-name-check")
            dp.expLog("annot-chem-shifts-atom-name-check-concat-alt.log")
            dp.exp(outPath)
            #
            if os.access(chkPath, os.R_OK):
                csr = PdbxChemShiftReport(inputPath=chkPath, verbose=self.__verbose, log=self.__lfh)
                status = csr.getStatus()
                logger.info("Status code: %s\n" % status)
                warnings = csr.getWarnings()
                logger.info("\n\nWarning count : %d\n %s\n" % (len(warnings), ('\n').join(warnings)))
                #
                errors = csr.getErrors()
                logger.info("\n\nError count : %d\n %s\n" % (len(errors), ('\n').join(errors)))
            #
            # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
Exemplo n.º 7
0
    def __getLoadFile(self, sessionPath, listfile, sqlfile, logfile):

        fn = os.path.join(self.__sessionPath, listfile)

        mapping = self.__cIcommon.get_site_da_internal_schema_path()

        self.__lfh.write(
            "DbLoadUtil::__getLoadFile(): listfile %s sqlfile %s logfile %s\n"
            % (fn, sqlfile, logfile))
        try:
            dp = RcsbDpUtility(tmpPath=sessionPath,
                               siteId=self.__siteId,
                               verbose=self.__verbose,
                               log=self.__lfh)
            dp.setDebugMode()
            dp.imp(fn)
            dp.addInput(name="mapping_file", value=mapping, type="file")
            dp.addInput(name="file_list", value=True)
            # This code handles model files
            dp.addInput(name="first_block", value=True)

            dp.op("db-loader")
            dp.expLog(logfile)
            dp.exp(sqlfile)
            dp.cleanup()
            return
        except:  # noqa: E722 pylint: disable=bare-except
            self.__lfh.write(
                "DbLoadUtil::__getLoadFile(): failing, with exception.\n")
            traceback.print_exc(file=self.__lfh)
    def testAnnotLigandMapCalc(self):
        """  Test create non-polymer local density maps --
        """
        logger.info("\nStarting %s %s\n" %
                    (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            for pdbId in ['3of4']:

                testFileXyz = pdbId + ".cif"
                testFileSf = pdbId + "-sf.cif"
                #
                dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                                   siteId=self.__siteId,
                                   verbose=True)
                dp.setDebugMode(flag=True)
                xyzPath = os.path.join(self.__testFilePath, testFileXyz)
                sfPath = os.path.join(self.__testFilePath, testFileSf)
                #
                outDataPath = os.path.join(self.__tmpPath, 'np-cc-maps')
                outIndexPath = os.path.join(self.__tmpPath, 'np-cc-maps',
                                            'np-cc-maps-index.cif')
                #
                dp.imp(xyzPath)
                dp.addInput(name="sf_file_path", value=sfPath)
                dp.addInput(name="output_data_path", value=outDataPath)
                dp.addInput(name="output_index_path", value=outIndexPath)
                dp.op("annot-make-ligand-maps")
                dp.expLog(pdbId + "-annot-make-ligand-maps.log")
                #
                if (False):
                    dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                                       siteId=self.__siteId,
                                       verbose=True)
                    dp.setDebugMode(flag=True)
                    xyzPath = os.path.join(self.__testFilePath, testFileXyz)
                    sfPath = os.path.join(self.__testFilePath, testFileSf)
                    #
                    outDataPath = os.path.join(self.__tmpPath,
                                               'np-cc-omit-maps')
                    outIndexPath = os.path.join(self.__tmpPath,
                                                'np-cc-omit-maps',
                                                'np-cc-omit-maps-index.cif')
                    #
                    dp.imp(xyzPath)
                    dp.addInput(name="omit_map", value=True)
                    dp.addInput(name="sf_file_path", value=sfPath)
                    dp.addInput(name="output_data_path", value=outDataPath)
                    dp.addInput(name="output_index_path", value=outIndexPath)
                    dp.op("annot-make-ligand-maps")
                    dp.expLog(pdbId + "-annot-make-ligand-omit-maps.log")

                    #
                    # This application
                    # dp.cleanup()

        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
Exemplo n.º 9
0
    def testReadMapHeader(self):
        """  Test read map header -- export JSON packet and plot density distribution -
        """
        logger.info("\nStarting %s %s\n" %
                    (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath,
                               siteId=self.__siteId,
                               verbose=True)
            dp.setDebugMode(flag=True)
            #
            inpPath = os.path.join(self.__testFilePath, self.__testMapNormal)
            of = self.__testMapNormal + "_map-header-data_P1.json"
            dp.imp(inpPath)
            dp.op("annot-read-map-header")
            dp.expLog("annot-read-map-header.log")
            dp.exp(of)
            # dp.cleanup()
            #
            mD = json.load(open(of, 'r'))
            logger.info("Map header keys: %r\n" % mD.keys())
            logger.info("Map header: %r\n" % mD.items())

            logger.info("Input  header keys: %r\n" % mD['input_header'].keys())
            logger.info("Output header keys: %r\n" %
                        mD['output_header'].keys())
            #
            x = mD['input_histogram_categories']
            y = mD['input_histogram_values']
            logy = []
            for v in y:
                if float(v) <= 0.0:
                    logy.append(math.log10(.1))
                else:
                    logy.append(math.log10(float(v)))

            #
            width = float(x[-1] - x[0]) / float(len(x))
            #width = 2.0
            logger.info("Starting plot\n")
            plt.bar(x, y, width, color="r", log=True)
            logger.info("Loaded data\n")
            plt.title('Map density distribution')
            logger.info("set title\n")
            plt.ylabel('Voxels (log(10))')
            plt.xlabel('Density')
            logger.info("set labels\n")
            plotFileName = "map-density-plot-mpl.svg"
            plt.savefig(plotFileName, format="svg")
            logger.info("saved figure\n")

        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
Exemplo n.º 10
0
    def testAnnotLigandMapCalc(self):
        """Test create non-polymer local density maps --"""
        logger.info("\nStarting")
        try:
            for pdbId in ["3of4"]:

                testFileXyz = pdbId + ".cif"
                testFileSf = pdbId + "-sf.cif"
                #
                dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
                dp.setDebugMode(flag=True)
                xyzPath = os.path.join(self.__testFilePath, testFileXyz)
                sfPath = os.path.join(self.__testFilePath, testFileSf)
                #
                outDataPath = os.path.join(self.__tmpPath, "np-cc-maps")
                outIndexPath = os.path.join(self.__tmpPath, "np-cc-maps", "np-cc-maps-index.cif")
                #
                dp.imp(xyzPath)
                dp.addInput(name="sf_file_path", value=sfPath)
                dp.addInput(name="output_data_path", value=outDataPath)
                dp.addInput(name="output_index_path", value=outIndexPath)
                dp.op("annot-make-ligand-maps")
                dp.expLog(pdbId + "-annot-make-ligand-maps.log")
                #
                if False:  # pylint: disable=using-constant-test
                    dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
                    dp.setDebugMode(flag=True)
                    xyzPath = os.path.join(self.__testFilePath, testFileXyz)
                    sfPath = os.path.join(self.__testFilePath, testFileSf)
                    #
                    outDataPath = os.path.join(self.__tmpPath, "np-cc-omit-maps")
                    outIndexPath = os.path.join(self.__tmpPath, "np-cc-omit-maps", "np-cc-omit-maps-index.cif")
                    #
                    dp.imp(xyzPath)
                    dp.addInput(name="omit_map", value=True)
                    dp.addInput(name="sf_file_path", value=sfPath)
                    dp.addInput(name="output_data_path", value=outDataPath)
                    dp.addInput(name="output_index_path", value=outIndexPath)
                    dp.op("annot-make-ligand-maps")
                    dp.expLog(pdbId + "-annot-make-ligand-omit-maps.log")

                    #
                    # This application
                    # dp.cleanup()

        except Exception as e:
            logger.exception("Failing with %s", str(e))
            self.fail()
    def testAnnotGetCorresInfo(self):
        """  Test running GetCorresInfo to get correspondance info -
        """
        logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            of = os.path.join(self.__tmpPath, "annot-get-corres-info-check.cif")
            dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
            dp.setDebugMode(True)
            inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotSite)
            dp.imp(inpPath)
            dp.op("annot-get-corres-info")
            dp.expLog(os.path.join(self.__tmpPath, "annot-get-corres-info-check-pdbx.log"))
            dp.exp(of)
            # dp.cleanup()

        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
Exemplo n.º 12
0
 def testAnnotMtz2PdbxGood(self):
     """Test mtz to pdbx conversion  (good mtz)"""
     logger.info("\nStarting")
     try:
         diagfn = "sf-convert-diags.cif"
         ciffn = "sf-convert-datafile.cif"
         dmpfn = "sf-convert-mtzdmp.log"
         #
         dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
         dp.setDebugMode()
         mtzPath = os.path.join(self.__testFilePath, self.__testFileMtzGood)
         dp.imp(mtzPath)
         dp.setTimeout(15)
         dp.op("annot-sf-convert")
         dp.expLog("sf-convert.log")
         dp.expList(dstPathList=[ciffn, diagfn, dmpfn])
         # dp.cleanup()
     except Exception as e:
         logger.exception("Failing with %s", str(e))
         self.fail()
Exemplo n.º 13
0
    def testUploadShiftOneCheck(self):
        """  Test upload check of one CS file  ---   upload single file
        """
        logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
            dp.setDebugMode(flag=True)
            inpPath = os.path.join(self.__testFilePath, self.__testFileStarCs)
            outPath = "output-cs-file-full.cif"
            chkPath = "cs-diag-upload-check-1.cif"
            dp.addInput(name="chemical_shifts_file_path_list", value=[inpPath])
            dp.addInput(name="chemical_shifts_auth_file_name_list", value=['cs_file_1'])
            dp.addInput(name="chemical_shifts_upload_check_file_path", value=chkPath)

            dp.op("annot-chem-shifts-upload-check")
            dp.expLog("annot-chem-shifts-upload-check.log")
            dp.exp(outPath)
            # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()
Exemplo n.º 14
0
    def testChemicalShiftCoordinateCheck(self):
        """  Test upload check of one CS file  ---   Using a PDB Archive STAR file -- (Does not work)
        """
        logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name))
        try:
            dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True)
            dp.setDebugMode(flag=True)
            inpPath = os.path.join(self.__testFilePath, self.__testFileStarCs)
            xyzPath = os.path.abspath(os.path.join(self.__testFilePath, self.__testFileNmrModel))
            outPath = "output-cs-file.cif"
            chkPath = "cs-diag-atom-name-check.cif"
            dp.imp(inpPath)
            dp.addInput(name="coordinate_file_path", value=xyzPath)
            dp.addInput(name="chemical_shifts_coord_check_file_path", value=chkPath)

            dp.op("annot-chem-shifts-atom-name-check")
            dp.expLog("annot-chem-shifts-atom-name-check.log")
            dp.exp(outPath)
            # dp.cleanup()
        except Exception as e:
            logger.exception("Failing with %s" % str(e))
            self.fail()