def testExecute(self): self.run() # Compare results strXMLExpected = self.readAndParseFile(self.__strReferenceDataOutputFile) xsDataObtained = self.getPlugin().getDataOutput() xsDataExpected = XSDataMOSFLMOutputIntegration.parseString(strXMLExpected) # Remove the bestFileHKL part which creates problem... xsDataObtained.setBestfileHKL(None) xsDataExpected.setBestfileHKL(None) EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), "(MOSFLM integration result comparison - expected versus obtained)", 0.1, 5000)
def testGenerateExecutiveSummary(self): pluginIntegration = self.createPlugin() pluginIntegration.setScriptExecutable("cat") pluginIntegration.configure() from XSDataMOSFLMv10 import XSDataMOSFLMInputIntegration strMOSFLMInputIntegrationXML = self.readAndParseFile(self.strReferenceDataInputFile) strMOSFLMOutputIntegrationXML = self.readAndParseFile(self.strReferenceDataOutputFile) xsDataMOSFLMInputIntegration = XSDataMOSFLMInputIntegration.parseString(strMOSFLMInputIntegrationXML) xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration.parseString(strMOSFLMOutputIntegrationXML) pluginIntegration.setDataInput(xsDataMOSFLMInputIntegration) pluginIntegration.setDataOutput(xsDataMOSFLMOutputIntegration) pluginIntegration.generateExecutiveSummary(pluginIntegration) pluginIntegration.verboseScreenExecutiveSummary() self.cleanUp(pluginIntegration)
def testGenerateXSDataIntegrationSubWedgeResult(self): strFilename = "XSDataMOSFLMOutputIntegration_reference.xml" strPath = os.path.join(self.m_strDataPath, strFilename) strXMLMOSFLMOutputIntegration = EDUtilsTest.readAndParseFile(strPath) from XSDataMOSFLMv10 import XSDataMOSFLMOutputIntegration xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration.parseString(strXMLMOSFLMOutputIntegration) from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10 xsDataIntegrationSubWedgeResult = EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationSubWedgeResult(xsDataMOSFLMOutputIntegration) strReferenceFilename = "XSDataIntegrationSubWedgeResult_reference.xml" strReferencePath = os.path.join(self.m_strDataPath, strReferenceFilename) strXMLIntegrationSubWedgeReference = EDUtilsTest.readAndParseFile(strReferencePath) from XSDataMXv1 import XSDataIntegrationSubWedgeResult xsDataIntegrationSubWedgeResult = XSDataIntegrationSubWedgeResult.parseString(strXMLIntegrationSubWedgeReference) EDAssert.equal(xsDataIntegrationSubWedgeResult.marshal(), xsDataIntegrationSubWedgeResult.marshal())
def testExecute(self): self.run() # Compare results strXMLExpected = self.readAndParseFile( self.__strReferenceDataOutputFile) xsDataObtained = self.getPlugin().getDataOutput() xsDataExpected = XSDataMOSFLMOutputIntegration.parseString( strXMLExpected) # Remove the bestFileHKL part which creates problem... xsDataObtained.setBestfileHKL(None) xsDataExpected.setBestfileHKL(None) EDAssert.strAlmostEqual( xsDataExpected.marshal(), xsDataObtained.marshal(), "(MOSFLM integration result comparison - expected versus obtained)", 0.1, 5000)
def testCreateDataMOSFLMOutputIntegration(self): pluginIntegration = self.createPlugin() pluginIntegration.setScriptExecutable("cat") pluginIntegration.configure() strBaseName = pluginIntegration.getBaseName() shutil.copyfile( os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileDat_ok.txt"), os.path.join(pluginIntegration.getWorkingDirectory(), "bestfile.dat")) shutil.copyfile( os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfilePar_ok.txt"), os.path.join(pluginIntegration.getWorkingDirectory(), "bestfile.par")) shutil.copyfile( os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileHKL_ok.txt"), os.path.join(pluginIntegration.getWorkingDirectory(), "bestfile.hkl")) shutil.copyfile( os.path.join( self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_outputDnaTables_ok.xml"), os.path.join(pluginIntegration.getWorkingDirectory(), strBaseName + "_dnaTables.xml")) strMatrixFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt") pluginIntegration.setMatrixFileName(strMatrixFile) xsDataMOSFLMIntegrationOutput = pluginIntegration.createDataMOSFLMOutputIntegration( ) # Fix problem with absolute path by replacing it with a fixed one xsDataFile = XSDataFile() xsDataFile.setPath( XSDataString("/tmp/EDPluginMOSFLMIntegrationv10_process_1_1.mtz")) xsDataMOSFLMIntegrationOutput.setGeneratedMTZFile(xsDataFile) strReferenceXML = self.readAndParseFile( self.strReferenceDataOutputFile) xsDataMOSFLMIntegrationOutputReference = XSDataMOSFLMOutputIntegration.parseString( strReferenceXML) # Replace path to log file since it cannot be determined by the unit test xsDataMOSFLMIntegrationOutput.setPathToLogFile( XSDataFile(XSDataString("MOSFLMIntegrationv10.log"))) EDAssert.equal(xsDataMOSFLMIntegrationOutputReference.marshal(), xsDataMOSFLMIntegrationOutput.marshal())
def testGenerateExecutiveSummary(self): pluginIntegration = self.createPlugin() pluginIntegration.setScriptExecutable("cat") pluginIntegration.configure() from XSDataMOSFLMv10 import XSDataMOSFLMInputIntegration strMOSFLMInputIntegrationXML = self.readAndParseFile( self.strReferenceDataInputFile) strMOSFLMOutputIntegrationXML = self.readAndParseFile( self.strReferenceDataOutputFile) xsDataMOSFLMInputIntegration = XSDataMOSFLMInputIntegration.parseString( strMOSFLMInputIntegrationXML) xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration.parseString( strMOSFLMOutputIntegrationXML) pluginIntegration.setDataInput(xsDataMOSFLMInputIntegration) pluginIntegration.setDataOutput(xsDataMOSFLMOutputIntegration) pluginIntegration.generateExecutiveSummary(pluginIntegration) pluginIntegration.verboseScreenExecutiveSummary() self.cleanUp(pluginIntegration)
def testCreateDataMOSFLMOutputIntegration(self): pluginIntegration = self.createPlugin() pluginIntegration.setScriptExecutable("cat") pluginIntegration.configure() strBaseName = pluginIntegration.getBaseName() shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileDat_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.dat")) shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfilePar_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.par")) shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_bestfileHKL_ok.txt"), os.path.join (pluginIntegration.getWorkingDirectory(), "bestfile.hkl")) shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIntegrationv10_outputDnaTables_ok.xml"), os.path.join(pluginIntegration.getWorkingDirectory(), strBaseName + "_dnaTables.xml")) strMatrixFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt") pluginIntegration.setMatrixFileName(strMatrixFile) xsDataMOSFLMIntegrationOutput = pluginIntegration.createDataMOSFLMOutputIntegration() # Fix problem with absolute path by replacing it with a fixed one xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString("/tmp/EDPluginMOSFLMIntegrationv10_process_1_1.mtz")) xsDataMOSFLMIntegrationOutput.setGeneratedMTZFile(xsDataFile) strReferenceXML = self.readAndParseFile(self.strReferenceDataOutputFile) xsDataMOSFLMIntegrationOutputReference = XSDataMOSFLMOutputIntegration.parseString(strReferenceXML) EDAssert.equal(xsDataMOSFLMIntegrationOutputReference.marshal(), xsDataMOSFLMIntegrationOutput.marshal())
def testGenerateXSDataIntegrationSubWedgeResult(self): strFilename = "XSDataMOSFLMOutputIntegration_reference.xml" strPath = os.path.join(self.m_strDataPath, strFilename) strXMLMOSFLMOutputIntegration = EDUtilsTest.readAndParseFile(strPath) from XSDataMOSFLMv10 import XSDataMOSFLMOutputIntegration xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration.parseString( strXMLMOSFLMOutputIntegration) from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10 xsDataIntegrationSubWedgeResult = EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationSubWedgeResult( xsDataMOSFLMOutputIntegration) strReferenceFilename = "XSDataIntegrationSubWedgeResult_reference.xml" strReferencePath = os.path.join(self.m_strDataPath, strReferenceFilename) strXMLIntegrationSubWedgeReference = EDUtilsTest.readAndParseFile( strReferencePath) from XSDataMXv1 import XSDataIntegrationSubWedgeResult xsDataIntegrationSubWedgeResult = XSDataIntegrationSubWedgeResult.parseString( strXMLIntegrationSubWedgeReference) EDAssert.equal(xsDataIntegrationSubWedgeResult.marshal(), xsDataIntegrationSubWedgeResult.marshal())
def createDataMOSFLMOutputIntegration(self): self.DEBUG("EDPluginMOSFLMIntegrationv10.createDataMOSFLMOutputIntegration") xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration() # Read bestfile.par, bestfile.hkl and bestfile.dat strBestfilePar = self.readBestFile("bestfile.par") bContinue = True if (strBestfilePar is not None): xsDataMOSFLMOutputIntegration.setBestfilePar(XSDataString(strBestfilePar)) else: bContinue = False if bContinue: strBestfileHKL = self.readBestFile("bestfile.hkl") if (strBestfileHKL is not None): xsDataMOSFLMOutputIntegration.setBestfileHKL(XSDataString(strBestfileHKL)) else: bContinue = False if bContinue: strBestfileDat = self.readBestFile("bestfile.dat") if (strBestfileDat is not None): xsDataMOSFLMOutputIntegration.setBestfileDat(XSDataString(strBestfileDat)) else: bContinue = False if bContinue: strDnaTablesXML = self.readProcessFile(self.getBaseName() + "_dnaTables.xml") xsDataDnaTables = dna_tables.parseString(strDnaTablesXML) xsTableIntegrationResults = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_results") xsListFinalResiduals = EDUtilsTable.getListsFromTable(xsTableIntegrationResults, "final_residuals")[0] strRMSSpotDeviation = EDUtilsTable.getItemFromList(xsListFinalResiduals, "rms").getValueOf_() xsDataMOSFLMOutputIntegration.setRMSSpotDeviation(XSDataLength(float(strRMSSpotDeviation))) strBeamPositionX = EDUtilsTable.getItemFromList(xsListFinalResiduals, "xcen").getValueOf_() strBeamPositionY = EDUtilsTable.getItemFromList(xsListFinalResiduals, "ycen").getValueOf_() xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition() xsDataMOSFLMBeamPosition.setX(XSDataLength(float(strBeamPositionX))) xsDataMOSFLMBeamPosition.setY(XSDataLength(float(strBeamPositionY))) xsDataMOSFLMOutputIntegration.setRefinedBeam(xsDataMOSFLMBeamPosition) xsDataMOSFLMNewmatMatrix = self.getDataMOSFLMMatrix() xsDataMOSFLMOutputIntegration.setRefinedNewmat(xsDataMOSFLMNewmatMatrix) # New results (described in bug #63) xsTableIntegrationOutput = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_output") xsListOutputFiles = EDUtilsTable.getListsFromTable(xsTableIntegrationOutput, "output_files")[0] strMTZFilename = EDUtilsTable.getItemFromList(xsListOutputFiles, "hklout").getValueOf_() strMTZPath = os.path.join(self.getWorkingDirectory(), strMTZFilename) xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(strMTZPath)) xsDataMOSFLMOutputIntegration.setGeneratedMTZFile(xsDataFile) xsTableSummaryInformation = EDUtilsTable.getTableFromTables(xsDataDnaTables, "summary_information") xsListSummary = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "summary")[0] xsListSpots = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "spots")[0] strDistance = EDUtilsTable.getItemFromList(xsListSummary, "distance").getValueOf_() xsDataMOSFLMOutputIntegration.setRefinedDistance(XSDataLength(float(strDistance))) strYScale = EDUtilsTable.getItemFromList(xsListSummary, "yscale").getValueOf_() xsDataMOSFLMOutputIntegration.setRefinedYScale(XSDataFloat(float(strYScale))) strOverallIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigall").getValueOf_() xsDataMOSFLMOutputIntegration.setOverallIOverSigma(XSDataFloat(float(strOverallIOverSigma))) strHighestResolutionIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigout").getValueOf_() xsDataMOSFLMOutputIntegration.setHighestResolutionIOverSigma(XSDataFloat(float(strHighestResolutionIOverSigma))) strNumberOfBadReflections = EDUtilsTable.getItemFromList(xsListSpots, "bad_spots").getValueOf_() xsDataMOSFLMOutputIntegration.setNumberOfBadReflections(XSDataInteger(int(strNumberOfBadReflections))) strNumberOfFullyRecordedReflections = EDUtilsTable.getItemFromList(xsListSpots, "full").getValueOf_() xsDataMOSFLMOutputIntegration.setNumberOfFullyRecordedReflections(XSDataInteger(int(strNumberOfFullyRecordedReflections))) strNumberOfNegativeReflections = EDUtilsTable.getItemFromList(xsListSpots, "negative").getValueOf_() xsDataMOSFLMOutputIntegration.setNumberOfNegativeReflections(XSDataInteger(int(strNumberOfNegativeReflections))) strNumberOfOverlappedReflections = EDUtilsTable.getItemFromList(xsListSpots, "overlap").getValueOf_() xsDataMOSFLMOutputIntegration.setNumberOfOverlappedReflections(XSDataInteger(int(strNumberOfOverlappedReflections))) strNumberOfPartialReflections = EDUtilsTable.getItemFromList(xsListSpots, "partial").getValueOf_() xsDataMOSFLMOutputIntegration.setNumberOfPartialReflections(XSDataInteger(int(strNumberOfPartialReflections))) # Fill in the statistics xsDataMOSFLMOutputIntegration.setOverallStatistics(self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, "bin_0")) iIndex = 1 bContinue = True fMinResolution = None while (bContinue == True): strBin = "bin_%d" % iIndex # I don't know how many intensity bins there are. Since the EDUtilsTable.getListsFromTable # method crashes if the list is not present, I had to wrap the calls to this method in # try - except: try: xsDataMOSFLMIntegrationStatisticsPerResolutionBin = self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, strBin, fMinResolution) fMinResolution = xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution().getValue() xsDataMOSFLMOutputIntegration.addStatisticsPerResolutionBin(xsDataMOSFLMIntegrationStatisticsPerResolutionBin) iIndex += 1 except: bContinue = False # Path to log file xsDataMOSFLMOutputIntegration.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName())))) return xsDataMOSFLMOutputIntegration
def __init__(self): EDPluginMOSFLMv10.__init__(self) self.setXSDataInputClass(XSDataMOSFLMInputIntegration) self.setDataOutput(XSDataMOSFLMOutputIntegration())