def testListOfTables(self):
        xsItem = None
        xsItem2 = None
        strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath2)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        listTable = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "data_collection_strategy")

        EDAssert.equal(2, len(listTable))

        bFoundPlan1 = False
        bFoundPlan2 = False

        for xsTable in listTable:
            xsItem = None
            xsLists = EDUtilsTable.getListsFromTable(xsTable, "summary")
            for xsList in xsLists:
                xsItem = EDUtilsTable.getItemFromList(xsList, "resolution_reasoning")

            if(xsItem.getValueOf_() == "Low-resolution pass, no overloads"):
                bFoundPlan1 = True
            if(xsItem.getValueOf_() == "Resolution limit is set by the initial image resolution"):
                bFoundPlan2 = True

        EDAssert.equal(True, bFoundPlan1)
        EDAssert.equal(True, bFoundPlan2)
예제 #2
0
    def testListOfTables(self):
        xsItem = None
        xsItem2 = None
        strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath2)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        listTable = EDUtilsTable.getTableListFromTables(
            xsDataDnaTables, "data_collection_strategy")

        EDAssert.equal(2, len(listTable))

        bFoundPlan1 = False
        bFoundPlan2 = False

        for xsTable in listTable:
            xsItem = None
            xsLists = EDUtilsTable.getListsFromTable(xsTable, "summary")
            for xsList in xsLists:
                xsItem = EDUtilsTable.getItemFromList(xsList,
                                                      "resolution_reasoning")

            if (xsItem.getValueOf_() == "Low-resolution pass, no overloads"):
                bFoundPlan1 = True
            if (xsItem.getValueOf_() ==
                    "Resolution limit is set by the initial image resolution"):
                bFoundPlan2 = True

        EDAssert.equal(True, bFoundPlan1)
        EDAssert.equal(True, bFoundPlan2)
예제 #3
0
    def getMOSFLMIntegrationStatistics(self, _xsDataList):
        """
        This method creates a new XSDataMOSFLMIntegrationStatistics object and populates it with
        values (averaged intensity, sigma, average I over sigma and number of reflections) 
        from the _xsDataList object.
        """
        xsDataMOSFLMIntegrationStatistics = XSDataMOSFLMIntegrationStatistics()

        strAverageIntensity = EDUtilsTable.getItemFromList(_xsDataList,
                                                           "i").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIntensity(
            XSDataFloat(float(strAverageIntensity)))

        strAverageSigma = EDUtilsTable.getItemFromList(_xsDataList,
                                                       "sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageSigma(
            XSDataFloat(float(strAverageSigma)))

        strAverageIOverSigma = EDUtilsTable.getItemFromList(
            _xsDataList, "i_sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIOverSigma(
            XSDataFloat(float(strAverageIOverSigma)))

        strNumberOfReflections = EDUtilsTable.getItemFromList(
            _xsDataList, "count").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setNumberOfReflections(
            XSDataInteger(int(strNumberOfReflections)))

        return xsDataMOSFLMIntegrationStatistics
예제 #4
0
    def getDamParOutputFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(_xsDataDnaTables, "dam_par_plan")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsDataStrategySummary = XSDataBestStrategySummary()
            xsGeneralList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "general")[0]
            xsCollectionRunList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "collection_run")

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(xsCollectionRunItemList, iCollectionRunNumber)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1

            xsDataBestCollectionPlan.setCollectionPlanNumber(XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

            xsItemDistance = EDUtilsTable.getItemFromList(xsGeneralList, "distance")
            fDistance = float(xsItemDistance.getValueOf_())
            xsDataStrategySummary.setDistance(XSDataLength(fDistance))

            xsItemResolution = EDUtilsTable.getItemFromList(xsGeneralList, "resolution")
            fResolution = float(xsItemResolution.getValueOf_())
            xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

        return xsDataResultBest
    def getMOSFLMIntegrationStatisticsPerResolutionBin(self, _xsDataDnaTables, _strListName, _fMinResolution=None):
        """
        This method creates an XSDataMOSFLMIntegrationStatisticsPerResolutionBin object given an XSDataDnaTables object
        and a list name, e.g. "bin_1". If _fMinResolution is provided it is used for setting the minimum resolution,
        otherwise the min and max resolution are set to the same value provided by the xsDataList object.
        """
        xsDataTableProfileFittedFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_full")
        xsDataTableProfileFittedPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_partial")
        xsDataTableSummationFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_full")
        xsDataTableSummationPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_partial")

        xsListProfileFittedFull = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedFull, _strListName)[0]
        xsListProfileFittedPartial = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedPartial, _strListName)[0]
        xsListSummationFull = EDUtilsTable.getListsFromTable(xsDataTableSummationFull, _strListName)[0]
        xsListSummationPartial = EDUtilsTable.getListsFromTable(xsDataTableSummationPartial, _strListName)[0]

        xsDataMOSFLMIntegrationDataProfileFittedFull = self.getMOSFLMIntegrationStatistics(xsListProfileFittedFull)
        xsDataMOSFLMIntegrationDataProfileFittedPartials = self.getMOSFLMIntegrationStatistics(
            xsListProfileFittedPartial
        )
        xsDataMOSFLMIntegrationSummationFull = self.getMOSFLMIntegrationStatistics(xsListSummationFull)
        xsDataMOSFLMIntegrationSummationPartial = self.getMOSFLMIntegrationStatistics(xsListSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted = (
            XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        )
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setFullyRecorded(
            xsDataMOSFLMIntegrationDataProfileFittedFull
        )
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setPartials(
            xsDataMOSFLMIntegrationDataProfileFittedPartials
        )

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation = (
            XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        )
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setFullyRecorded(
            xsDataMOSFLMIntegrationSummationFull
        )
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setPartials(xsDataMOSFLMIntegrationSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerResolutionBin = XSDataMOSFLMIntegrationStatisticsPerResolutionBin()
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setProfileFitted(
            xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted
        )
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setSummation(
            xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation
        )

        strMaxResolution = EDUtilsTable.getItemFromList(xsListProfileFittedFull, "resolution").getValueOf_()
        if strMaxResolution != "overall":
            xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMaxResolution(XSDataFloat(float(strMaxResolution)))
            if _fMinResolution is not None:
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(_fMinResolution))
            else:
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(float(strMaxResolution)))

        return xsDataMOSFLMIntegrationStatisticsPerResolutionBin
