def finallyProcess(self, _edObject=None): """ Parses the labelit.screen log file and the generated MOSFLM script """ EDPluginExecProcessScript.finallyProcess(self, _edObject) self.DEBUG("EDPluginDistlSignalStrengthThinClientv1_1.finallyProcess") strLabelitDistlLog = self.readProcessLogFile() if (strLabelitDistlLog is None): strErrorMessage = "EDPluginDistlSignalStrengthThinClientv1_1.finallyProcess : Could not read the Labelit log file" self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() xsDataImageQualityIndicators = XSDataImageQualityIndicators() xsDataImageQualityIndicators.setImage(self.xsDataImage) elif strLabelitDistlLog == "": strLabelitDislErr = self.readProcessErrorLogFile() if "httplib.BadStatusLine" in strLabelitDislErr: strErrorMessage = "Cannot read image due to problem with file permission!" else: strErrorMessage = "Labelit thin client error message: " + strLabelitDislErr self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() xsDataImageQualityIndicators = XSDataImageQualityIndicators() xsDataImageQualityIndicators.setImage(self.xsDataImage) else: xsDataImageQualityIndicators = self.parseLabelitDistlOutput( strLabelitDistlLog) xsDataImageQualityIndicators.setImage(self.xsDataImage) xsDataResultDistlSignalStrength = XSDataResultDistlSignalStrength() xsDataResultDistlSignalStrength.setImageQualityIndicators( xsDataImageQualityIndicators) self.setDataOutput(xsDataResultDistlSignalStrength)
def finallyProcess(self, _edObject=None): """ Parses the labelit.screen log file and the generated MOSFLM script """ EDPluginExecProcessScript.finallyProcess(self, _edObject) self.DEBUG("EDPluginDistlSignalStrengthThinClientv1_1.finallyProcess") strLabelitDistlLog = self.readProcessLogFile() if (strLabelitDistlLog is None): strErrorMessage = "EDPluginDistlSignalStrengthThinClientv1_1.finallyProcess : Could not read the Labelit log file" self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() xsDataImageQualityIndicators = XSDataImageQualityIndicators() xsDataImageQualityIndicators.setImage(self.xsDataImage) elif strLabelitDistlLog == "": strLabelitDislErr = self.readProcessErrorLogFile() if "httplib.BadStatusLine" in strLabelitDislErr: strErrorMessage = "Cannot read image due to problem with file permission!" else: strErrorMessage = "Labelit thin client error message: " + strLabelitDislErr self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() xsDataImageQualityIndicators = XSDataImageQualityIndicators() xsDataImageQualityIndicators.setImage(self.xsDataImage) else: xsDataImageQualityIndicators = self.parseLabelitDistlOutput(strLabelitDistlLog) xsDataImageQualityIndicators.setImage(self.xsDataImage) xsDataResultDistlSignalStrength = XSDataResultDistlSignalStrength() xsDataResultDistlSignalStrength.setImageQualityIndicators(xsDataImageQualityIndicators) self.setDataOutput(xsDataResultDistlSignalStrength)
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. """ edPluginLabelitDistlv1_1 = self.createPlugin() xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitDistlv1_1.setDataInput(xmlInput1, "referenceImage") strImageQualityIndicatorsFile = os.path.join(self.getPluginTestsDataHome(), "XSDataImageQualityIndicators_reference.xml") strImageQualityIndicatorsXML = self.readAndParseFile(strImageQualityIndicatorsFile) from XSDataPhenixv1_1 import XSDataImageQualityIndicators xsDataImageQualityIndicatorsReference = XSDataImageQualityIndicators.parseString(strImageQualityIndicatorsXML) edPluginLabelitDistlv1_1.setDataOutput(xsDataImageQualityIndicatorsReference, "imageQualityIndicators") edPluginLabelitDistlv1_1.generateExecutiveSummary(edPluginLabelitDistlv1_1)
def testParseLabelitDistlOutput(self): """ This method test the parsing of the Labelit results in the log file. """ edPluginLabelitDistlv1_1 = self.createPlugin() strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(), "labelit.distl_v116.log") strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText) xsDataImageQualityIndicators = edPluginLabelitDistlv1_1.parseLabelitDistlOutput(strLabelitLogText) xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) xsDataImage1 = XSDataImage.parseString(xmlInput1) xsDataImageQualityIndicators.setImage(xsDataImage1) strLabelitDistlOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataImageQualityIndicators_reference.xml") print strLabelitDistlOutputFile strLabelitDistlOutputXML = self.readAndParseFile(strLabelitDistlOutputFile) from XSDataPhenixv1_1 import XSDataImageQualityIndicators xsDataImageQualityIndicatorsReference = XSDataImageQualityIndicators.parseString(strLabelitDistlOutputXML) EDAssert.equal(xsDataImageQualityIndicatorsReference.marshal(), xsDataImageQualityIndicators.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. """ edPluginLabelitDistlv1_1 = self.createPlugin() xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) edPluginLabelitDistlv1_1.setDataInput(xmlInput1, "referenceImage") strImageQualityIndicatorsFile = os.path.join( self.getPluginTestsDataHome(), "XSDataImageQualityIndicators_reference.xml") strImageQualityIndicatorsXML = self.readAndParseFile( strImageQualityIndicatorsFile) from XSDataPhenixv1_1 import XSDataImageQualityIndicators xsDataImageQualityIndicatorsReference = XSDataImageQualityIndicators.parseString( strImageQualityIndicatorsXML) edPluginLabelitDistlv1_1.setDataOutput( xsDataImageQualityIndicatorsReference, "imageQualityIndicators") edPluginLabelitDistlv1_1.generateExecutiveSummary( edPluginLabelitDistlv1_1)
def testParseLabelitDistlOutput(self): """ This method test the parsing of the Labelit results in the log file. """ edPluginLabelitDistlv1_1 = self.createPlugin() strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(), "labelit.distl_v116.log") strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText) xsDataImageQualityIndicators = edPluginLabelitDistlv1_1.parseLabelitDistlOutput( strLabelitLogText) xmlInput1 = self.readAndParseFile(self.__strReferenceInputFile1) xsDataImage1 = XSDataImage.parseString(xmlInput1) xsDataImageQualityIndicators.setImage(xsDataImage1) strLabelitDistlOutputFile = os.path.join( self.getPluginTestsDataHome(), "XSDataImageQualityIndicators_reference.xml") print strLabelitDistlOutputFile strLabelitDistlOutputXML = self.readAndParseFile( strLabelitDistlOutputFile) from XSDataPhenixv1_1 import XSDataImageQualityIndicators xsDataImageQualityIndicatorsReference = XSDataImageQualityIndicators.parseString( strLabelitDistlOutputXML) EDAssert.equal(xsDataImageQualityIndicatorsReference.marshal(), xsDataImageQualityIndicators.marshal())
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG("EDPluginDistlSignalStrengthThinClientv1_1.parseLabelitDistlOutput") xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setSpotTotal(XSDataInteger(iSpotTotal)) elif strLine.find("Method-2 Resolution Total") != -1: iInResTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResTotal(XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[-1]) xsDataImageQualityIndicators.setGoodBraggCandidates(XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[-1]) xsDataImageQualityIndicators.setIceRings(XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod1Res(XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod2Res(XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMaxUnitCell(XSDataDouble(fMaxUnitCell)) elif strLine.find("Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[-2]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks(XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-resolution overloaded spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResolutionOvrlSpots(XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find("Total integrated signal, pixel-ADC units above local background") != -1: fTotalIntegratedSignal = float(strLine.split()[-1]) xsDataImageQualityIndicators.setTotalIntegratedSignal(XSDataDouble(fTotalIntegratedSignal)) return xsDataImageQualityIndicators
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG("EDPluginLabelitDistlv1_1.parseLabelitDistlOutput") xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setSpotTotal( XSDataInteger(iSpotTotal)) elif strLine.find("In-Resolution Total") != -1: iInResTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setInResTotal( XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[4]) xsDataImageQualityIndicators.setGoodBraggCandidates( XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[3]) xsDataImageQualityIndicators.setIceRings( XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod1Res( XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod2Res( XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[4]) xsDataImageQualityIndicators.setMaxUnitCell( XSDataDouble(fMaxUnitCell)) elif strLine.find("%Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[5]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks( XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-Resolution Ovrld Spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[4]) xsDataImageQualityIndicators.setInResolutionOvrlSpots( XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find( "Bin population cutoff for method 2 resolution") != -1: fBinPopCutOffMethod2Res = float(strLine.split()[7][:-1]) xsDataImageQualityIndicators.setBinPopCutOffMethod2Res( XSDataDouble(fBinPopCutOffMethod2Res)) return xsDataImageQualityIndicators
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG("EDPluginDistlSignalStrengthv1_1.parseLabelitDistlOutput") xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setSpotTotal(XSDataInteger(iSpotTotal)) elif strLine.find("In-Resolution Total") != -1: iInResTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setInResTotal(XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[4]) xsDataImageQualityIndicators.setGoodBraggCandidates(XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[3]) xsDataImageQualityIndicators.setIceRings(XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod1Res(XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod2Res(XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[4]) xsDataImageQualityIndicators.setMaxUnitCell(XSDataDouble(fMaxUnitCell)) elif strLine.find("%Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[5]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks(XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-Resolution Ovrld Spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[4]) xsDataImageQualityIndicators.setInResolutionOvrlSpots(XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find("Bin population cutoff for method 2 resolution") != -1: fBinPopCutOffMethod2Res = float(strLine.split()[7][:-1]) xsDataImageQualityIndicators.setBinPopCutOffMethod2Res(XSDataDouble(fBinPopCutOffMethod2Res)) elif strLine.find("Total integrated signal, pixel-ADC units above local background (just the good Bragg candidates)") != -1: fTotalIntegratedSignal = float(strLine.split()[-1]) xsDataImageQualityIndicators.setTotalIntegratedSignal(XSDataDouble(fTotalIntegratedSignal)) elif strLine.find("Signals range from") != -1: listStrLine = strLine.split() fSignalRangeMin = float(listStrLine[3]) fSignalRangeMax = float(listStrLine[5]) fSignalRangeAverage = float(listStrLine[-1]) xsDataImageQualityIndicators.setSignalRangeMin(XSDataDouble(fSignalRangeMin)) xsDataImageQualityIndicators.setSignalRangeMax(XSDataDouble(fSignalRangeMax)) xsDataImageQualityIndicators.setSignalRangeAverage(XSDataDouble(fSignalRangeAverage)) elif strLine.find("Saturations range from") != -1: listStrLine = strLine.split() fSaturationRangeMin = float(listStrLine[3][:-1]) fSaturationRangeMax = float(listStrLine[5][:-1]) fSaturationRangeAverage = float(listStrLine[-1][:-1]) xsDataImageQualityIndicators.setSaturationRangeMin(XSDataDouble(fSaturationRangeMin)) xsDataImageQualityIndicators.setSaturationRangeMax(XSDataDouble(fSaturationRangeMax)) xsDataImageQualityIndicators.setSaturationRangeAverage(XSDataDouble(fSaturationRangeAverage)) return xsDataImageQualityIndicators
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG("EDPluginLabelitDistlv1_1.parseLabelitDistlOutput") xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setSpotTotal(XSDataInteger(iSpotTotal)) elif strLine.find("In-Resolution Total") != -1: iInResTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setInResTotal(XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[4]) xsDataImageQualityIndicators.setGoodBraggCandidates(XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[3]) xsDataImageQualityIndicators.setIceRings(XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod1Res(XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod2Res(XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[4]) xsDataImageQualityIndicators.setMaxUnitCell(XSDataDouble(fMaxUnitCell)) elif strLine.find("%Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[5]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks(XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-Resolution Ovrld Spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[4]) xsDataImageQualityIndicators.setInResolutionOvrlSpots(XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find("Bin population cutoff for method 2 resolution") != -1: fBinPopCutOffMethod2Res = float(strLine.split()[7][:-1]) xsDataImageQualityIndicators.setBinPopCutOffMethod2Res(XSDataDouble(fBinPopCutOffMethod2Res)) return xsDataImageQualityIndicators
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG( "EDPluginDistlSignalStrengthThinClientv1_1.parseLabelitDistlOutput" ) xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setSpotTotal( XSDataInteger(iSpotTotal)) elif strLine.find("Method-2 Resolution Total") != -1: iInResTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResTotal( XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[-1]) xsDataImageQualityIndicators.setGoodBraggCandidates( XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[-1]) xsDataImageQualityIndicators.setIceRings( XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod1Res( XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod2Res( XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMaxUnitCell( XSDataDouble(fMaxUnitCell)) elif strLine.find("Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[-2]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks( XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-resolution overloaded spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResolutionOvrlSpots( XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find( "Total integrated signal, pixel-ADC units above local background" ) != -1: fTotalIntegratedSignal = float(strLine.split()[-1]) xsDataImageQualityIndicators.setTotalIntegratedSignal( XSDataDouble(fTotalIntegratedSignal)) return xsDataImageQualityIndicators