Пример #1
0
    def createDataMOSFLMOutputIntegration(self):
        self.DEBUG("EDPluginMOSFLMIntegrationv10.createDataMOSFLMOutputIntegration")
        xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration()
        # Read bestfile.par, bestfile.hkl and bestfile.dat
        strBestfilePar = self.readBestFile("bestfile.par")
        bContinue = True
        if (strBestfilePar is not None):
            xsDataMOSFLMOutputIntegration.setBestfilePar(XSDataString(strBestfilePar))
        else:
            bContinue = False

        if bContinue:
            strBestfileHKL = self.readBestFile("bestfile.hkl")
            if (strBestfileHKL is not None):
                xsDataMOSFLMOutputIntegration.setBestfileHKL(XSDataString(strBestfileHKL))
            else:
                bContinue = False

        if bContinue:
            strBestfileDat = self.readBestFile("bestfile.dat")
            if (strBestfileDat is not None):
                xsDataMOSFLMOutputIntegration.setBestfileDat(XSDataString(strBestfileDat))
            else:
                bContinue = False

        if bContinue:
            strDnaTablesXML = self.readProcessFile(self.getBaseName() + "_dnaTables.xml")
            xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)

            xsTableIntegrationResults = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_results")
            xsListFinalResiduals = EDUtilsTable.getListsFromTable(xsTableIntegrationResults, "final_residuals")[0]
            strRMSSpotDeviation = EDUtilsTable.getItemFromList(xsListFinalResiduals, "rms").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRMSSpotDeviation(XSDataLength(float(strRMSSpotDeviation)))
            strBeamPositionX = EDUtilsTable.getItemFromList(xsListFinalResiduals, "xcen").getValueOf_()
            strBeamPositionY = EDUtilsTable.getItemFromList(xsListFinalResiduals, "ycen").getValueOf_()
            xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
            xsDataMOSFLMBeamPosition.setX(XSDataLength(float(strBeamPositionX)))
            xsDataMOSFLMBeamPosition.setY(XSDataLength(float(strBeamPositionY)))
            xsDataMOSFLMOutputIntegration.setRefinedBeam(xsDataMOSFLMBeamPosition)

            xsDataMOSFLMNewmatMatrix = self.getDataMOSFLMMatrix()
            xsDataMOSFLMOutputIntegration.setRefinedNewmat(xsDataMOSFLMNewmatMatrix)

            # New results (described in bug #63)

            xsTableIntegrationOutput = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_output")
            xsListOutputFiles = EDUtilsTable.getListsFromTable(xsTableIntegrationOutput, "output_files")[0]

            strMTZFilename = EDUtilsTable.getItemFromList(xsListOutputFiles, "hklout").getValueOf_()
            strMTZPath = os.path.join(self.getWorkingDirectory(), strMTZFilename)
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strMTZPath))
            xsDataMOSFLMOutputIntegration.setGeneratedMTZFile(xsDataFile)

            xsTableSummaryInformation = EDUtilsTable.getTableFromTables(xsDataDnaTables, "summary_information")
            xsListSummary = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "summary")[0]
            xsListSpots = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "spots")[0]

            strDistance = EDUtilsTable.getItemFromList(xsListSummary, "distance").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedDistance(XSDataLength(float(strDistance)))

            strYScale = EDUtilsTable.getItemFromList(xsListSummary, "yscale").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedYScale(XSDataFloat(float(strYScale)))

            strOverallIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigall").getValueOf_()
            xsDataMOSFLMOutputIntegration.setOverallIOverSigma(XSDataFloat(float(strOverallIOverSigma)))

            strHighestResolutionIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigout").getValueOf_()
            xsDataMOSFLMOutputIntegration.setHighestResolutionIOverSigma(XSDataFloat(float(strHighestResolutionIOverSigma)))

            strNumberOfBadReflections = EDUtilsTable.getItemFromList(xsListSpots, "bad_spots").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfBadReflections(XSDataInteger(int(strNumberOfBadReflections)))

            strNumberOfFullyRecordedReflections = EDUtilsTable.getItemFromList(xsListSpots, "full").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfFullyRecordedReflections(XSDataInteger(int(strNumberOfFullyRecordedReflections)))

            strNumberOfNegativeReflections = EDUtilsTable.getItemFromList(xsListSpots, "negative").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfNegativeReflections(XSDataInteger(int(strNumberOfNegativeReflections)))

            strNumberOfOverlappedReflections = EDUtilsTable.getItemFromList(xsListSpots, "overlap").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfOverlappedReflections(XSDataInteger(int(strNumberOfOverlappedReflections)))

            strNumberOfPartialReflections = EDUtilsTable.getItemFromList(xsListSpots, "partial").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfPartialReflections(XSDataInteger(int(strNumberOfPartialReflections)))

            # Fill in the statistics

            xsDataMOSFLMOutputIntegration.setOverallStatistics(self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, "bin_0"))

            iIndex = 1
            bContinue = True
            fMinResolution = None
            while (bContinue == True):
                strBin = "bin_%d" % iIndex
                # I don't know how many intensity bins there are. Since the EDUtilsTable.getListsFromTable
                # method crashes if the list is not present, I had to wrap the calls to this method in
                # try - except:
                try:
                    xsDataMOSFLMIntegrationStatisticsPerResolutionBin = self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, strBin, fMinResolution)
                    fMinResolution = xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution().getValue()
                    xsDataMOSFLMOutputIntegration.addStatisticsPerResolutionBin(xsDataMOSFLMIntegrationStatisticsPerResolutionBin)
                    iIndex += 1
                except:
                    bContinue = False

        # Path to log file
        xsDataMOSFLMOutputIntegration.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))))
        return xsDataMOSFLMOutputIntegration
    def createDataMOSFLMOutputIntegration(self):
        self.DEBUG("EDPluginMOSFLMIntegrationv10.createDataMOSFLMOutputIntegration")
        xsDataMOSFLMOutputIntegration = XSDataMOSFLMOutputIntegration()
        # Read bestfile.par, bestfile.hkl and bestfile.dat
        strBestfilePar = self.readBestFile("bestfile.par")
        bContinue = True
        if (strBestfilePar is not None):
            xsDataMOSFLMOutputIntegration.setBestfilePar(XSDataString(strBestfilePar))
        else:
            bContinue = False

        if bContinue:
            strBestfileHKL = self.readBestFile("bestfile.hkl")
            if (strBestfileHKL is not None):
                xsDataMOSFLMOutputIntegration.setBestfileHKL(XSDataString(strBestfileHKL))
            else:
                bContinue = False

        if bContinue:
            strBestfileDat = self.readBestFile("bestfile.dat")
            if (strBestfileDat is not None):
                xsDataMOSFLMOutputIntegration.setBestfileDat(XSDataString(strBestfileDat))
            else:
                bContinue = False

        if bContinue:
            strDnaTablesXML = self.readProcessFile(self.getBaseName() + "_dnaTables.xml")
            xsDataDnaTables = dna_tables.parseString(strDnaTablesXML)

            xsTableIntegrationResults = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_results")
            xsListFinalResiduals = EDUtilsTable.getListsFromTable(xsTableIntegrationResults, "final_residuals")[0]
            strRMSSpotDeviation = EDUtilsTable.getItemFromList(xsListFinalResiduals, "rms").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRMSSpotDeviation(XSDataLength(float(strRMSSpotDeviation)))
            strBeamPositionX = EDUtilsTable.getItemFromList(xsListFinalResiduals, "xcen").getValueOf_()
            strBeamPositionY = EDUtilsTable.getItemFromList(xsListFinalResiduals, "ycen").getValueOf_()
            xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
            xsDataMOSFLMBeamPosition.setX(XSDataLength(float(strBeamPositionX)))
            xsDataMOSFLMBeamPosition.setY(XSDataLength(float(strBeamPositionY)))
            xsDataMOSFLMOutputIntegration.setRefinedBeam(xsDataMOSFLMBeamPosition)

            xsDataMOSFLMNewmatMatrix = self.getDataMOSFLMMatrix()
            xsDataMOSFLMOutputIntegration.setRefinedNewmat(xsDataMOSFLMNewmatMatrix)

            # New results (described in bug #63)

            xsTableIntegrationOutput = EDUtilsTable.getTableFromTables(xsDataDnaTables, "integration_output")
            xsListOutputFiles = EDUtilsTable.getListsFromTable(xsTableIntegrationOutput, "output_files")[0]

            strMTZFilename = EDUtilsTable.getItemFromList(xsListOutputFiles, "hklout").getValueOf_()
            strMTZPath = os.path.join(self.getWorkingDirectory(), strMTZFilename)
            xsDataFile = XSDataFile()
            xsDataFile.setPath(XSDataString(strMTZPath))
            xsDataMOSFLMOutputIntegration.setGeneratedMTZFile(xsDataFile)

            xsTableSummaryInformation = EDUtilsTable.getTableFromTables(xsDataDnaTables, "summary_information")
            xsListSummary = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "summary")[0]
            xsListSpots = EDUtilsTable.getListsFromTable(xsTableSummaryInformation, "spots")[0]

            strDistance = EDUtilsTable.getItemFromList(xsListSummary, "distance").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedDistance(XSDataLength(float(strDistance)))

            strYScale = EDUtilsTable.getItemFromList(xsListSummary, "yscale").getValueOf_()
            xsDataMOSFLMOutputIntegration.setRefinedYScale(XSDataFloat(float(strYScale)))

            strOverallIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigall").getValueOf_()
            xsDataMOSFLMOutputIntegration.setOverallIOverSigma(XSDataFloat(float(strOverallIOverSigma)))

            strHighestResolutionIOverSigma = EDUtilsTable.getItemFromList(xsListSummary, "isigout").getValueOf_()
            xsDataMOSFLMOutputIntegration.setHighestResolutionIOverSigma(XSDataFloat(float(strHighestResolutionIOverSigma)))

            strNumberOfBadReflections = EDUtilsTable.getItemFromList(xsListSpots, "bad_spots").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfBadReflections(XSDataInteger(int(strNumberOfBadReflections)))

            strNumberOfFullyRecordedReflections = EDUtilsTable.getItemFromList(xsListSpots, "full").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfFullyRecordedReflections(XSDataInteger(int(strNumberOfFullyRecordedReflections)))

            strNumberOfNegativeReflections = EDUtilsTable.getItemFromList(xsListSpots, "negative").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfNegativeReflections(XSDataInteger(int(strNumberOfNegativeReflections)))

            strNumberOfOverlappedReflections = EDUtilsTable.getItemFromList(xsListSpots, "overlap").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfOverlappedReflections(XSDataInteger(int(strNumberOfOverlappedReflections)))

            strNumberOfPartialReflections = EDUtilsTable.getItemFromList(xsListSpots, "partial").getValueOf_()
            xsDataMOSFLMOutputIntegration.setNumberOfPartialReflections(XSDataInteger(int(strNumberOfPartialReflections)))

            # Fill in the statistics

            xsDataMOSFLMOutputIntegration.setOverallStatistics(self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, "bin_0"))

            iIndex = 1
            bContinue = True
            fMinResolution = None
            while (bContinue == True):
                strBin = "bin_%d" % iIndex
                # I don't know how many intensity bins there are. Since the EDUtilsTable.getListsFromTable
                # method crashes if the list is not present, I had to wrap the calls to this method in
                # try - except:
                try:
                    xsDataMOSFLMIntegrationStatisticsPerResolutionBin = self.getMOSFLMIntegrationStatisticsPerResolutionBin(xsDataDnaTables, strBin, fMinResolution)
                    fMinResolution = xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution().getValue()
                    xsDataMOSFLMOutputIntegration.addStatisticsPerResolutionBin(xsDataMOSFLMIntegrationStatisticsPerResolutionBin)
                    iIndex += 1
                except:
                    bContinue = False

        # Path to log file
        xsDataMOSFLMOutputIntegration.setPathToLogFile(XSDataFile(XSDataString(os.path.join(self.getWorkingDirectory(), self.getScriptLogFileName()))))
        return xsDataMOSFLMOutputIntegration