def testExecute(self): self.run() # Compare results strXMLExpected = self.readAndParseFile(self.getReferenceDataOutputFile()) xsDataObtained = self.getPlugin().getDataOutput() xsDataExpected = XSDataMOSFLMOutputIndexing.parseString(strXMLExpected) EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), \ "(MOSFLM indexing result comparison - expected versus obtained)")
def testExecute(self): self.run() # Compare results strXMLExpected = self.readAndParseFile( self.getReferenceDataOutputFile()) xsDataObtained = self.getPlugin().getDataOutput() xsDataExpected = XSDataMOSFLMOutputIndexing.parseString(strXMLExpected) EDAssert.strAlmostEqual(xsDataExpected.marshal(), xsDataObtained.marshal(), \ "(MOSFLM indexing result comparison - expected versus obtained)", _fAbsError=1000.0)
def testGenerateXSDataIndexingResult(self): strFilename = "XSDataMOSFLMOutputIndexing_reference.xml" strPath = os.path.join(self.m_strDataPath, strFilename) strXMLMOSFLMOutputIndexing = EDUtilsTest.readAndParseFile(strPath) from XSDataMOSFLMv10 import XSDataMOSFLMOutputIndexing xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing.parseString(strXMLMOSFLMOutputIndexing) from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10 xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult(xsDataMOSFLMOutputIndexing) strReferenceFilename = "XSDataIndexingResult_reference.xml" strReferencePath = os.path.join(self.m_strDataPath, strReferenceFilename) strXMLIndexingOutputReference = EDUtilsTest.readAndParseFile(strReferencePath) from XSDataMXv1 import XSDataIndexingResult xsdataIndexingResultReference = XSDataIndexingResult.parseString(strXMLIndexingOutputReference) EDAssert.equal(xsdataIndexingResultReference.marshal(), xsDataIndexingResult.marshal())
def testGenerateExecutiveSummary(self): """ """ pluginIndexing = self.createPlugin() pluginIndexing.setScriptExecutable("cat") pluginIndexing.configure() from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing from XSDataMOSFLMv10 import XSDataMOSFLMOutputIndexing strMOSFLMInputIndexingXML = self.readAndParseFile(self.strReferenceDataInputFile) strMOSFLMOutputIndexingXML = self.readAndParseFile(self.strReferenceDataOutputFile) xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing.parseString(strMOSFLMInputIndexingXML) xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing.parseString(strMOSFLMOutputIndexingXML) pluginIndexing.setDataInput(xsDataMOSFLMInputIndexing) pluginIndexing.setDataOutput(xsDataMOSFLMOutputIndexing) pluginIndexing.generateExecutiveSummary(pluginIndexing) pluginIndexing.verboseScreenExecutiveSummary() self.cleanUp(pluginIndexing)
def testCreateDataMOSFLMOutputIndexing(self): """ """ pluginIndexing = self.createPlugin() pluginIndexing.setScriptExecutable("cat") pluginIndexing.configure() strBaseName = pluginIndexing.getBaseName() shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIndexingv10_outputDnaTables_ok.xml"), os.path.join(pluginIndexing.getWorkingDirectory(), strBaseName + "_dnaTables.xml")) strNewmatFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt") pluginIndexing.setNewmatFileName(strNewmatFile) xsDataMOSFLMOutputIndexing = pluginIndexing.createDataMOSFLMOutputIndexing() strReferenceXML = self.readAndParseFile(self.strReferenceDataOutputFile) xsDataMOSFLMOutputIndexingReference = XSDataMOSFLMOutputIndexing.parseString(strReferenceXML) #print len( strReferenceXML ) #print len( xsDataMOSFLMOutputIndexing.marshal() ) EDAssert.equal(xsDataMOSFLMOutputIndexingReference.marshal(), xsDataMOSFLMOutputIndexing.marshal()) self.cleanUp(pluginIndexing)
def testCreateDataMOSFLMOutputIndexing(self): """ """ pluginIndexing = self.createPlugin() pluginIndexing.setScriptExecutable("cat") pluginIndexing.configure() strBaseName = pluginIndexing.getBaseName() shutil.copyfile(os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMIndexingv10_outputDnaTables_ok.xml"), os.path.join(pluginIndexing.getWorkingDirectory(), strBaseName + "_dnaTables.xml")) strNewmatFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt") pluginIndexing.setNewmatFileName(strNewmatFile) xsDataMOSFLMOutputIndexing = pluginIndexing.createDataMOSFLMOutputIndexing() strReferenceXML = self.readAndParseFile(self.strReferenceDataOutputFile) xsDataMOSFLMOutputIndexingReference = XSDataMOSFLMOutputIndexing.parseString(strReferenceXML) #print len( strReferenceXML ) #print len( xsDataMOSFLMOutputIndexing.marshal() ) # Replace path to log file since it cannot be determined by the unit test xsDataMOSFLMOutputIndexing.setPathToLogFile(XSDataFile(XSDataString("MOSFLMIndexingv10.log"))) EDAssert.equal(xsDataMOSFLMOutputIndexingReference.marshal(), xsDataMOSFLMOutputIndexing.marshal()) self.cleanUp(pluginIndexing)
def testGenerateXSDataIndexingResult(self): strFilename = "XSDataMOSFLMOutputIndexing_reference.xml" strPath = os.path.join(self.m_strDataPath, strFilename) strXMLMOSFLMOutputIndexing = EDUtilsTest.readAndParseFile(strPath) from XSDataMOSFLMv10 import XSDataMOSFLMOutputIndexing xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing.parseString( strXMLMOSFLMOutputIndexing) from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10 xsDataIndexingResult = EDHandlerXSDataMOSFLMv10.generateXSDataIndexingResult( xsDataMOSFLMOutputIndexing) strReferenceFilename = "XSDataIndexingResult_reference.xml" strReferencePath = os.path.join(self.m_strDataPath, strReferenceFilename) strXMLIndexingOutputReference = EDUtilsTest.readAndParseFile( strReferencePath) from XSDataMXv1 import XSDataIndexingResult xsdataIndexingResultReference = XSDataIndexingResult.parseString( strXMLIndexingOutputReference) EDAssert.equal(xsdataIndexingResultReference.marshal(), xsDataIndexingResult.marshal())
def createDataMOSFLMOutputIndexing(self): EDVerbose.DEBUG("EDPluginMOSFLMIndexingv10.createDataMOSFLMOutputIndexing") xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing() # Read Newmat file xsDataMOSFLMNewmat = self.getDataMOSFLMNewmat() if (xsDataMOSFLMNewmat is None): strError = "MOSFLM indexing error : No solution was obtained!" EDVerbose.ERROR(strError) self.setFailure() else: xsDataMOSFLMOutputIndexing.setRefinedNewmat(xsDataMOSFLMNewmat) # Then read the XML file strDnaTablesXML = self.readProcessFile(self.getScriptBaseName() + "_dnaTables.xml") xsDataDnaTables = dna_tables.parseString(strDnaTablesXML) listXSTableMosaicityEstimation = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "mosaicity_estimation") dMosaicityValueSum = 0.0 nValues = 0 for xsTableMosaicityEstimation in listXSTableMosaicityEstimation: for xsListMosaicity in EDUtilsTable.getListsFromTable(xsTableMosaicityEstimation, "mosaicity"): dMosaicityValue = float(EDUtilsTable.getItemFromList(xsListMosaicity, "value").getValueOf_()) dMosaicityValueSum += dMosaicityValue nValues += 1 xsDataFloatMosaicityEstimation = XSDataFloat() xsDataFloatMosaicityEstimation.setValue(dMosaicityValueSum / nValues) xsDataMOSFLMOutputIndexing.setMosaicityEstimation(xsDataFloatMosaicityEstimation) xsTableRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "refinement") if (xsTableRefinement is None): strError = "MOSFLM indexing error : No solution was refined!" EDVerbose.ERROR(strError) self.setFailure() else: xsListDeviations = EDUtilsTable.getListsFromTable(xsTableRefinement, "deviations")[0] dDeviationAngular = float(EDUtilsTable.getItemFromList(xsListDeviations, "angular").getValueOf_()) dDeviationPositional = float(EDUtilsTable.getItemFromList(xsListDeviations, "positional").getValueOf_()) xsDataMOSFLMOutputIndexing.setDeviationAngular(XSDataAngle(dDeviationAngular)) xsDataMOSFLMOutputIndexing.setDeviationPositional(XSDataLength(dDeviationPositional)) xsListResults = EDUtilsTable.getListsFromTable(xsTableRefinement, "results")[0] dDetectorDistance = float(EDUtilsTable.getItemFromList(xsListResults, "detector_distance").getValueOf_()) xsDataMOSFLMOutputIndexing.setRefinedDistance(XSDataLength(dDetectorDistance)) xsListParameters = EDUtilsTable.getListsFromTable(xsTableRefinement, "parameters")[0] iSpotsUsed = int(EDUtilsTable.getItemFromList(xsListParameters, "used").getValueOf_()) iSpotsTotal = int(EDUtilsTable.getItemFromList(xsListParameters, "out_of").getValueOf_()) xsDataMOSFLMOutputIndexing.setSpotsUsed(XSDataInteger(iSpotsUsed)) xsDataMOSFLMOutputIndexing.setSpotsTotal(XSDataInteger(iSpotsTotal)) xsTableSolutionRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "solution_refinement") xsListParameters = EDUtilsTable.getListsFromTable(xsTableSolutionRefinement, "selection")[0] iSelectedSolutionNumber = int(EDUtilsTable.getItemFromList(xsListParameters, "number").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionNumber(XSDataInteger(iSelectedSolutionNumber)) strSelectedSolutionSpaceGroup = (EDUtilsTable.getItemFromList(xsListParameters, "spacegroup").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroup(XSDataString(strSelectedSolutionSpaceGroup)) iSelectedSolutionSpaceGroupNumber = int(EDUtilsTable.getItemFromList(xsListParameters, "spacegroup_number").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroupNumber(XSDataInteger(iSelectedSolutionSpaceGroupNumber)) xsTableAutoIndexSolutions = EDUtilsTable.getTableFromTables(xsDataDnaTables, "autoindex_solutions") xsListsSolution = xsTableAutoIndexSolutions.getList() for xsListSolution in xsListsSolution: xsDataMOSFLMIndexingSolution = XSDataMOSFLMIndexingSolution() xsDataCell = XSDataCell() iSolutionNumber = int(EDUtilsTable.getItemFromList(xsListSolution, "index").getValueOf_()) xsDataMOSFLMIndexingSolution.setIndex(XSDataInteger(iSolutionNumber)) iPenalty = int(EDUtilsTable.getItemFromList(xsListSolution, "penalty").getValueOf_()) xsDataMOSFLMIndexingSolution.setPenalty(XSDataInteger(iPenalty)) strLattice = (EDUtilsTable.getItemFromList(xsListSolution, "lattice").getValueOf_()) xsDataMOSFLMIndexingSolution.setLattice(XSDataString(strLattice)) dA = float(EDUtilsTable.getItemFromList(xsListSolution, "a").getValueOf_()) xsDataCell.setLength_a(XSDataLength(dA)) dB = float(EDUtilsTable.getItemFromList(xsListSolution, "b").getValueOf_()) xsDataCell.setLength_b(XSDataLength(dB)) dC = float(EDUtilsTable.getItemFromList(xsListSolution, "c").getValueOf_()) xsDataCell.setLength_c(XSDataLength(dC)) dAlpha = float(EDUtilsTable.getItemFromList(xsListSolution, "alpha").getValueOf_()) xsDataCell.setAngle_alpha(XSDataAngle(dAlpha)) dBeta = float(EDUtilsTable.getItemFromList(xsListSolution, "beta").getValueOf_()) xsDataCell.setAngle_beta(XSDataAngle(dBeta)) dGamma = float(EDUtilsTable.getItemFromList(xsListSolution, "gamma").getValueOf_()) xsDataCell.setAngle_gamma(XSDataAngle(dGamma)) xsDataMOSFLMIndexingSolution.setCell(xsDataCell) xsDataMOSFLMOutputIndexing.addPossibleSolutions(xsDataMOSFLMIndexingSolution) xsTableBeamRefinement = EDUtilsTable.getTableFromTables(xsDataDnaTables, "beam_refinement") xsDataMOSFLMBeamPositionRefined = XSDataMOSFLMBeamPosition() xsDataMOSFLMBeamPositionShift = XSDataMOSFLMBeamPosition() dInitialBeamX = 0.0 dInitialBeamY = 0.0 dRefinedBeamX = 0.0 dRefinedBeamY = 0.0 xsListInitialBeam = EDUtilsTable.getListsFromTable(xsTableBeamRefinement, "initial_beam")[0] fInitialBeamPositionX = float(EDUtilsTable.getItemFromList(xsListInitialBeam, "x").getValueOf_()) fInitialBeamPositionY = float(EDUtilsTable.getItemFromList(xsListInitialBeam, "y").getValueOf_()) xsListRefinedBeam = EDUtilsTable.getListsFromTable(xsTableBeamRefinement, "refined_beam")[0] fRefinedBeamPositionX = float(EDUtilsTable.getItemFromList(xsListRefinedBeam, "x").getValueOf_()) fRefinedBeamPositionY = float(EDUtilsTable.getItemFromList(xsListRefinedBeam, "y").getValueOf_()) xsDataMOSFLMBeamPositionRefined.setX(XSDataLength(fRefinedBeamPositionX)) xsDataMOSFLMBeamPositionRefined.setY(XSDataLength(fRefinedBeamPositionY)) xsDataMOSFLMBeamPositionShift.setX(XSDataLength(fInitialBeamPositionX - fRefinedBeamPositionX)) xsDataMOSFLMBeamPositionShift.setY(XSDataLength(fInitialBeamPositionY - fRefinedBeamPositionY)) xsDataMOSFLMOutputIndexing.setRefinedBeam(xsDataMOSFLMBeamPositionRefined) xsDataMOSFLMOutputIndexing.setBeamShift(xsDataMOSFLMBeamPositionShift) return xsDataMOSFLMOutputIndexing
def createDataMOSFLMOutputIndexing(self): self.DEBUG("EDPluginMOSFLMIndexingv10.createDataMOSFLMOutputIndexing") xsDataMOSFLMOutputIndexing = XSDataMOSFLMOutputIndexing() # Read Newmat file xsDataMOSFLMNewmat = self.getDataMOSFLMNewmat() if (xsDataMOSFLMNewmat is None): strError = "MOSFLM indexing error : No solution was obtained!" self.ERROR(strError) self.setFailure() else: xsDataMOSFLMOutputIndexing.setRefinedNewmat(xsDataMOSFLMNewmat) # Then read the XML file strDnaTablesXML = self.readProcessFile(self.getScriptBaseName() + "_dnaTables.xml") xsDataDnaTables = dna_tables.parseString(strDnaTablesXML) listXSTableMosaicityEstimation = EDUtilsTable.getTableListFromTables( xsDataDnaTables, "mosaicity_estimation") dMosaicityValueSum = 0.0 nValues = 0 for xsTableMosaicityEstimation in listXSTableMosaicityEstimation: for xsListMosaicity in EDUtilsTable.getListsFromTable( xsTableMosaicityEstimation, "mosaicity"): dMosaicityValue = float( EDUtilsTable.getItemFromList(xsListMosaicity, "value").getValueOf_()) dMosaicityValueSum += dMosaicityValue nValues += 1 xsDataFloatMosaicityEstimation = XSDataFloat() xsDataFloatMosaicityEstimation.setValue(dMosaicityValueSum / nValues) xsDataMOSFLMOutputIndexing.setMosaicityEstimation( xsDataFloatMosaicityEstimation) xsTableRefinement = EDUtilsTable.getTableFromTables( xsDataDnaTables, "refinement") if (xsTableRefinement is None): strError = "MOSFLM indexing error : No solution was refined!" self.ERROR(strError) self.setFailure() else: xsListDeviations = EDUtilsTable.getListsFromTable( xsTableRefinement, "deviations")[0] dDeviationAngular = float( EDUtilsTable.getItemFromList(xsListDeviations, "angular").getValueOf_()) dDeviationPositional = float( EDUtilsTable.getItemFromList(xsListDeviations, "positional").getValueOf_()) xsDataMOSFLMOutputIndexing.setDeviationAngular( XSDataAngle(dDeviationAngular)) xsDataMOSFLMOutputIndexing.setDeviationPositional( XSDataLength(dDeviationPositional)) xsListResults = EDUtilsTable.getListsFromTable( xsTableRefinement, "results")[0] dDetectorDistance = float( EDUtilsTable.getItemFromList( xsListResults, "detector_distance").getValueOf_()) xsDataMOSFLMOutputIndexing.setRefinedDistance( XSDataLength(dDetectorDistance)) xsListParameters = EDUtilsTable.getListsFromTable( xsTableRefinement, "parameters")[0] iSpotsUsed = int( EDUtilsTable.getItemFromList(xsListParameters, "used").getValueOf_()) iSpotsTotal = int( EDUtilsTable.getItemFromList(xsListParameters, "out_of").getValueOf_()) xsDataMOSFLMOutputIndexing.setSpotsUsed( XSDataInteger(iSpotsUsed)) xsDataMOSFLMOutputIndexing.setSpotsTotal( XSDataInteger(iSpotsTotal)) xsTableSolutionRefinement = EDUtilsTable.getTableFromTables( xsDataDnaTables, "solution_refinement") xsListParameters = EDUtilsTable.getListsFromTable( xsTableSolutionRefinement, "selection")[0] iSelectedSolutionNumber = int( EDUtilsTable.getItemFromList(xsListParameters, "number").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionNumber( XSDataInteger(iSelectedSolutionNumber)) strSelectedSolutionSpaceGroup = (EDUtilsTable.getItemFromList( xsListParameters, "spacegroup").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroup( XSDataString(strSelectedSolutionSpaceGroup)) iSelectedSolutionSpaceGroupNumber = int( EDUtilsTable.getItemFromList( xsListParameters, "spacegroup_number").getValueOf_()) xsDataMOSFLMOutputIndexing.setSelectedSolutionSpaceGroupNumber( XSDataInteger(iSelectedSolutionSpaceGroupNumber)) xsTableAutoIndexSolutions = EDUtilsTable.getTableFromTables( xsDataDnaTables, "autoindex_solutions") xsListsSolution = xsTableAutoIndexSolutions.getList() for xsListSolution in xsListsSolution: xsDataMOSFLMIndexingSolution = XSDataMOSFLMIndexingSolution( ) xsDataCell = XSDataCell() iSolutionNumber = int( EDUtilsTable.getItemFromList(xsListSolution, "index").getValueOf_()) xsDataMOSFLMIndexingSolution.setIndex( XSDataInteger(iSolutionNumber)) iPenalty = int( EDUtilsTable.getItemFromList(xsListSolution, "penalty").getValueOf_()) xsDataMOSFLMIndexingSolution.setPenalty( XSDataInteger(iPenalty)) strLattice = (EDUtilsTable.getItemFromList( xsListSolution, "lattice").getValueOf_()) xsDataMOSFLMIndexingSolution.setLattice( XSDataString(strLattice)) dA = float( EDUtilsTable.getItemFromList(xsListSolution, "a").getValueOf_()) xsDataCell.setLength_a(XSDataLength(dA)) dB = float( EDUtilsTable.getItemFromList(xsListSolution, "b").getValueOf_()) xsDataCell.setLength_b(XSDataLength(dB)) dC = float( EDUtilsTable.getItemFromList(xsListSolution, "c").getValueOf_()) xsDataCell.setLength_c(XSDataLength(dC)) dAlpha = float( EDUtilsTable.getItemFromList(xsListSolution, "alpha").getValueOf_()) xsDataCell.setAngle_alpha(XSDataAngle(dAlpha)) dBeta = float( EDUtilsTable.getItemFromList(xsListSolution, "beta").getValueOf_()) xsDataCell.setAngle_beta(XSDataAngle(dBeta)) dGamma = float( EDUtilsTable.getItemFromList(xsListSolution, "gamma").getValueOf_()) xsDataCell.setAngle_gamma(XSDataAngle(dGamma)) xsDataMOSFLMIndexingSolution.setCell(xsDataCell) xsDataMOSFLMOutputIndexing.addPossibleSolutions( xsDataMOSFLMIndexingSolution) xsTableBeamRefinement = EDUtilsTable.getTableFromTables( xsDataDnaTables, "beam_refinement") xsDataMOSFLMBeamPositionRefined = XSDataMOSFLMBeamPosition() xsDataMOSFLMBeamPositionShift = XSDataMOSFLMBeamPosition() dInitialBeamX = 0.0 dInitialBeamY = 0.0 dRefinedBeamX = 0.0 dRefinedBeamY = 0.0 xsListInitialBeam = EDUtilsTable.getListsFromTable( xsTableBeamRefinement, "initial_beam")[0] fInitialBeamPositionX = float( EDUtilsTable.getItemFromList(xsListInitialBeam, "x").getValueOf_()) fInitialBeamPositionY = float( EDUtilsTable.getItemFromList(xsListInitialBeam, "y").getValueOf_()) xsListRefinedBeam = EDUtilsTable.getListsFromTable( xsTableBeamRefinement, "refined_beam")[0] fRefinedBeamPositionX = float( EDUtilsTable.getItemFromList(xsListRefinedBeam, "x").getValueOf_()) fRefinedBeamPositionY = float( EDUtilsTable.getItemFromList(xsListRefinedBeam, "y").getValueOf_()) xsDataMOSFLMBeamPositionRefined.setX( XSDataLength(fRefinedBeamPositionX)) xsDataMOSFLMBeamPositionRefined.setY( XSDataLength(fRefinedBeamPositionY)) xsDataMOSFLMBeamPositionShift.setX( XSDataLength(fInitialBeamPositionX - fRefinedBeamPositionX)) xsDataMOSFLMBeamPositionShift.setY( XSDataLength(fInitialBeamPositionY - fRefinedBeamPositionY)) xsDataMOSFLMOutputIndexing.setRefinedBeam( xsDataMOSFLMBeamPositionRefined) xsDataMOSFLMOutputIndexing.setBeamShift( xsDataMOSFLMBeamPositionShift) # Path to log file xsDataMOSFLMOutputIndexing.setPathToLogFile( XSDataFile( XSDataString( os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName())))) return xsDataMOSFLMOutputIndexing