예제 #6
0
    def strategySummaryItemListToStrategySummary(self,
                                                 _xsStrategySummaryItemList):
        xsDataStrategySummary = XSDataBestStrategySummary()

        xsItemDistance = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataStrategySummary.setDistance(XSDataLength(fDistance))

        strItemTransmission = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "transmission")
        fTransmission = float(strItemTransmission.getValueOf_())
        xsDataStrategySummary.setTransmission(XSDataDouble(fTransmission))

        strItemCompleteness = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "completeness")
        # For homegeneity concerns, EDNA data model should store all the completeness value in fraction
        # ( DNA table xml file stores the summary strategy completeness in percentage whereas
        # the resolution bin completeness are in fraction )
        fCompleteness = float(strItemCompleteness.getValueOf_()) / 100
        xsDataStrategySummary.setCompleteness(XSDataDouble(fCompleteness))

        strItemISigma = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "i_sigma")
        fISigma = float(strItemISigma.getValueOf_())
        xsDataStrategySummary.setISigma(XSDataDouble(fISigma))

        strItemRedundancy = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "redundancy")
        fRedundancy = float(strItemRedundancy.getValueOf_())
        xsDataStrategySummary.setRedundancy(XSDataDouble(fRedundancy))

        strItemResolution = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution")
        fResolution = float(strItemResolution.getValueOf_())
        xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

        strItemResolutionReasoning = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution_reasoning")
        strResolutionReasoning = strItemResolutionReasoning.getValueOf_()
        xsDataStrategySummary.setResolutionReasoning(
            XSDataString(strResolutionReasoning))

        strItemTotalDataCollectionTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_data_collection_time")
        fTotalDataCollectionTime = float(
            strItemTotalDataCollectionTime.getValueOf_())
        xsDataStrategySummary.setTotalDataCollectionTime(
            XSDataTime(fTotalDataCollectionTime))

        strItemTotalExposureTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_exposure_time")
        fTotalExposureTime = float(strItemTotalExposureTime.getValueOf_())
        xsDataStrategySummary.setTotalExposureTime(
            XSDataTime(fTotalExposureTime))

        return xsDataStrategySummary
예제 #7
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList,
                                             _iCollectionRunNumber):
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemWedge = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                   "Wedge")
        if xsItemWedge is not None:
            iWedge = int(xsItemWedge.getValueOf_())
        else:
            iWedge = _iCollectionRunNumber
        xsDataCollectionRun.setCollectionRunNumber(XSDataInteger(iWedge))

        xsItemCrystal = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                     "Crystal")
        if xsItemCrystal is not None:
            iCrystal = int(xsItemCrystal.getValueOf_())
            xsDataCollectionRun.setCrystalPosition(XSDataInteger(iCrystal))

        xsItemExposureTime = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemAction = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                    "action")
        if (xsItemAction is not None):
            strAction = xsItemAction.getValueOf_()
            xsDataCollectionRun.setAction(XSDataString(strAction))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "overlaps")
        if (xsItemOverlaps is not None):
            strOverlaps = xsItemOverlaps.getValueOf_()
            xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        xsItemTransmission = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "transmission")
        if (xsItemTransmission is not None):
            fTransmission = float(xsItemTransmission.getValueOf_())
            xsDataCollectionRun.setTransmission(XSDataDouble(fTransmission))

        return xsDataCollectionRun
