def testParseLabelitScreenOutput(self):
     """
     This method test the parsing of the Labelit results in the log file.
     """
     edPluginLabelitv10 = self.createPlugin()
     strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(), "labelit_v1000rc11.log")
     strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText)
     xsDataLabelitScreenOutput = edPluginLabelitv10.parseLabelitScreenOutput(strLabelitLogText)
     strLabelitScreenOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataLabelitScreenOutput_reference.xml")
     strLabelitScreenOutputXML = self.readAndParseFile(strLabelitScreenOutputFile)
     from XSDataLabelitv10 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.
     """
     edPluginLabelitv10 = self.createPlugin()
     strPathToLabelitLogText = os.path.join(self.getPluginTestsDataHome(),
                                            "labelit_v1000rc11.log")
     strLabelitLogText = self.readAndParseFile(strPathToLabelitLogText)
     xsDataLabelitScreenOutput = edPluginLabelitv10.parseLabelitScreenOutput(
         strLabelitLogText)
     strLabelitScreenOutputFile = os.path.join(
         self.getPluginTestsDataHome(),
         "XSDataLabelitScreenOutput_reference.xml")
     strLabelitScreenOutputXML = self.readAndParseFile(
         strLabelitScreenOutputFile)
     from XSDataLabelitv10 import XSDataLabelitScreenOutput
     xsDataLabelitScreenOutputReference = XSDataLabelitScreenOutput.parseString(
         strLabelitScreenOutputXML)
     EDAssert.equal(xsDataLabelitScreenOutputReference.marshal(),
                    xsDataLabelitScreenOutput.marshal())
예제 #3
0
    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("EDPluginLabelitv10.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:
            errorMessage = EDMessage.ERROR_EXECUTION_03 % (
                "EDPluginLabelitv10.parseLabelitLogText",
                self.getClassName(),
                "Labelit log message: %s" % _strLabelitLogText,
            )
            self.error(errorMessage)
            self.addErrorMessage(errorMessage)
        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))
                else:
                    xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False))

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

                xsDataLabelitScreenSolution.setCrystalSystem(XSDataString(listStringLabelitSolution[6]))
                xsDataLabelitScreenSolution.setBravaisLattice(XSDataString(listStringLabelitSolution[7]))

                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:
                        xsDataLabelitScreenOutput.setSelectedSolutionNumber(XSDataInteger(iSolutionNumber))
                        bFoundSelectedSolution = True

                xsDataLabelitScreenOutput.addLabelitScreenSolution(xsDataLabelitScreenSolution)
                if iIndex < (len(listLogLines) - 2):
                    iIndex += 1
                else:
                    bContinue = False

        return xsDataLabelitScreenOutput
예제 #4
0
    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("EDPluginLabelitv10.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):
            errorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginLabelitv10.parseLabelitLogText", self.getClassName(), "Labelit log message: %s" % _strLabelitLogText)
            self.error(errorMessage)
            self.addErrorMessage(errorMessage)
        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))
                else:
                    xsDataLabelitScreenSolution.setHappy(XSDataBoolean(False))

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

                xsDataLabelitScreenSolution.setCrystalSystem(XSDataString(listStringLabelitSolution[6]))
                xsDataLabelitScreenSolution.setBravaisLattice(XSDataString(listStringLabelitSolution[7]))

                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):
                        xsDataLabelitScreenOutput.setSelectedSolutionNumber(XSDataInteger(iSolutionNumber))
                        bFoundSelectedSolution = True


                xsDataLabelitScreenOutput.addLabelitScreenSolution(xsDataLabelitScreenSolution)
                if (iIndex < (len(listLogLines) - 2)):
                    iIndex += 1
                else:
                    bContinue = False


        return xsDataLabelitScreenOutput