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()
def pdbx2Assemblies(self, idCode, inpFilePath, outPath=".", indexFilePath=None): """Create model assemby files from input PDBx model file.""" try: pdbxPath = inpFilePath logPath = os.path.join(self.__sessionPath, "pdbx-assembly.log") # indexFilePath=os.path.join(self.__sessionPath,"pdbx-assembly-index.txt") # dp = RcsbDpUtility(tmpPath=self.__sessionPath, siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh) dp.imp(pdbxPath) if idCode is not None: dp.addInput(name="deposition_data_set_id", value=idCode, type="param") if indexFilePath is not None: dp.addInput(name="index_file_path", value=indexFilePath, type="param") dp.op("annot-gen-assem-pdbx") dp.expLog(logPath) pthList = dp.getResultPathList() # wrkPath = dp.getWorkingDir() for pth in pthList: if os.access(pth, os.R_OK): (_t, fn) = os.path.split(pth) shutil.copyfile(pth, os.path.join(outPath, fn)) # if (not self.__debug): # dp.cleanup() # if self.__verbose: self.__lfh.write("+DataFileAdapter.pdbx2Assemblies() - input model file path: %s\n" % inpFilePath) self.__lfh.write("+DataFileAdapter.pdbx2Assemblies() - assembly output paths: %r\n" % pthList) return True except: # noqa: E722 pylint: disable=bare-except self.__lfh.write("+DataFileAdapter.pdbx2Assemblies() - failing for input file path %s output path %s\n" % (inpFilePath, outPath)) traceback.print_exc(file=self.__lfh) return False
def read_mtz_sf(self, pathin): """Reads MTZ structure factor file Return True on success, otherwise False """ logger.debug("Starting mtz read %s", pathin) suffix = "-dir" prefix = "rcsb-" if self.__tmppath is not None and os.path.isdir(self.__tmppath): workpath = tempfile.mkdtemp(suffix, prefix, self.__tmppath) else: workpath = tempfile.mkdtemp(suffix, prefix) diagfn = os.path.join(workpath, "sf-convert-diags.cif") ciffn = os.path.join(workpath, "sf-convert-datafile.cif") dmpfn = os.path.join(workpath, "sf-convert-mtzdmp.log") logfn = os.path.join(workpath, "sf-convert.log") dp = RcsbDpUtility(siteId=self.__siteid, tmpPath=self.__tmppath) dp.imp(pathin) dp.op("annot-sf-convert") dp.expLog(logfn) dp.expList(dstPathList=[ciffn, diagfn, dmpfn]) if os.path.exists(ciffn): ret = self.read_mmcif_sf(ciffn) else: ret = False if self.__cleanup: dp.cleanup() shutil.rmtree(workpath, ignore_errors=True) return ret
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 __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 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 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 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()
def testAnnotSiteAndMerge(self): """ Calculate site environment """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: of = "annot-site-" + self.__testFileAnnotSite # +".gz" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotSite) dp.imp(inpPath) dp.addInput(name="block_id", value=self.__testIdAnnotSite) dp.op("annot-site") dp.expLog("annot-site.log") dp.exp(of) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotSite) dp.imp(inpPath) dp.addInput(name="site_info_file_path", value=of, type="file") dp.op("annot-merge-struct-site") dp.exp("annot-site-updated.cif.gz") dp.expLog("annot-site-updated-cif.log.gz") # dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def testAnnotValidateListNmrTest(self): """ Test create validation report for the test list of example PDB ids (NMR examples) """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: count = 0 for pdbId in self.__testValidateNmrIdList: ofpdf = pdbId + "-valrpt.pdf" ofxml = pdbId + "-valdata.xml" offullpdf = pdbId + "-valrpt_full.pdf" ofpng = pdbId + "-val-slider.png" ofsvg = pdbId + "-val-slider.svg" # testFileValidateXyz = pdbId + ".cif" testFileValidateCs = pdbId + "-cs.cif" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) xyzPath = os.path.abspath(os.path.join(self.__testFilePath, testFileValidateXyz)) csPath = os.path.abspath(os.path.join(self.__testFilePath, testFileValidateCs)) dp.addInput(name="request_annotation_context", value="yes") # adding explicit selection of steps -- # Alternate if count % 2 == 0: dp.addInput(name="step_list", value=" coreclust,chemicalshifts,writexml,writepdf ") count += 1 dp.imp(xyzPath) dp.addInput(name="cs_file_path", value=csPath) dp.op("annot-wwpdb-validate-all") dp.expLog(pdbId + "-annot-validate-test.log") dp.expList(dstPathList=[ofpdf, ofxml, offullpdf, ofpng, ofsvg]) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def mtz2Pdbx(self, mtzFilePath, outSfFilePath, pdbxFilePath=None, logFilePath=None, diagsFilePath=None, dumpFilePath=None, timeout=120): """ Convert input MTZ format to PDBx sf file. """ try: diagfn = logFilePath if logFilePath is not None else "sf-convert-diags.cif" dmpfn = dumpFilePath if dumpFilePath is not None else "sf-convert-mtzdmp.log" # dp = RcsbDpUtility(tmpPath=self.__sessionPath, siteId=self.__siteId, verbose=self.__verbose, log=self.__lfh) dp.imp(mtzFilePath) dp.setTimeout(timeout) if pdbxFilePath is not None: dp.addInput(name="xyz_file_path", value=pdbxFilePath) dp.op("annot-sf-convert") dp.expLog(logFilePath) dp.expList(dstPathList=[outSfFilePath, diagfn, dmpfn]) if (not self.__debug): dp.cleanup() return True except: self.__lfh.write( "+DataFileAdapter.mtz2Pdbx() - failing for mtz file path %s output path %s\n" % (mtzFilePath, outSfFilePath)) traceback.print_exc(file=self.__lfh) return False
def testAnnotLigandMapCalc(self): """ Test create density maps -- """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: for pdbId in ['3of4']: # of2fofc=pdbId+"_2fofc.map" # offofc=pdbId+"_fofc.map" testFileXyz = pdbId + ".cif" testFileSf = pdbId + "-sf.cif" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) xyzPath = os.path.join(self.__testFilePath, testFileXyz) sfPath = os.path.join(self.__testFilePath, testFileSf) outMapPath = '.' outMapPathFull = os.path.abspath(outMapPath) # dp.imp(xyzPath) dp.addInput(name="sf_file_path", value=sfPath) dp.addInput(name="output_map_file_path", value=outMapPathFull) dp.op("annot-make-ligand-maps") dp.expLog(pdbId + "-annot-make-ligand-maps.log") # dp.expList(dstPathList=[of2fofc,offofc]) # dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def testAnnotValidateListXrayTest(self): """ Test create validation report for the test list of example PDB ids (NMR examples) """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: for pdbId in self.__testValidateXrayIdList: ofpdf = pdbId + "-valrpt.pdf" ofxml = pdbId + "-valdata.xml" offullpdf = pdbId + "-valrpt_full.pdf" ofpng = pdbId + "-val-slider.png" ofsvg = pdbId + "-val-slider.svg" # testFileValidateXyz = pdbId + ".cif" testFileValidateSf = pdbId + "-sf.cif" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) # dp.setDebugMode(True) xyzPath = os.path.abspath(os.path.join(self.__testFilePath, testFileValidateXyz)) sfPath = os.path.abspath(os.path.join(self.__testFilePath, testFileValidateSf)) #dp.addInput(name="request_annotation_context", value="yes") dp.addInput(name="request_validation_mode", value="annotate") #dp.addInput(name="request_validation_mode", value="server") dp.imp(xyzPath) dp.addInput(name="sf_file_path", value=sfPath) dp.op("annot-wwpdb-validate-all") dp.expLog(pdbId + "-annot-validate-test.log") dp.expList(dstPathList=[ofpdf, ofxml, offullpdf, ofpng, ofsvg]) # dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
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()
def testFixSpecialPosition(self): """ Test for fixing atoms on special position """ 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) # inpPath = os.path.join(self.__testFilePath, self.__testFileValidateXyz) dp.imp(inpPath) dp.op("annot-dcc-fix-special-position") dp.expLog("special-position-fix.log") dp.exp("special-position-output-fix.log") # No output - none on special self.assertEqual(['missing'], dp.getResultPathList()) f = open('special-position-output-fix.log', 'r') lines = f.read() f.close() self.assertIn('No atoms sit on special position', lines) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail() # This case has atoms on special position that needs correction try: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) # # dp.setDebugMode(True) # inpPath = os.path.join(self.__testFilePath, self.__testSpecialPosition) dp.imp(inpPath) dp.op("annot-dcc-fix-special-position") dp.expLog("special-position-fix2.log") dp.exp("special-position-output-fix2.log") print(dp.getResultPathList()) # We expect output self.assertNotEqual(['missing'], dp.getResultPathList()) dp.expList(dstPathList=['special-position-out-fix2.cif']) # Check output - for differences... f = open('special-position-output-fix2.log', 'r') lines = f.read() f.close() self.assertIn('Error: Wrong occupancy of 1.00 for atom (O : id=D_HOH_1)', lines) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
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()
def testSpecialPosition(self): """Test for atom on special position""" logger.info("\nStarting") try: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) # # dp.setDebugMode(True) # inpPath = os.path.join(self.__testFilePath, self.__testFileValidateXyz) dp.imp(inpPath) dp.op("annot-dcc-special-position") dp.expLog("special-position.log") dp.exp("special-position-output.log") f = open("special-position-output.log", "r") lines = f.read() f.close() self.assertIn("No atoms sit on special position", lines) dp.cleanup() except Exception as e: logger.exception("Failing with %s", str(e)) self.fail() # This case has atoms on special position that needs correction try: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) # # dp.setDebugMode(True) # inpPath = os.path.join(self.__testFilePath, self.__testSpecialPosition) dp.imp(inpPath) dp.op("annot-dcc-special-position") dp.expLog("special-position2.log") dp.exp("special-position-output2.log") f = open("special-position-output2.log", "r") lines = f.read() f.close() self.assertIn( "Error: Wrong occupancy of 1.00 for atom (O : id=D_HOH_1)", lines) dp.cleanup() except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def convert_em_volume(self, in_em_volume, out_binary_volume, working_dir): logging.debug(working_dir) rdb = RcsbDpUtility(tmpPath=working_dir, siteId=self.__site_id, verbose=True) rdb.imp(in_em_volume) rdb.op('em-density-bcif') rdb.exp(out_binary_volume) if out_binary_volume: if os.path.exists(out_binary_volume): return True return False
def testCifToPdb(self): """ """ logger.info("\nStarting") try: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) cifPath = os.path.join(self.__testFilePath, self.__testFileCif) dp.imp(cifPath) dp.op("cif2pdb") dp.exp("myTest1.pdb.gz") dp.expLog("myLog1.log.gz") # dp.cleanup() except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testCifCheck(self): """ """ logger.info("\nStarting") try: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) cifPath = os.path.join(self.__testFilePath, self.__testFileCif) dp.imp(cifPath) dp.op("check-cif") dp.exp("check-cif-diags.txt") dp.expLog("check-cif.log") # dp.cleanup() except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testPisaAnalysisCif(self): """ """ 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) cifPath = os.path.join(self.__testFilePath, self.__testFileCifPisa) dp.imp(cifPath) dp.addInput(name="pisa_session_name", value="session_test_cif") dp.op("pisa-analysis") dp.expLog("pisa-anal-cif.log.gz") dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
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 testAnnotMtz2PdbxGood(self): """ Test mtz to pdbx conversion (good mtz) """ self.__lfh.write( "\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) diagfn = os.path.join(self.__tmpPath, "sf-convert-diags.cif") ciffn = os.path.join(self.__tmpPath, "sf-convert-datafile.cif") dmpfn = os.path.join(self.__tmpPath, "sf-convert-mtzdmp.log") # dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) mtzPath = os.path.join(self.__testFilePath, self.__testFileMtzGood) dp.imp(mtzPath) dp.setTimeout(15) ret = dp.op("annot-sf-convert") dp.expLog(os.path.join(self.__tmpPath, "sf-convert.log")) dp.expList(dstPathList=[ciffn, diagfn, dmpfn]) # dp.cleanup() self.assertTrue(ret == 0) self.assertTrue(ciffn) self.assertTrue(diagfn) self.assertTrue(dmpfn)
def testMapFixRemote(self): """ Test mapfix utility """ self.__lfh.write( "\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) # inpPath = os.path.join(self.__testFilePath, self.__testMapNormal) of = os.path.join(self.__tmpPath, self.__testMapNormal + "-fix.map") dp.imp(inpPath) pixelSize = 2.54 #dp.addInput(name="pixel-spacing-x", value=pixelSize) #dp.addInput(name="pixel-spacing-y", value=pixelSize) #dp.addInput(name="pixel-spacing-z", value=pixelSize) dp.addInput(name="input_map_file_path", value=inpPath) dp.addInput(name="output_map_file_path", value=of) dp.addInput(name="label", value='test') dp.addInput(name="voxel", value='{0} {0} {0}'.format(pixelSize)) # dp.setRunRemote() ret = dp.op("deposit-update-map-header-in-place") dp.expLog(os.path.join(self.__tmpPath, "mapfix-big.log")) dp.exp(of) # dp.cleanup() self.assertTrue(ret == 0) self.assertTrue(os.path.exists(of))
def test_AnnotMergeRemote(self): """ Test of updating geometrical validation diagnostics - """ self.__lfh.write( "\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) for pdbId in self.__testValidateXrayIdList: self.__tmpPath = tempfile.mkdtemp( dir=self.__siteWebAppsSessionsPath) testFileValidateXyz = pdbId + ".cif" xyzPath = os.path.abspath( os.path.join(self.__testFilePath, testFileValidateXyz)) dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) of = os.path.join(self.__tmpPath, "annot-merge-xyz-remote.cif") dp.imp(xyzPath) dp.addInput(name="new_coordinate_file_path", value=xyzPath) dp.addInput(name="new_coordinate_format", value='cif') # dp.setRunRemote() ret = dp.op("annot-merge-xyz") dp.expLog( os.path.join(self.__tmpPath, "annot-merge-xyz-remote.log")) dp.exp(of) # dp.cleanup() self.assertTrue(ret == 0) self.assertTrue(os.path.exists(of))
def testCifCheckExt(self): """ """ logger.info("\nStarting") try: for name in ["deposit", "archive_current", "archive_next"]: dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) cifPath = os.path.join(self.__testFilePath, self.__testFileCif) dp.imp(cifPath) dp.addInput(name="dictionary", value=name) dp.op("check-cif-ext") dp.exp("check-cif-diags-%s.txt" % name) dp.expLog("check-cif-%s.log" % name) # dp.cleanup() except Exception as e: logger.exception("Failing with %s", str(e)) self.fail()
def testAnnotLinkSSBond(self): """ Calculate link and ss-bond features - """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: of = "annot-link-" + self.__testFileAnnotLink + ".gz" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotLink) dp.imp(inpPath) dp.op("annot-link-ssbond") dp.expLog("annot-link-ssbond.log") dp.exp(of) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def testAnnotValidation(self): """ Calculate geometrical validation - """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: of = "annot-validation-" + self.__testFileAnnotValidate + ".gz" dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotValidate) dp.imp(inpPath) dp.op("annot-validation") dp.expLog("annot-validation.log") dp.exp(of) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def testAnnotRcsb2PdbxStrip(self): """ RCSB CIF -> PDBx conversion (Using the smaller application in the annotation package) """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: of = "annot-rcsb2pdbx-strip-" + self.__testFileAnnotRcsb dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotRcsb) dp.imp(inpPath) dp.op("annot-rcsb2pdbx-strip") dp.expLog("annot-rcsb2pdbx-strip.log") dp.exp(of) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()
def testAnnotRepositionSolventPlusDerived(self): """ Calculate distant solvent followed by computing key derived categories -- """ logger.info("\nStarting %s %s\n" % (self.__class__.__name__, sys._getframe().f_code.co_name)) try: of = "annot-reposition-add-derived-" + self.__testFileAnnotSolvent dp = RcsbDpUtility(tmpPath=self.__tmpPath, siteId=self.__siteId, verbose=True) inpPath = os.path.join(self.__testFilePath, self.__testFileAnnotSolvent) dp.imp(inpPath) dp.op("annot-reposition-solvent-add-derived") dp.expLog("annot-reposition-solvent-plus-derived.log") dp.exp(of) dp.cleanup() except Exception as e: logger.exception("Failing with %s" % str(e)) self.fail()