예제 #8
0
 def getOutputDataFromDNATableFile(self, _strFileName):
     """Parses the result 'DNA'-type XML file"""
     xsDataResultRdfit = XSDataResultRdfit()
     strDnaTablesXML = self.readProcessFile(_strFileName)
     xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
     # Loop through all the tables and fill in the relevant parts of xsDataResultBest
     xsDataRDFIT_Results = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "RDFIT_Results")[0]
     xsDataListGeneral = EDUtilsTable.getListsFromTable(xsDataRDFIT_Results, "general")[0]
     xsDataItemBeta = EDUtilsTable.getItemFromList(xsDataListGeneral, "beta")
     if xsDataItemBeta is not None:
         beta = xsDataItemBeta.getValueOf_()
         xsDataResultRdfit.setBeta(XSDataDouble(beta))
     xsDataItemGama = EDUtilsTable.getItemFromList(xsDataListGeneral, "gama")
     if xsDataItemGama is not None:
         gama = xsDataItemGama.getValueOf_()
         xsDataResultRdfit.setGama(XSDataDouble(gama))
     xsDataItemDose_half_th = EDUtilsTable.getItemFromList(xsDataListGeneral, "Dose_1/2_th")
     if xsDataItemDose_half_th is not None:
         dose_half_th = xsDataItemDose_half_th.getValueOf_()
         xsDataResultRdfit.setDose_half_th(XSDataDouble(dose_half_th))
     xsDataItemDose_half = EDUtilsTable.getItemFromList(xsDataListGeneral, "Dose_1/2")
     if xsDataItemDose_half is not None:
         dose_half = xsDataItemDose_half.getValueOf_()
         xsDataResultRdfit.setDose_half(XSDataDouble(dose_half))
     xsDataItemRelative_radiation_sensitivity = EDUtilsTable.getItemFromList(xsDataListGeneral, "Relative_Radiation_Sensitivity")
     if xsDataItemRelative_radiation_sensitivity is not None:
         relative_radiation_sensitivity = xsDataItemRelative_radiation_sensitivity.getValueOf_()
         xsDataResultRdfit.setRelative_radiation_sensitivity(XSDataDouble(relative_radiation_sensitivity))
     return xsDataResultRdfit
예제 #9
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList, _iCollectionRunNumber):
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemWedge = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "Wedge")
        if xsItemWedge is not None:
            iWedge = int(xsItemWedge.getValueOf_())
        else:
            iWedge = _iCollectionRunNumber
        xsDataCollectionRun.setCollectionRunNumber(XSDataInteger(iWedge))

        xsItemCrystal = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "Crystal")
        if xsItemCrystal is not None:
            iCrystal = int(xsItemCrystal.getValueOf_())
            xsDataCollectionRun.setCrystalPosition(XSDataInteger(iCrystal))

        xsItemExposureTime = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemAction = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "action")
        if (xsItemAction is not None):
            strAction = xsItemAction.getValueOf_()
            xsDataCollectionRun.setAction(XSDataString(strAction))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "overlaps")
        if (xsItemOverlaps is not None):
            strOverlaps = xsItemOverlaps.getValueOf_()
            xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        xsItemTransmission = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "transmission")
        if (xsItemTransmission is not None):
            fTransmission = float(xsItemTransmission.getValueOf_())
            xsDataCollectionRun.setTransmission(XSDataDouble(fTransmission))

        return xsDataCollectionRun
    def getMOSFLMIntegrationStatistics(self, _xsDataList):
        """
        This method creates a new XSDataMOSFLMIntegrationStatistics object and populates it with
        values (averaged intensity, sigma, average I over sigma and number of reflections) 
        from the _xsDataList object.
        """
        xsDataMOSFLMIntegrationStatistics = XSDataMOSFLMIntegrationStatistics()

        strAverageIntensity = EDUtilsTable.getItemFromList(_xsDataList, "i").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIntensity(XSDataFloat(float(strAverageIntensity)))

        strAverageSigma = EDUtilsTable.getItemFromList(_xsDataList, "sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageSigma(XSDataFloat(float(strAverageSigma)))

        strAverageIOverSigma = EDUtilsTable.getItemFromList(_xsDataList, "i_sig").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setAverageIOverSigma(XSDataFloat(float(strAverageIOverSigma)))

        strNumberOfReflections = EDUtilsTable.getItemFromList(_xsDataList, "count").getValueOf_()
        xsDataMOSFLMIntegrationStatistics.setNumberOfReflections(XSDataInteger(int(strNumberOfReflections)))

        return xsDataMOSFLMIntegrationStatistics
예제 #11
0
    def getBonlyOutputFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        xsTablesGeneralInform = EDUtilsTable.getTableListFromTables(_xsDataDnaTables, "general_inform")

        xsDataBestCollectionPlan = XSDataBestCollectionPlan()
        xsDataCrystalScale = XSDataCrystalScale()

        xsCrystalScaleList = EDUtilsTable.getListsFromTable(xsTablesGeneralInform[0], "crystal_scale")[0]

        xsItemScal = EDUtilsTable.getItemFromList(xsCrystalScaleList, "scal")
        fScal = float(xsItemScal.getValueOf_())
        xsDataCrystalScale.setScale(XSDataDouble(fScal))

        xsItemBfactor = EDUtilsTable.getItemFromList(xsCrystalScaleList, "B_factor")
        fBfactor = float(xsItemBfactor.getValueOf_())
        xsDataCrystalScale.setBFactor(XSDataDouble(fBfactor))

        xsDataBestCollectionPlan.setCrystalScale(xsDataCrystalScale)
        xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)

        return xsDataResultBest
