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 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