Ejemplo n.º 1
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
Ejemplo n.º 2
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        xsDataResultBest = XSDataResultBest()
        if os.path.exists(_strFileName):
            strDnaTablesXML = self.readProcessFile(_strFileName)
            # Fix for MXSUP-1751: Error when parsing broken XML
            try:
                xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
            except Exception as e:
                self.setFailure()
                self.error("Parsing of BEST XML file failed: %s" % e)

            # Loop through all the tables and fill in the relevant parts of xsDataResultBest
            if not self.isFailure():
                xsDataStringStrategyOption = self.getDataInput(
                ).getStrategyOption()
                if (xsDataStringStrategyOption is not None):
                    strStrategyOption = xsDataStringStrategyOption.getValue()
                    if (strStrategyOption.find("-DamPar") != -1):
                        xsDataResultBest = self.getDamParOutputFromDNATables(
                            xsDataDnaTables)
                    elif (strStrategyOption.find("-Bonly") != -1):
                        xsDataResultBest = self.getBonlyOutputFromDNATables(
                            xsDataDnaTables)
                    else:
                        xsDataResultBest = self.getDataCollectionOutputDataFromDNATables(
                            xsDataDnaTables)
                else:
                    xsDataResultBest = self.getDataCollectionOutputDataFromDNATables(
                        xsDataDnaTables)

        return xsDataResultBest
Ejemplo n.º 3
0
 def finallyProcess(self, _edObject=None):
     EDPluginExecProcessScript.finallyProcess(self)
     self.DEBUG("EDPluginBestv1_2.finallyProcess")
     strError = self.readProcessErrorLogFile()
     if ((strError is not None) and (strError != "")):
         strErrorMessage = EDMessage.ERROR_EXECUTION_03 % (
             'EDPluginBestv1_2.postProcess', 'EDPluginBestv1_2', strError)
         self.error(strErrorMessage)
         self.addErrorMessage(strErrorMessage)
         self.setDataOutput(XSDataResultBest())
         self.setFailure()
     else:
         xsDataResultBest = self.getOutputDataFromDNATableFile(
             os.path.join(self.getWorkingDirectory(),
                          self.getScriptBaseName() + "_dnaTables.xml"))
         xsDataFilePathToLog = XSDataFile(
             XSDataString(
                 os.path.join(self.getWorkingDirectory(),
                              self.getScriptLogFileName())))
         xsDataResultBest.setPathToLogFile(xsDataFilePathToLog)
         xsDataFilePathToPlotMtv = XSDataFile(
             XSDataString(
                 os.path.join(self.getWorkingDirectory(),
                              self.getScriptBaseName() + "_plots.mtv")))
         xsDataResultBest.setPathToPlotMtvFile(xsDataFilePathToPlotMtv)
         self.setDataOutput(xsDataResultBest)
Ejemplo n.º 4
0
    def __init__(self):
        EDPluginExecProcessScript.__init__(self)
        self.setXSDataInputClass(XSDataInputBest)
        self.setDataOutput(XSDataResultBest())

        # This version of the Best plugin requires the latest
        # version of Best.
        self.addCompatibleVersion("Version 4.1.0 //  02.10.2012")

        self.strCONF_BEST_HOME_LABEL = "besthome"

        # Default value of strategy complexity
        self.strComplexity = "none"

        self.strBestHome = None
        self.strCommandBestHome = None
        self.strCommandBest = None

        self.strExposureTime = None
        self.strDoseRate = None
        self.strDetectorType = None

        self.strPathToBestDatFile = None
        self.strPathToBestParFile = None
        self.listFileBestHKL = []

        self.strPathToCorrectLp = None
        self.strPathToBkgpixCbf = None
        self.strListFileXdsAsciiHkl = None

        self.bVersionHigherThan4_0 = False
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
0
    def testGenerateExecutiveSummary(self):
        pyStrInputBest = self.readAndParseFile (self.m_edReferenceInputFile)
        pyStrResultBest = self.readAndParseFile (self.m_edReferenceResultFile)

        from XSDataBestv1_2 import XSDataInputBest
        from XSDataBestv1_2 import XSDataResultBest

        xsDataInputBest = XSDataInputBest.parseString(pyStrInputBest)
        xsDataResultBest = XSDataResultBest.parseString(pyStrResultBest)
        edPluginBest = self.createPlugin()
        edPluginBest.setDataInput(xsDataInputBest)
        edPluginBest.setDataOutput(xsDataResultBest)
        edPluginBest.generateExecutiveSummary(edPluginBest)
Ejemplo n.º 8
0
    def testGenerateExecutiveSummary(self):
        pyStrInputBest = self.readAndParseFile(self.m_edReferenceInputFile)
        pyStrResultBest = self.readAndParseFile(self.m_edReferenceResultFile)

        from XSDataBestv1_2 import XSDataInputBest
        from XSDataBestv1_2 import XSDataResultBest

        xsDataInputBest = XSDataInputBest.parseString(pyStrInputBest)
        xsDataResultBest = XSDataResultBest.parseString(pyStrResultBest)
        edPluginBest = self.createPlugin()
        edPluginBest.setDataInput(xsDataInputBest)
        edPluginBest.setDataOutput(xsDataResultBest)
        edPluginBest.generateExecutiveSummary(edPluginBest)
Ejemplo n.º 9
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
Ejemplo n.º 10
0
    def getOutputDataFromDNATableFile(self, _strFileName):
        strDnaTablesXML = self.readProcessFile(_strFileName)
        xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)
        xsDataResultBest = XSDataResultBest()
        # Loop through all the tables and fill in the relevant parts of xsDataResultBest

        xsDataStringStrategyOption = self.getDataInput().getStrategyOption()
        if (xsDataStringStrategyOption is not None):
            strStrategyOption = xsDataStringStrategyOption.getValue()
            if (strStrategyOption.find("-DamPar") != -1):
                xsDataResultBest = self.getDamParOutputFromDNATables(
                    xsDataDnaTables)
            elif (strStrategyOption.find("-Bonly") != -1):
                xsDataResultBest = self.getBonlyOutputFromDNATables(
                    xsDataDnaTables)
            else:
                xsDataResultBest = self.getDataCollectionOutputDataFromDNATables(
                    xsDataDnaTables)
        else:
            xsDataResultBest = self.getDataCollectionOutputDataFromDNATables(
                xsDataDnaTables)

        return xsDataResultBest
Ejemplo n.º 11
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
Ejemplo n.º 12
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