예제 #12
0
    def strategySummaryItemListToStrategySummary(self, _xsStrategySummaryItemList):
        xsDataStrategySummary = XSDataBestStrategySummary()

        xsItemDistance = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataStrategySummary.setDistance(XSDataLength(fDistance))

        strItemTransmission = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "transmission")
        fTransmission = float(strItemTransmission.getValueOf_())
        xsDataStrategySummary.setTransmission(XSDataDouble(fTransmission))

        strItemCompleteness = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "completeness")
        # For homegeneity concerns, EDNA data model should store all the completeness value in fraction
        # ( DNA table xml file stores the summary strategy completeness in percentage whereas
        # the resolution bin completeness are in fraction )
        fCompleteness = float(strItemCompleteness.getValueOf_()) / 100
        xsDataStrategySummary.setCompleteness(XSDataDouble(fCompleteness))

        strItemISigma = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "i_sigma")
        fISigma = float(strItemISigma.getValueOf_())
        xsDataStrategySummary.setISigma(XSDataDouble(fISigma))

        strItemRedundancy = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "redundancy")
        fRedundancy = float(strItemRedundancy.getValueOf_())
        xsDataStrategySummary.setRedundancy(XSDataDouble(fRedundancy))

        strItemResolution = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "resolution")
        fResolution = float(strItemResolution.getValueOf_())
        xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

        strItemResolutionReasoning = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "resolution_reasoning")
        strResolutionReasoning = strItemResolutionReasoning.getValueOf_()
        xsDataStrategySummary.setResolutionReasoning(XSDataString(strResolutionReasoning))

        strItemTotalDataCollectionTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_data_collection_time"
        )
        fTotalDataCollectionTime = float(strItemTotalDataCollectionTime.getValueOf_())
        xsDataStrategySummary.setTotalDataCollectionTime(XSDataTime(fTotalDataCollectionTime))

        strItemTotalExposureTime = EDUtilsTable.getItemFromList(_xsStrategySummaryItemList, "total_exposure_time")
        fTotalExposureTime = float(strItemTotalExposureTime.getValueOf_())
        xsDataStrategySummary.setTotalExposureTime(XSDataTime(fTotalExposureTime))

        return xsDataStrategySummary
예제 #13
0
    def getDamParOutputFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            _xsDataDnaTables, "dam_par_plan")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsDataStrategySummary = XSDataBestStrategySummary()
            xsGeneralList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "general")[0]
            xsCollectionRunList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "collection_run")

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList, iCollectionRunNumber)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1

            xsDataBestCollectionPlan.setCollectionPlanNumber(
                XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

            xsItemDistance = EDUtilsTable.getItemFromList(
                xsGeneralList, "distance")
            fDistance = float(xsItemDistance.getValueOf_())
            xsDataStrategySummary.setDistance(XSDataLength(fDistance))

            xsItemResolution = EDUtilsTable.getItemFromList(
                xsGeneralList, "resolution")
            fResolution = float(xsItemResolution.getValueOf_())
            xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

        return xsDataResultBest
예제 #14
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList):
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemExposureTime = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemDistance = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataCollectionRun.setDistance(XSDataLength(fDistance))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "overlaps")
        strOverlaps = xsItemOverlaps.getValueOf_()
        xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        return xsDataCollectionRun
예제 #15
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList):
        """
        """
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemExposureTime = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemDistance = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataCollectionRun.setDistance(XSDataLength(fDistance))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList, "overlaps")
        strOverlaps = xsItemOverlaps.getValueOf_()
        xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        return xsDataCollectionRun
