def testGenerateExecutiveSummary(self): """ This method tests the generateExecutiveSummary of the Labelit plugin. It contains no assert call so the contents of the executive summary is not tested. """ edPluginLabelitIndexingv1_1 = self.createPlugin() xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitIndexingv1_1.setDataInput(xmlInput1, "referenceImage") xmlInput2 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitIndexingv1_1.setDataInput(xmlInput2, "referenceImage") strLabelitScreenOutputFile = os.path.join( self.getPluginTestsDataHome(), "XSDataLabelitScreenOutput_reference.xml") strLabelitScreenOutputXML = self.readAndParseFile( strLabelitScreenOutputFile) from XSDataLabelitv1_1 import XSDataLabelitScreenOutput xsDataLabelitScreenOutputReference = XSDataLabelitScreenOutput.parseString( strLabelitScreenOutputXML) edPluginLabelitIndexingv1_1.setDataOutput( xsDataLabelitScreenOutputReference, "labelitScreenOutput") strLabelitMosflmScriptsOutputFile = os.path.join( self.getPluginTestsDataHome(), "XSDataLabelitMosflmScriptsOutput_reference.xml") strLabelitMosflmScriptsOutputXML = self.readAndParseFile( strLabelitMosflmScriptsOutputFile) from XSDataLabelitv1_1 import XSDataLabelitMosflmScriptsOutput xsDataLabelitMosflmScriptsOutputReference = XSDataLabelitMosflmScriptsOutput.parseString( strLabelitMosflmScriptsOutputXML) edPluginLabelitIndexingv1_1.setDataOutput( xsDataLabelitMosflmScriptsOutputReference, "mosflmScriptOutput") edPluginLabelitIndexingv1_1.generateExecutiveSummary( edPluginLabelitIndexingv1_1)
def testParseLabelitScreenOutput(self): """ This method test the parsing of the Labelit results in the log file. """ edPluginLabelitIndexingv1_1 = self.createPlugin() strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(), "labelit_v1000rc11.log") strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText) xsDataLabelitScreenOutput = edPluginLabelitIndexingv1_1.parseLabelitScreenOutput(strLabelitLogText) strLabelitScreenOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitScreenOutput_reference.xml") strLabelitScreenOutputXML = self.readAndParseFile(strLabelitScreenOutputFile) from XSDataLabelitv1_1 import XSDataLabelitScreenOutput xsDataLabelitScreenOutputReference = XSDataLabelitScreenOutput.parseString(strLabelitScreenOutputXML) EDAssert.equal(xsDataLabelitScreenOutputReference.marshal(), xsDataLabelitScreenOutput.marshal())
def testParseLabelitScreenOutput(self): """ This method test the parsing of the Labelit results in the log file. """ edPluginLabelitIndexingv1_1 = self.createPlugin() strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(), "labelit_v1000rc11.log") strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText) xsDataLabelitScreenOutput = edPluginLabelitIndexingv1_1.parseLabelitScreenOutput( strLabelitLogText) strLabelitScreenOutputFile = os.path.join( self.getPluginTestsDataHome(), "XSDataLabelitScreenOutput_reference.xml") strLabelitScreenOutputXML = self.readAndParseFile( strLabelitScreenOutputFile) from XSDataLabelitv1_1 import XSDataLabelitScreenOutput xsDataLabelitScreenOutputReference = XSDataLabelitScreenOutput.parseString( strLabelitScreenOutputXML) EDAssert.equal(xsDataLabelitScreenOutputReference.marshal(), xsDataLabelitScreenOutput.marshal())
def testGenerateExecutiveSummary(self): """ This method tests the generateExecutiveSummary of the Labelit plugin. It contains no assert call so the contents of the executive summary is not tested. """ edPluginLabelitIndexingv1_1 = self.createPlugin() xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitIndexingv1_1.setDataInput(xmlInput1, "referenceImage") xmlInput2 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitIndexingv1_1.setDataInput(xmlInput2, "referenceImage") strLabelitScreenOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitScreenOutput_reference.xml") strLabelitScreenOutputXML = self.readAndParseFile(strLabelitScreenOutputFile) from XSDataLabelitv1_1 import XSDataLabelitScreenOutput xsDataLabelitScreenOutputReference = XSDataLabelitScreenOutput.parseString(strLabelitScreenOutputXML) edPluginLabelitIndexingv1_1.setDataOutput(xsDataLabelitScreenOutputReference, "labelitScreenOutput") strLabelitMosflmScriptsOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitMosflmScriptsOutput_reference.xml") strLabelitMosflmScriptsOutputXML = self.readAndParseFile(strLabelitMosflmScriptsOutputFile) from XSDataLabelitv1_1 import XSDataLabelitMosflmScriptsOutput xsDataLabelitMosflmScriptsOutputReference = XSDataLabelitMosflmScriptsOutput.parseString(strLabelitMosflmScriptsOutputXML) edPluginLabelitIndexingv1_1.setDataOutput(xsDataLabelitMosflmScriptsOutputReference, "mosflmScriptOutput") edPluginLabelitIndexingv1_1.generateExecutiveSummary(edPluginLabelitIndexingv1_1)
def parseLabelitScreenOutput(self, _strLabelitLogText): """ This method parses the labelit.screen log and populates the relevant parts of the XSDataLabelitScreenOutput object which is then returned. """ self.DEBUG("EDPluginLabelitIndexingv1_1.parseLabelitLogText") xsDataLabelitScreenOutput = None iIndex = 0 listLogLines = _strLabelitLogText.split('\n') bFoundLabelitIndexingResults = False bContinue = True while (bContinue): if (listLogLines[iIndex].find("LABELIT Indexing results:") != -1): bFoundLabelitIndexingResults = True bContinue = False else: if (iIndex < (len(listLogLines) - 2)): iIndex += 1 else: bContinue = False if (bFoundLabelitIndexingResults == False): strErrorMessage = "EDPluginLabelitIndexingv1_1.parseLabelitLogText : Labelit log message: %s" % _strLabelitLogText self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() else: # We found some indexing results! xsDataLabelitScreenOutput = XSDataLabelitScreenOutput() iIndex += 1 strBeamDistanceMosaicity = listLogLines[iIndex] strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace( ',', '') strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace( 'mm', ' ') strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace( '=', ' ') listStringBeamDistanceMosaicity = strBeamDistanceMosaicity.split() fBeamX = float(listStringBeamDistanceMosaicity[3]) fBeamY = float(listStringBeamDistanceMosaicity[5]) xsDataLabelitScreenOutput.setBeamCentreX(XSDataLength(fBeamX)) xsDataLabelitScreenOutput.setBeamCentreY(XSDataLength(fBeamY)) fDistance = float(listStringBeamDistanceMosaicity[7]) xsDataLabelitScreenOutput.setDistance(XSDataLength(fDistance)) fMosaicity = float(listStringBeamDistanceMosaicity[11]) xsDataLabelitScreenOutput.setMosaicity(XSDataAngle(fMosaicity)) iIndex += 3 bContinue = True bFoundSelectedSolution = False while (bContinue): xsDataLabelitScreenSolution = XSDataLabelitScreenSolution() strLabelitSolution = listLogLines[iIndex] listStringLabelitSolution = strLabelitSolution.split() if (listStringLabelitSolution[0] == ":)"): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(True)) elif (listStringLabelitSolution[0] == ":("): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False)) elif (listStringLabelitSolution[0] == ";("): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False)) else: # We have an error... strErrorMessage = "Indexing with labelit.screen failed! Log file:" self.ERROR(strErrorMessage) self.addErrorMessage(strErrorMessage) self.ERROR(_strLabelitLogText) self.addErrorMessage(_strLabelitLogText) self.setFailure() bContinue = False if bContinue: iSolutionNumber = int(listStringLabelitSolution[1]) xsDataLabelitScreenSolution.setSolutionNumber( XSDataInteger(iSolutionNumber)) fMetricFitValue = float(listStringLabelitSolution[2]) xsDataLabelitScreenSolution.setMetricFitValue( XSDataDouble(fMetricFitValue)) strMetricFitCode = listStringLabelitSolution[3] xsDataLabelitScreenSolution.setMetricFitCode( XSDataString(strMetricFitCode)) fRMSD = float(listStringLabelitSolution[4]) xsDataLabelitScreenSolution.setRmsd(XSDataLength(fRMSD)) iNumberOfSpots = int(listStringLabelitSolution[5]) xsDataLabelitScreenSolution.setNumberOfSpots( XSDataInteger(iNumberOfSpots)) strCrystalSystem = listStringLabelitSolution[6] strBravaisLattice = listStringLabelitSolution[7] xsDataLabelitScreenSolution.setCrystalSystem( XSDataString(strCrystalSystem)) xsDataLabelitScreenSolution.setBravaisLattice( XSDataString(strBravaisLattice)) xsDataCell = XSDataCell() xsDataCell.setLength_a( XSDataLength(float(listStringLabelitSolution[8]))) xsDataCell.setLength_b( XSDataLength(float(listStringLabelitSolution[9]))) xsDataCell.setLength_c( XSDataLength(float(listStringLabelitSolution[10]))) xsDataCell.setAngle_alpha( XSDataAngle(float(listStringLabelitSolution[11]))) xsDataCell.setAngle_beta( XSDataAngle(float(listStringLabelitSolution[12]))) xsDataCell.setAngle_gamma( XSDataAngle(float(listStringLabelitSolution[13]))) xsDataLabelitScreenSolution.setUnitCell(xsDataCell) iVolume = int(listStringLabelitSolution[14]) xsDataLabelitScreenSolution.setVolume( XSDataInteger(iVolume)) # Find the selected solution if (bFoundSelectedSolution == False): if (xsDataLabelitScreenSolution.getHappy().getValue() == True): # Check if forced space group if self.__strForcedSpaceGroup == None: bFoundSelectedSolution = True xsDataLabelitScreenOutput.setSelectedSolutionNumber( XSDataInteger(iSolutionNumber)) else: listBravaisLattice = self.getBravaisLatticeFromSpaceGroup( self.__strForcedSpaceGroup) for strPossibleBravaisLattice in listBravaisLattice: if strBravaisLattice == strPossibleBravaisLattice: bFoundSelectedSolution = True xsDataLabelitScreenOutput.setSelectedSolutionNumber( XSDataInteger(iSolutionNumber)) xsDataLabelitScreenOutput.addLabelitScreenSolution( xsDataLabelitScreenSolution) if (iIndex < (len(listLogLines) - 2)): iIndex += 1 else: bContinue = False return xsDataLabelitScreenOutput
def parseLabelitScreenOutput(self, _strLabelitLogText): """ This method parses the labelit.screen log and populates the relevant parts of the XSDataLabelitScreenOutput object which is then returned. """ self.DEBUG("EDPluginLabelitIndexingv1_1.parseLabelitLogText") xsDataLabelitScreenOutput = None iIndex = 0 listLogLines = _strLabelitLogText.split('\n') bFoundLabelitIndexingResults = False bContinue = True while (bContinue) : if (listLogLines[ iIndex ].find("LABELIT Indexing results:") != -1) : bFoundLabelitIndexingResults = True bContinue = False else: if (iIndex < (len(listLogLines) - 2)): iIndex += 1 else: bContinue = False if (bFoundLabelitIndexingResults == False): strErrorMessage = "EDPluginLabelitIndexingv1_1.parseLabelitLogText : Labelit log message: %s" % _strLabelitLogText self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() else: # We found some indexing results! xsDataLabelitScreenOutput = XSDataLabelitScreenOutput() iIndex += 1 strBeamDistanceMosaicity = listLogLines[ iIndex ] strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace(',', '') strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace('mm', ' ') strBeamDistanceMosaicity = strBeamDistanceMosaicity.replace('=', ' ') listStringBeamDistanceMosaicity = strBeamDistanceMosaicity.split() fBeamX = float(listStringBeamDistanceMosaicity[3]) fBeamY = float(listStringBeamDistanceMosaicity[5]) xsDataLabelitScreenOutput.setBeamCentreX(XSDataLength(fBeamX)) xsDataLabelitScreenOutput.setBeamCentreY(XSDataLength(fBeamY)) fDistance = float(listStringBeamDistanceMosaicity[7]) xsDataLabelitScreenOutput.setDistance(XSDataLength(fDistance)) fMosaicity = float(listStringBeamDistanceMosaicity[11]) xsDataLabelitScreenOutput.setMosaicity(XSDataAngle(fMosaicity)) iIndex += 3 bContinue = True bFoundSelectedSolution = False while (bContinue): xsDataLabelitScreenSolution = XSDataLabelitScreenSolution() strLabelitSolution = listLogLines[ iIndex ] listStringLabelitSolution = strLabelitSolution.split() if (listStringLabelitSolution[0] == ":)"): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(True)) elif (listStringLabelitSolution[0] == ":("): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False)) elif (listStringLabelitSolution[0] == ";("): xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False)) else: # We have an error... strErrorMessage = "Indexing with labelit.screen failed! Log file:" self.ERROR(strErrorMessage) self.addErrorMessage(strErrorMessage) self.ERROR(_strLabelitLogText) self.addErrorMessage(_strLabelitLogText) self.setFailure() bContinue = False if bContinue: iSolutionNumber = int(listStringLabelitSolution[1]) xsDataLabelitScreenSolution.setSolutionNumber(XSDataInteger(iSolutionNumber)) fMetricFitValue = float(listStringLabelitSolution[2]) xsDataLabelitScreenSolution.setMetricFitValue(XSDataDouble(fMetricFitValue)) strMetricFitCode = listStringLabelitSolution[3] xsDataLabelitScreenSolution.setMetricFitCode(XSDataString(strMetricFitCode)) fRMSD = float(listStringLabelitSolution[4]) xsDataLabelitScreenSolution.setRmsd(XSDataLength(fRMSD)) iNumberOfSpots = int(listStringLabelitSolution[5]) xsDataLabelitScreenSolution.setNumberOfSpots(XSDataInteger(iNumberOfSpots)) strCrystalSystem = listStringLabelitSolution[6] strBravaisLattice = listStringLabelitSolution[7] xsDataLabelitScreenSolution.setCrystalSystem(XSDataString(strCrystalSystem)) xsDataLabelitScreenSolution.setBravaisLattice(XSDataString(strBravaisLattice)) xsDataCell = XSDataCell() xsDataCell.setLength_a(XSDataLength(float(listStringLabelitSolution[ 8]))) xsDataCell.setLength_b(XSDataLength(float(listStringLabelitSolution[ 9]))) xsDataCell.setLength_c(XSDataLength(float(listStringLabelitSolution[10]))) xsDataCell.setAngle_alpha(XSDataAngle(float(listStringLabelitSolution[11]))) xsDataCell.setAngle_beta(XSDataAngle(float(listStringLabelitSolution[12]))) xsDataCell.setAngle_gamma(XSDataAngle(float(listStringLabelitSolution[13]))) xsDataLabelitScreenSolution.setUnitCell(xsDataCell) iVolume = int(listStringLabelitSolution[14]) xsDataLabelitScreenSolution.setVolume(XSDataInteger(iVolume)) # Find the selected solution if (bFoundSelectedSolution == False): if (xsDataLabelitScreenSolution.getHappy().getValue() == True): # Check if forced space group if self.__strForcedSpaceGroup == None or self.__strForcedSpaceGroup == "": bFoundSelectedSolution = True xsDataLabelitScreenOutput.setSelectedSolutionNumber(XSDataInteger(iSolutionNumber)) else: listBravaisLattice = self.getBravaisLatticeFromSpaceGroup(self.__strForcedSpaceGroup) for strPossibleBravaisLattice in listBravaisLattice: if strBravaisLattice == strPossibleBravaisLattice: bFoundSelectedSolution = True xsDataLabelitScreenOutput.setSelectedSolutionNumber(XSDataInteger(iSolutionNumber)) xsDataLabelitScreenOutput.addLabelitScreenSolution(xsDataLabelitScreenSolution) if (iIndex < (len(listLogLines) - 2)): iIndex += 1 else: bContinue = False return xsDataLabelitScreenOutput