Exemplo n.º 1
0
 def testGenerateMOSFLMCommands(self):
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands")
     self.cleanUp(edPluginMOSFLMv10)
Exemplo n.º 2
0
 def testRasterConfiguration(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome,
                                            "XSConfiguration_raster.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     dictItem = edConfiguration.get(self.getPluginName())
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.setConfig(dictItem, _bLocal=True)
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img',
         'RASTER 15 15 3 3 3'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands with ratser configured")
    def generateDataMOSFLMInputGeneratePrediction(self):
        """
        """
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(102.5))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(104.7))

        from XSDataMOSFLMv10 import XSDataMOSFLMDetector

        xsDataMOSFLMDetector = XSDataMOSFLMDetector()
        xsDataMOSFLMDetector.setType(XSDataString("ADSC"))

        from XSDataMOSFLMv10 import XSDataMOSFLMImage

        xsDataMOSFLMImage1 = XSDataMOSFLMImage()
        xsDataMOSFLMImage1.setNumber(XSDataInteger(1))
        xsDataMOSFLMImage1.setRotationAxisStart(XSDataAngle(0.0))
        xsDataMOSFLMImage1.setRotationAxisEnd(XSDataAngle(1.0))

        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction()
        xsDataMOSFLMInputGeneratePrediction.setDistance(XSDataLength(198.4))
        xsDataMOSFLMInputGeneratePrediction.setWavelength(XSDataWavelength(0.9340))
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)
        xsDataMOSFLMInputGeneratePrediction.setDirectory(XSDataString(self.strDataImagePath))
        xsDataMOSFLMInputGeneratePrediction.setTemplate(XSDataString("ref-testscale_1_###.img"))
        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage1)

        return xsDataMOSFLMInputGeneratePrediction
    def generateDataMOSFLMInputGeneratePrediction(self):
        """
        """
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(102.5))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(104.7))

        from XSDataMOSFLMv10 import XSDataMOSFLMDetector
        xsDataMOSFLMDetector = XSDataMOSFLMDetector()
        xsDataMOSFLMDetector.setType(XSDataString("ADSC"))

        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        xsDataMOSFLMImage1 = XSDataMOSFLMImage()
        xsDataMOSFLMImage1.setNumber(XSDataInteger(1))
        xsDataMOSFLMImage1.setRotationAxisStart(XSDataAngle(0.0))
        xsDataMOSFLMImage1.setRotationAxisEnd(XSDataAngle(1.0))

        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction
        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction(
        )
        xsDataMOSFLMInputGeneratePrediction.setDistance(XSDataLength(198.4))
        xsDataMOSFLMInputGeneratePrediction.setWavelength(
            XSDataWavelength(0.9340))
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)
        xsDataMOSFLMInputGeneratePrediction.setDirectory(
            XSDataString(self.strDataImagePath))
        xsDataMOSFLMInputGeneratePrediction.setTemplate(
            XSDataString("ref-testscale_1_###.img"))
        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage1)

        return xsDataMOSFLMInputGeneratePrediction
 def testRasterConfiguration(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome, "XSConfiguration_raster.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     edConfiguration.load()
     xsPluginItem = edConfiguration.getPluginItem("EDPluginMOSFLMv10")
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.setConfiguration(xsPluginItem)
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = ['WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0', 'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img', 'RASTER 15 15 3 3 3']
     EDAssert.equal(edListCommandsReference, edListCommands, "MOSFLM commands with ratser configured")
 def testGenerateMOSFLMCommands(self):
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = ['WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0', 'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img']
     EDAssert.equal(edListCommandsReference, edListCommands, "MOSFLM commands")
     self.cleanUp(edPluginMOSFLMv10)
    def generateXSDataMOSFLMInputIndexing(_xsDataIndexingInput):
        """
        Translation from XSDataIndexingInput to XSDataMOSFLMInputIndexing.
        """
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage

        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing")

        xsDataCollection = _xsDataIndexingInput.getDataCollection()
        xsDataExperimentalCondition = _xsDataIndexingInput.getExperimentalCondition(
        )
        xsDataCrystal = _xsDataIndexingInput.getCrystal()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()
        xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing()

        if (xsDataExperimentalCondition is None):
            xsDataExperimentalCondition = xsDataSubWedgeList[
                0].getExperimentalCondition()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(dBeamPositionX))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(dBeamPositionY))
        xsDataMOSFLMInputIndexing.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(
            xsDataDetector)
        xsDataMOSFLMInputIndexing.setDetector(xsDataMOSFLMDetector)

        xsDataMOSFLMInputIndexing.setWavelength(XSDataWavelength(dWavelength))
        xsDataMOSFLMInputIndexing.setDistance(XSDataLength(dDistance))

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        strPath = xsDataImageFirst.getPath().getValue()
        strFileName = os.path.basename(strPath)
        strDirectory = os.path.dirname(strPath)

        if xsDataDetector.type.value == "eiger2_16m":
            strMOSFLMTemplate = EDUtilsImage.getH5MasterTemplate(
                strFileName, 1)
        else:
            strMOSFLMTemplate = EDUtilsImage.getTemplate(strFileName, "#")
        xsDataMOSFLMInputIndexing.setTemplate(XSDataString(strMOSFLMTemplate))
        xsDataMOSFLMInputIndexing.setDirectory(XSDataString(strDirectory))

        if (xsDataCrystal is not None):
            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
            if (xsDataSpaceGroup is not None):
                xsDataStringName = xsDataSpaceGroup.getName()
                if (xsDataStringName is not None):
                    xsDataMOSFLMInputIndexing.setSymmetry(
                        XSDataString(xsDataStringName.getValue()))

        # Loop through the list of sub wedges

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth(
            ).getValue()

            # First find the lowest image number
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber

            # Loop through the list of images

            for xsDataImage in xsDataImageList:
                # Create the MOSFLM image object

                xsDataMOSFLMImage = XSDataMOSFLMImage()

                iImageNumber = xsDataImage.getNumber().getValue()
                xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

                fImageOscillationStart = fGonioStatOscillationStart + (
                    iImageNumber -
                    iLowestImageNumber) * fGonioStatOscillationRange
                xsDataMOSFLMImage.setRotationAxisStart(
                    XSDataAngle(fImageOscillationStart))
                xsDataMOSFLMImage.setRotationAxisEnd(
                    XSDataAngle(fImageOscillationStart +
                                fGonioStatOscillationRange))

                xsDataMOSFLMInputIndexing.addImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputIndexing
    def generateXSDataMOSFLMInputGeneratePrediction(
            xsDataGeneratePredictionInput):
        """
        Translation from XSDataGeneratePredictionInput to XSDataMOSFLMInputGeneratePrediction.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction"
        )
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        from XSDataMOSFLMv10 import XSDataMOSFLMNewmat
        from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataIndexingSolutionSelected = xsDataGeneratePredictionInput.getSelectedIndexingSolution(
        )

        xsDataCollection = xsDataGeneratePredictionInput.getDataCollection()
        xsDataSubWedge = xsDataCollection.getSubWedge()[0]
        xsDataImageList = xsDataSubWedge.getImage()
        xsDataImageFirst = xsDataImageList[0]

        xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal()
        xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation()
        xsDataExperimentalCondition = xsDataIndexingSolutionSelected.getExperimentalConditionRefined(
        )
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataMatrixA = xsDataOrientation.getMatrixA()
        xsDataMatrixU = xsDataOrientation.getMatrixU()
        xsDataCell = xsDataCrystal.getCell()

        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction(
        )
        xsDataMOSFLMNewmat = XSDataMOSFLMNewmat()
        xsDataMOSFLMNewmat.setRefinedCell(xsDataCell)
        xsDataMOSFLMNewmat.setAMatrix(xsDataMatrixA)
        xsDataMOSFLMNewmat.setUMatrix(xsDataMatrixU)
        xsDataMOSFLMInputGeneratePrediction.setMatrix(xsDataMOSFLMNewmat)

        xsDataMOSFLMMissettingsAngles = XSDataMOSFLMMissettingsAngles()
        xsDataMOSFLMMissettingsAngles.setPhix(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiy(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiz(XSDataAngle(0.0))
        xsDataMOSFLMNewmat.setMissettingAngles(xsDataMOSFLMMissettingsAngles)

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(xsDataDetector.getBeamPositionX())
        xsDataMOSFLMBeamPosition.setY(xsDataDetector.getBeamPositionY())
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMInputGeneratePrediction.setMosaicity(
            xsDataCrystal.getMosaicity())
        xsDataMOSFLMInputGeneratePrediction.setSymmetry(
            xsDataCrystal.getSpaceGroup().getName())

        strPathFirst = xsDataImageFirst.getPath().getValue()
        strDirectoryFirst = os.path.dirname(strPathFirst)
        strFilenameFirst = os.path.basename(strPathFirst)

        xsDataMOSFLMInputGeneratePrediction.setWavelength(
            xsDataBeam.getWavelength())
        xsDataMOSFLMInputGeneratePrediction.setDistance(
            xsDataDetector.getDistance())
        xsDataMOSFLMInputGeneratePrediction.setDirectory(
            XSDataString(strDirectoryFirst))
        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(
            xsDataDetector)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)

        # The MOSFLM plugin can only handle one image

        xsDataImage = xsDataSubWedge.getImage()[0]
        xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
        ).getGoniostat()

        iImageNumber = xsDataImage.getNumber().getValue()

        if xsDataDetector.type.value == "eiger2_16m":
            strMOSFLMTemplate = EDUtilsImage.getH5MasterTemplate(
                strFilenameFirst, iImageNumber)
        else:
            strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#")
        xsDataMOSFLMInputGeneratePrediction.setTemplate(
            XSDataString(strMOSFLMTemplate))

        xsDataMOSFLMImage = XSDataMOSFLMImage()
        xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

        fOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
        fOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()
        xsDataMOSFLMImage.setRotationAxisStart(XSDataAngle(fOscillationStart))
        xsDataMOSFLMImage.setRotationAxisEnd(
            XSDataAngle(fOscillationStart + fOscillationRange))

        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputGeneratePrediction
Exemplo n.º 9
0
    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 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 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
    def generateXSDataMOSFLMInputIndexing(_xsDataIndexingInput):
        """
        Translation from XSDataIndexingInput to XSDataMOSFLMInputIndexing.
        """
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage

        EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing")

        xsDataCollection = _xsDataIndexingInput.getDataCollection()
        xsDataExperimentalCondition = _xsDataIndexingInput.getExperimentalCondition()
        xsDataCrystal = _xsDataIndexingInput.getCrystal()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()
        xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing()

        if (xsDataExperimentalCondition is None):
            xsDataExperimentalCondition = xsDataSubWedgeList[0].getExperimentalCondition()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(dBeamPositionX))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(dBeamPositionY))
        xsDataMOSFLMInputIndexing.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(xsDataDetector)
        xsDataMOSFLMInputIndexing.setDetector(xsDataMOSFLMDetector)

        xsDataMOSFLMInputIndexing.setWavelength(XSDataWavelength(dWavelength))
        xsDataMOSFLMInputIndexing.setDistance(XSDataLength(dDistance))

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        strPath = xsDataImageFirst.getPath().getValue()
        strFileName = os.path.basename(strPath)
        strDirectory = os.path.dirname(strPath)

        strMOSFLMTemplate = EDUtilsImage.getTemplate(strFileName, "#")
        xsDataMOSFLMInputIndexing.setTemplate(XSDataString(strMOSFLMTemplate))
        xsDataMOSFLMInputIndexing.setDirectory(XSDataString(strDirectory))

        if (xsDataCrystal is not None):
            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
            if (xsDataSpaceGroup is not None):
                xsDataStringName = xsDataSpaceGroup.getName()
                if (xsDataStringName is not None):
                    xsDataMOSFLMInputIndexing.setSymmetry(XSDataString(xsDataStringName.getValue()))

        # Loop through the list of sub wedges 

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition().getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()

            # First find the lowest image number
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber

            # Loop through the list of images

            for xsDataImage in xsDataImageList:
                # Create the MOSFLM image object

                xsDataMOSFLMImage = XSDataMOSFLMImage()

                iImageNumber = xsDataImage.getNumber().getValue()
                xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

                fImageOscillationStart = fGonioStatOscillationStart + (iImageNumber - iLowestImageNumber) * fGonioStatOscillationRange
                xsDataMOSFLMImage.setRotationAxisStart(XSDataAngle(fImageOscillationStart))
                xsDataMOSFLMImage.setRotationAxisEnd(XSDataAngle(fImageOscillationStart + fGonioStatOscillationRange))

                xsDataMOSFLMInputIndexing.addImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputIndexing
    def generateXSDataMOSFLMInputGeneratePrediction(xsDataGeneratePredictionInput):
        """
        Translation from XSDataGeneratePredictionInput to XSDataMOSFLMInputGeneratePrediction.
        """
        EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction")
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        from XSDataMOSFLMv10 import XSDataMOSFLMNewmat
        from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataIndexingSolutionSelected = xsDataGeneratePredictionInput.getSelectedIndexingSolution()

        xsDataCollection = xsDataGeneratePredictionInput.getDataCollection()
        xsDataSubWedge = xsDataCollection.getSubWedge()[0]
        xsDataImageList = xsDataSubWedge.getImage()
        xsDataImageFirst = xsDataImageList[0]

        xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal()
        xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation()
        xsDataExperimentalCondition = xsDataIndexingSolutionSelected.getExperimentalConditionRefined()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataMatrixA = xsDataOrientation.getMatrixA()
        xsDataMatrixU = xsDataOrientation.getMatrixU()
        xsDataCell = xsDataCrystal.getCell()

        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction()
        xsDataMOSFLMNewmat = XSDataMOSFLMNewmat()
        xsDataMOSFLMNewmat.setRefinedCell(xsDataCell)
        xsDataMOSFLMNewmat.setAMatrix(xsDataMatrixA)
        xsDataMOSFLMNewmat.setUMatrix(xsDataMatrixU)
        xsDataMOSFLMInputGeneratePrediction.setMatrix(xsDataMOSFLMNewmat)

        xsDataMOSFLMMissettingsAngles = XSDataMOSFLMMissettingsAngles()
        xsDataMOSFLMMissettingsAngles.setPhix(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiy(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiz(XSDataAngle(0.0))
        xsDataMOSFLMNewmat.setMissettingAngles(xsDataMOSFLMMissettingsAngles)

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(xsDataDetector.getBeamPositionX())
        xsDataMOSFLMBeamPosition.setY(xsDataDetector.getBeamPositionY())
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMInputGeneratePrediction.setMosaicity(xsDataCrystal.getMosaicity())
        xsDataMOSFLMInputGeneratePrediction.setSymmetry(xsDataCrystal.getSpaceGroup().getName())

        strPathFirst = xsDataImageFirst.getPath().getValue()
        strDirectoryFirst = os.path.dirname(strPathFirst)
        strFilenameFirst = os.path.basename(strPathFirst)

        xsDataMOSFLMInputGeneratePrediction.setWavelength(xsDataBeam.getWavelength())
        xsDataMOSFLMInputGeneratePrediction.setDistance(xsDataDetector.getDistance())
        xsDataMOSFLMInputGeneratePrediction.setDirectory(XSDataString(strDirectoryFirst))
        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(xsDataDetector)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)

        strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#")
        xsDataMOSFLMInputGeneratePrediction.setTemplate(XSDataString(strMOSFLMTemplate))

        # The MOSFLM plugin can only handle one image 

        xsDataImage = xsDataSubWedge.getImage()[0]
        xsDataGoniostat = xsDataSubWedge.getExperimentalCondition().getGoniostat()

        xsDataMOSFLMImage = XSDataMOSFLMImage()

        iImageNumber = xsDataImage.getNumber().getValue()
        xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

        fOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
        fOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()
        xsDataMOSFLMImage.setRotationAxisStart(XSDataAngle(fOscillationStart))
        xsDataMOSFLMImage.setRotationAxisEnd(XSDataAngle(fOscillationStart + fOscillationRange))

        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputGeneratePrediction
Exemplo n.º 15
0
    def generateXSDataMOSFLMInputIntegration(_xsDataIntegrationInput):
        """
        Translation from XSDataIntegrationInput to XSDataMOSFLMInputIntegration.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIntegration")
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMInputIntegration
        from XSDataMOSFLMv10 import XSDataMOSFLMNewmat
        from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles
        xsDataCrystalRefined = _xsDataIntegrationInput.getCrystalRefined()
        xsDataIndexingSolutionSelected = _xsDataIntegrationInput.getSelectedIndexingSolution(
        )

        if (xsDataCrystalRefined is None):
            xsDataCrystalRefined = xsDataIndexingSolutionSelected.getCrystal()

        xsDataCollection = _xsDataIntegrationInput.getDataCollection()
        xsDataSubWedge = xsDataCollection.getSubWedge()[0]
        xsDataImageList = xsDataSubWedge.getImage()
        xsDataImageFirst = xsDataImageList[0]
        xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
        ).getGoniostat()

        xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal()
        xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation()
        xsDataExperimentalCondition = xsDataIndexingSolutionSelected.getExperimentalConditionRefined(
        )
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataMatrixA = xsDataOrientation.getMatrixA()
        xsDataMatrixU = xsDataOrientation.getMatrixU()
        xsDataCell = xsDataCrystal.getCell()

        xsDataMOSFLMInputIntegration = XSDataMOSFLMInputIntegration()
        xsDataMOSFLMNewmat = XSDataMOSFLMNewmat()
        xsDataMOSFLMNewmat.setRefinedCell(xsDataCell)
        xsDataMOSFLMNewmat.setAMatrix(xsDataMatrixA)
        xsDataMOSFLMNewmat.setUMatrix(xsDataMatrixU)
        xsDataMOSFLMInputIntegration.setMatrix(xsDataMOSFLMNewmat)

        xsDataMOSFLMMissettingsAngles = XSDataMOSFLMMissettingsAngles()
        xsDataMOSFLMMissettingsAngles.setPhix(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiy(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiz(XSDataAngle(0.0))
        xsDataMOSFLMNewmat.setMissettingAngles(xsDataMOSFLMMissettingsAngles)

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(xsDataDetector.getBeamPositionX())
        xsDataMOSFLMBeamPosition.setY(xsDataDetector.getBeamPositionY())
        xsDataMOSFLMInputIntegration.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMInputIntegration.setMosaicity(xsDataCrystal.getMosaicity())
        xsDataMOSFLMInputIntegration.setSymmetry(
            xsDataCrystal.getSpaceGroup().getName())

        strPathFirst = xsDataImageFirst.getPath().getValue()
        strDirectoryFirst = os.path.dirname(strPathFirst)
        strFilenameFirst = os.path.basename(strPathFirst)
        fOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()

        xsDataMOSFLMInputIntegration.setWavelength(xsDataBeam.getWavelength())
        xsDataMOSFLMInputIntegration.setDistance(xsDataDetector.getDistance())
        xsDataMOSFLMInputIntegration.setDirectory(
            XSDataString(strDirectoryFirst))
        xsDataMOSFLMInputIntegration.setOscillationWidth(
            XSDataAngle(fOscillationRange))
        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(
            xsDataDetector)
        xsDataMOSFLMInputIntegration.setDetector(xsDataMOSFLMDetector)

        strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#")
        xsDataMOSFLMInputIntegration.setTemplate(
            XSDataString(strMOSFLMTemplate))

        iImageStart = None
        iImageEnd = None
        for xsDataImage in xsDataImageList:
            iImageNumber = xsDataImage.getNumber().getValue()
            if (iImageStart is None):
                iImageStart = iImageNumber
            elif (iImageStart > iImageNumber):
                iImageStart = iImageNumber
            if (iImageEnd is None):
                iImageEnd = iImageNumber
            elif (iImageEnd < iImageNumber):
                iImageEnd = iImageNumber

        xsDataMOSFLMInputIntegration.setImageStart(XSDataInteger(iImageStart))
        xsDataMOSFLMInputIntegration.setImageEnd(XSDataInteger(iImageEnd))
        xsDataMOSFLMInputIntegration.setRotationAxisStart(
            xsDataGoniostat.getRotationAxisStart())

        # print xsDataMOSFLMInputIntegration.marshal()

        return xsDataMOSFLMInputIntegration