예제 #16
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        """
        """

        xsDataBestOutput = XSDataBestOutput()
        strDnaTablesXML = self.readProcessFile(_strFileName)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        # Loop through all the tables and fill in the relevant parts of xsDataBestOutput

        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "data_collection_strategy")

        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsCollectionRunList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "collection_run")

            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(xsCollectionRunItemList)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)

            # Strategy Summary
            xsStrategySummaryItemList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "summary")
            xsDataStrategySummary = self.strategySummaryItemListToStrategySummary(xsStrategySummaryItemList[0])
            # Ranking Resolution
            # Not part of strategySummaryItemListToStrategySummary method since it is in the general_form part
            xsTableGeneralInform = EDUtilsTable.getTableFromTables(xsDataDnaTables, "general_inform")
            xsRankingResolutionItemList = EDUtilsTable.getListsFromTable(xsTableGeneralInform, "ranking_resolution")
            xsItemRankingResolution = EDUtilsTable.getItemFromList(xsRankingResolutionItemList[0], "dmin")
            fRankingResolution = float(xsItemRankingResolution.getValueOf_())
            xsDataStrategySummary.setRankingResolution(XSDataFloat(fRankingResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

            # Satistics
            xsTablesStatisticalPrediction = EDUtilsTable.getTableListFromTables(xsDataDnaTables, "statistical_prediction")
            for xsTableStatisticalPrediction in xsTablesStatisticalPrediction:
                if(xsTableStatisticalPrediction.getIndex() == xsTableCollectionStrategy.getIndex()):
                    xsResolutionBinList = EDUtilsTable.getListsFromTable(xsTableStatisticalPrediction, "resolution_bin")
                    xsDataStatisticalPrediction = XSDataBestStatisticalPrediction()
                    for xsResolutionBinItemList in xsResolutionBinList:
                        xsDataResolutionBin = self.resolutionBinItemListToResolutionBin(xsResolutionBinItemList)
                        xsDataStatisticalPrediction.addResolutionBin(xsDataResolutionBin)

                    xsDataBestCollectionPlan.setStatisticalPrediction(xsDataStatisticalPrediction)

            xsDataBestOutput.addCollectionPlan(xsDataBestCollectionPlan)

        return xsDataBestOutput
예제 #17
0
    def getMOSFLMIntegrationStatisticsPerResolutionBin(self, _xsDataDnaTables, _strListName, _fMinResolution=None):
        """
        This method creates an XSDataMOSFLMIntegrationStatisticsPerResolutionBin object given an XSDataDnaTables object
        and a list name, e.g. "bin_1". If _fMinResolution is provided it is used for setting the minimum resolution,
        otherwise the min and max resolution are set to the same value provided by the xsDataList object.
        """
        xsDataTableProfileFittedFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_full")
        xsDataTableProfileFittedPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "profile_fitted_partial")
        xsDataTableSummationFull = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_full")
        xsDataTableSummationPartial = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "summation_partial")

        xsListProfileFittedFull = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedFull, _strListName)[0]
        xsListProfileFittedPartial = EDUtilsTable.getListsFromTable(xsDataTableProfileFittedPartial, _strListName)[0]
        xsListSummationFull = EDUtilsTable.getListsFromTable(xsDataTableSummationFull, _strListName)[0]
        xsListSummationPartial = EDUtilsTable.getListsFromTable(xsDataTableSummationPartial, _strListName)[0]

        xsDataMOSFLMIntegrationDataProfileFittedFull = self.getMOSFLMIntegrationStatistics(xsListProfileFittedFull)
        xsDataMOSFLMIntegrationDataProfileFittedPartials = self.getMOSFLMIntegrationStatistics(xsListProfileFittedPartial)
        xsDataMOSFLMIntegrationSummationFull = self.getMOSFLMIntegrationStatistics(xsListSummationFull)
        xsDataMOSFLMIntegrationSummationPartial = self.getMOSFLMIntegrationStatistics(xsListSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted = XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setFullyRecorded(xsDataMOSFLMIntegrationDataProfileFittedFull)
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted.setPartials(xsDataMOSFLMIntegrationDataProfileFittedPartials)

        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation = XSDataMOSFLMIntegrationStatisticsPerReflectionType()
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setFullyRecorded(xsDataMOSFLMIntegrationSummationFull)
        xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation.setPartials(xsDataMOSFLMIntegrationSummationPartial)

        xsDataMOSFLMIntegrationStatisticsPerResolutionBin = XSDataMOSFLMIntegrationStatisticsPerResolutionBin()
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setProfileFitted(xsDataMOSFLMIntegrationStatisticsPerReflectionTypeProfileFitted)
        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setSummation(xsDataMOSFLMIntegrationStatisticsPerReflectionTypeSummation)

        strMaxResolution = EDUtilsTable.getItemFromList(xsListProfileFittedFull, "resolution").getValueOf_()
        if strMaxResolution != "overall":
            xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMaxResolution(XSDataFloat(float(strMaxResolution)))
            if (_fMinResolution is not None):
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(_fMinResolution))
            else:
                xsDataMOSFLMIntegrationStatisticsPerResolutionBin.setMinResolution(XSDataFloat(float(strMaxResolution)))

        return xsDataMOSFLMIntegrationStatisticsPerResolutionBin
예제 #18
0
    def getBonlyOutputFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        xsTablesGeneralInform = EDUtilsTable.getTableListFromTables(
            _xsDataDnaTables, "general_inform")

        xsDataBestCollectionPlan = XSDataBestCollectionPlan()
        xsDataCrystalScale = XSDataCrystalScale()

        xsCrystalScaleList = EDUtilsTable.getListsFromTable(
            xsTablesGeneralInform[0], "crystal_scale")[0]

        xsItemScal = EDUtilsTable.getItemFromList(xsCrystalScaleList, "scal")
        fScal = float(xsItemScal.getValueOf_())
        xsDataCrystalScale.setScale(XSDataDouble(fScal))

        xsItemBfactor = EDUtilsTable.getItemFromList(xsCrystalScaleList,
                                                     "B_factor")
        fBfactor = float(xsItemBfactor.getValueOf_())
        xsDataCrystalScale.setBFactor(XSDataDouble(fBfactor))

        xsDataBestCollectionPlan.setCrystalScale(xsDataCrystalScale)
        xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)

        return xsDataResultBest
예제 #19
0
 def getOutputDataFromDNATableFile(self, _strFileName):
     """Parses the result 'DNA'-type XML file"""
     xsDataResultRdfit = XSDataResultRdfit()
     strDnaTablesXML = self.readProcessFile(_strFileName)
     xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
     # Loop through all the tables and fill in the relevant parts of xsDataResultBest
     xsDataRDFIT_Results = EDUtilsTable.getTableListFromTables(
         xsDataDnaTables, "RDFIT_Results")[0]
     xsDataListGeneral = EDUtilsTable.getListsFromTable(
         xsDataRDFIT_Results, "general")[0]
     xsDataItemBeta = EDUtilsTable.getItemFromList(xsDataListGeneral,
                                                   "beta")
     if xsDataItemBeta is not None:
         beta = xsDataItemBeta.getValueOf_()
         xsDataResultRdfit.setBeta(XSDataDouble(beta))
     xsDataItemGama = EDUtilsTable.getItemFromList(xsDataListGeneral,
                                                   "gama")
     if xsDataItemGama is not None:
         gama = xsDataItemGama.getValueOf_()
         xsDataResultRdfit.setGama(XSDataDouble(gama))
     xsDataItemDose_half_th = EDUtilsTable.getItemFromList(
         xsDataListGeneral, "Dose_1/2_th")
     if xsDataItemDose_half_th is not None:
         dose_half_th = xsDataItemDose_half_th.getValueOf_()
         xsDataResultRdfit.setDose_half_th(XSDataDouble(dose_half_th))
     xsDataItemDose_half = EDUtilsTable.getItemFromList(
         xsDataListGeneral, "Dose_1/2")
     if xsDataItemDose_half is not None:
         dose_half = xsDataItemDose_half.getValueOf_()
         xsDataResultRdfit.setDose_half(XSDataDouble(dose_half))
     xsDataItemRelative_radiation_sensitivity = EDUtilsTable.getItemFromList(
         xsDataListGeneral, "Relative_Radiation_Sensitivity")
     if xsDataItemRelative_radiation_sensitivity is not None:
         relative_radiation_sensitivity = xsDataItemRelative_radiation_sensitivity.getValueOf_(
         )
         xsDataResultRdfit.setRelative_radiation_sensitivity(
             XSDataDouble(relative_radiation_sensitivity))
     return xsDataResultRdfit
예제 #20
0
    def testTableListItem(self):
        xsItem = None
        xsItem2 = None
        strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "input")
        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_task")
        for xsList in xsLists:
            xsItem = EDUtilsTable.getItemFromList(xsList, "task")
            xsItem2 = EDUtilsTable.getItemFromList(xsList, "tata")
        EDAssert.equal("optimize", xsItem.getValueOf_())

        EDAssert.equal(None, xsItem2)

        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_tata")
        EDAssert.equal([], xsLists)

        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "toto")
        EDAssert.equal(None, xsTable)

        EDVerbose.DEBUG("Test done...")
예제 #21
0
    def testTableListItem(self):
        xsItem = None
        xsItem2 = None
        strDnaTablesXML = EDUtilsFile.readFile(self.__strFilePath)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "input")
        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_task")
        for xsList in xsLists:
            xsItem = EDUtilsTable.getItemFromList(xsList, "task")
            xsItem2 = EDUtilsTable.getItemFromList(xsList, "tata")
        EDAssert.equal("optimize", xsItem.getValueOf_())

        EDAssert.equal(None, xsItem2)

        xsLists = EDUtilsTable.getListsFromTable(xsTable, "select_tata")
        EDAssert.equal([], xsLists)

        xsTable = EDUtilsTable.getTableFromTables(xsDataDnaTables, "toto")
        EDAssert.equal(None, xsTable)

        EDVerbose.DEBUG("Test done...")
    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
예제 #23
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        xsDataResultBest = XSDataResultBest()
        strDnaTablesXML = self.readProcessFile(_strFileName)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        # Loop through all the tables and fill in the relevant parts of xsDataResultBest

        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            xsDataDnaTables, "data_collection_strategy")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsCollectionRunList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "collection_run")

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList)
                xsDataCollectionRun.setCollectionRunNumber(
                    XSDataInteger(iCollectionRunNumber))
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1

            # Strategy Summary
            xsStrategySummaryItemList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "summary")
            xsDataStrategySummary = self.strategySummaryItemListToStrategySummary(
                xsStrategySummaryItemList[0])
            # Ranking Resolution
            # Not part of strategySummaryItemListToStrategySummary method since it is in the general_form part
            xsTableGeneralInform = EDUtilsTable.getTableFromTables(
                xsDataDnaTables, "general_inform")
            xsRankingResolutionItemList = EDUtilsTable.getListsFromTable(
                xsTableGeneralInform, "ranking_resolution")
            xsItemRankingResolution = EDUtilsTable.getItemFromList(
                xsRankingResolutionItemList[0], "dmin")
            fRankingResolution = float(xsItemRankingResolution.getValueOf_())
            xsDataStrategySummary.setRankingResolution(
                XSDataDouble(fRankingResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

            # Satistics
            xsTablesStatisticalPrediction = EDUtilsTable.getTableListFromTables(
                xsDataDnaTables, "statistical_prediction")
            for xsTableStatisticalPrediction in xsTablesStatisticalPrediction:
                if (xsTableStatisticalPrediction.getIndex() ==
                        xsTableCollectionStrategy.getIndex()):
                    xsResolutionBinList = EDUtilsTable.getListsFromTable(
                        xsTableStatisticalPrediction, "resolution_bin")
                    xsDataStatisticalPrediction = XSDataBestStatisticalPrediction(
                    )
                    for xsResolutionBinItemList in xsResolutionBinList:
                        xsDataResolutionBin = self.resolutionBinItemListToResolutionBin(
                            xsResolutionBinItemList)
                        xsDataStatisticalPrediction.addResolutionBin(
                            xsDataResolutionBin)

                    xsDataBestCollectionPlan.setStatisticalPrediction(
                        xsDataStatisticalPrediction)

            xsDataBestCollectionPlan.setCollectionPlanNumber(
                XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

        # Fix the order of the collection plans - then low resolution pass should be the first one
        listCollectionPlan = xsDataResultBest.getCollectionPlan()
        if (len(listCollectionPlan) > 1):
            bIsModified = False
            for xsDataCollectionPlan in listCollectionPlan:
                xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary(
                )
                strReasoning = xsDataStrategySummary.getResolutionReasoning(
                ).getValue()
                if (strReasoning.find("Low-resolution") !=
                        -1) and (xsDataCollectionPlan.getCollectionPlanNumber(
                        ).getValue() != 1):
                    listCollectionPlan.remove(xsDataCollectionPlan)
                    listCollectionPlan.insert(0, xsDataCollectionPlan)
                    bIsModified = True
            if (bIsModified):
                iCollectionPlanNumber = 1
                for xsDataCollectionPlan in listCollectionPlan:
                    xsDataCollectionPlan.setCollectionPlanNumber(
                        XSDataInteger(iCollectionPlanNumber))
                    iCollectionPlanNumber = iCollectionPlanNumber + 1

        return xsDataResultBest
예제 #24
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
예제 #25
0
    def resolutionBinItemListToResolutionBin(self, _xsResolutionBinItemList):
        """
        """
        xsDataResolutionBin = XSDataBestResolutionBin()

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "min_resolution")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setMinResolution(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "max_resolution")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setMaxResolution(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "completeness")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setCompleteness(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "redundancy")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setRedundancy(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_intensity")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setAverageIntensity(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_error")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setAverageSigma(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "average_i_over_sigma")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setIOverSigma(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "R_factor")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setRFactor(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "Chi**2")
        if (pyStrItem is not None):
            fItem = float(pyStrItem.getValueOf_())
            xsDataResolutionBin.setChi2(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(
            _xsResolutionBinItemList, "average_i_over_sigma_Chi**2")
        if (pyStrItem is not None):
            fItem = float(pyStrItem.getValueOf_())
            xsDataResolutionBin.setIOverSigmaChi(XSDataDouble(fItem))

        pyStrItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList,
                                                 "fract_overload")
        fItem = float(pyStrItem.getValueOf_())
        xsDataResolutionBin.setPercentageOverload(XSDataDouble(fItem))

        return xsDataResolutionBin
    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
예제 #27
0
    def getDataCollectionOutputDataFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(_xsDataDnaTables, "data_collection_strategy")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsCollectionRunList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "collection_run")

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(xsCollectionRunItemList, iCollectionRunNumber)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1


            # Strategy Summary
            xsStrategySummaryItemList = EDUtilsTable.getListsFromTable(xsTableCollectionStrategy, "summary")
            xsDataStrategySummary = self.strategySummaryItemListToStrategySummary(xsStrategySummaryItemList[0])
            # Ranking Resolution
            # Not part of strategySummaryItemListToStrategySummary method since it is in the general_form part
            xsTableGeneralInform = EDUtilsTable.getTableFromTables(_xsDataDnaTables, "general_inform")
            xsRankingResolutionItemList = EDUtilsTable.getListsFromTable(xsTableGeneralInform, "ranking_resolution")
            xsItemRankingResolution = EDUtilsTable.getItemFromList(xsRankingResolutionItemList[0], "dmin")
            fRankingResolution = float(xsItemRankingResolution.getValueOf_())
            xsDataStrategySummary.setRankingResolution(XSDataDouble(fRankingResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

            # Satistics
            xsTablesStatisticalPrediction = EDUtilsTable.getTableListFromTables(_xsDataDnaTables, "statistical_prediction")
            for xsTableStatisticalPrediction in xsTablesStatisticalPrediction:
                if(xsTableStatisticalPrediction.getIndex() == xsTableCollectionStrategy.getIndex()):
                    xsResolutionBinList = EDUtilsTable.getListsFromTable(xsTableStatisticalPrediction, "resolution_bin")
                    xsDataStatisticalPrediction = XSDataBestStatisticalPrediction()
                    for xsResolutionBinItemList in xsResolutionBinList:
                        xsDataResolutionBin = self.resolutionBinItemListToResolutionBin(xsResolutionBinItemList)
                        xsDataStatisticalPrediction.addResolutionBin(xsDataResolutionBin)

                    xsDataBestCollectionPlan.setStatisticalPrediction(xsDataStatisticalPrediction)

            xsDataBestCollectionPlan.setCollectionPlanNumber(XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

        # Fix the order of the collection plans - then low resolution pass should be the first one
        listCollectionPlan = xsDataResultBest.getCollectionPlan()
        if (len(listCollectionPlan) > 1):
            bIsModified = False
            for xsDataCollectionPlan in listCollectionPlan:
                xsDataStrategySummary = xsDataCollectionPlan.getStrategySummary()
                strReasoning = xsDataStrategySummary.getResolutionReasoning().getValue()
                if ((strReasoning.find("Low-resolution") != -1) and xsDataCollectionPlan.getCollectionPlanNumber().getValue() != 1):
                    listCollectionPlan.remove(xsDataCollectionPlan)
                    listCollectionPlan.insert(0, xsDataCollectionPlan)
                    bIsModified = True
            if (bIsModified):
                iCollectionPlanNumber = 1
                for xsDataCollectionPlan in listCollectionPlan:
                    xsDataCollectionPlan.setCollectionPlanNumber(XSDataInteger(iCollectionPlanNumber))
                    iCollectionPlanNumber = iCollectionPlanNumber + 1

        return xsDataResultBest
    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
예제 #29
0
    def resolutionBinItemListToResolutionBin(self, _xsResolutionBinItemList):
        xsDataResolutionBin = XSDataBestResolutionBin()

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "min_resolution")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setMinResolution(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "max_resolution")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setMaxResolution(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "completeness")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setCompleteness(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "redundancy")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setRedundancy(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "average_intensity")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setAverageIntensity(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "average_error")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setAverageSigma(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "average_i_over_sigma")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setIOverSigma(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "average_i_over_average_sigma")
        if (strItem is not None):
            fItem = float(strItem.getValueOf_())
            xsDataResolutionBin.setAverageIntensityOverAverageSigma(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "R_factor")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setRFactor(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "R_friedel")
        if (strItem is not None):
            fItem = float(strItem.getValueOf_())
            xsDataResolutionBin.setRFriedel(XSDataDouble(fItem))

#        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "average_i_over_sigma_Chi**2")
#        if (strItem is not None):
#            fItem = float(strItem.getValueOf_())
#            xsDataResolutionBin.setIOverSigmaChi(XSDataDouble(fItem))

        strItem = EDUtilsTable.getItemFromList(_xsResolutionBinItemList, "fract_overload")
        fItem = float(strItem.getValueOf_())
        xsDataResolutionBin.setPercentageOverload(XSDataDouble(fItem))

        return xsDataResolutionBin
예제 #30
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        """
        """

        xsDataBestOutput = XSDataBestOutput()
        strDnaTablesXML = self.readProcessFile(_strFileName)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        # Loop through all the tables and fill in the relevant parts of xsDataBestOutput

        # SubWedges
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            xsDataDnaTables, "data_collection_strategy")

        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsCollectionRunList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "collection_run")

            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)

            # Strategy Summary
            xsStrategySummaryItemList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "summary")
            xsDataStrategySummary = self.strategySummaryItemListToStrategySummary(
                xsStrategySummaryItemList[0])
            # Ranking Resolution
            # Not part of strategySummaryItemListToStrategySummary method since it is in the general_form part
            xsTableGeneralInform = EDUtilsTable.getTableFromTables(
                xsDataDnaTables, "general_inform")
            xsRankingResolutionItemList = EDUtilsTable.getListsFromTable(
                xsTableGeneralInform, "ranking_resolution")
            xsItemRankingResolution = EDUtilsTable.getItemFromList(
                xsRankingResolutionItemList[0], "dmin")
            fRankingResolution = float(xsItemRankingResolution.getValueOf_())
            xsDataStrategySummary.setRankingResolution(
                XSDataFloat(fRankingResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

            # Satistics
            xsTablesStatisticalPrediction = EDUtilsTable.getTableListFromTables(
                xsDataDnaTables, "statistical_prediction")
            for xsTableStatisticalPrediction in xsTablesStatisticalPrediction:
                if (xsTableStatisticalPrediction.getIndex() ==
                        xsTableCollectionStrategy.getIndex()):
                    xsResolutionBinList = EDUtilsTable.getListsFromTable(
                        xsTableStatisticalPrediction, "resolution_bin")
                    xsDataStatisticalPrediction = XSDataBestStatisticalPrediction(
                    )
                    for xsResolutionBinItemList in xsResolutionBinList:
                        xsDataResolutionBin = self.resolutionBinItemListToResolutionBin(
                            xsResolutionBinItemList)
                        xsDataStatisticalPrediction.addResolutionBin(
                            xsDataResolutionBin)

                    xsDataBestCollectionPlan.setStatisticalPrediction(
                        xsDataStatisticalPrediction)

            xsDataBestOutput.addCollectionPlan(xsDataBestCollectionPlan)

        return xsDataBestOutput