Пример #1
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 5.1.0 //  07.07.2015")
        self.addCompatibleVersion("Version 5.1.1 //  18.11.2015")

        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.bVersionHigherThan4_0 = False
Пример #2
0
 def getBonlyOutputFromLog(self, _strBestLog):
     listLog = _strBestLog.split("\n")
     indexLine = 0
     xsDataResultBest = XSDataResultBest()
     xsDataBestCollectionPlan = XSDataBestCollectionPlan()
     xsDataCrystalScale = XSDataCrystalScale()
     #
     while not "Relative scale" in listLog[indexLine]:
         indexLine += 1
     xsDataCrystalScale.scale = XSDataDouble(listLog[indexLine].split()[-1])
     #
     while not "Overall B-factor" in listLog[indexLine]:
         indexLine += 1
     xsDataCrystalScale.bFactor = XSDataDouble(listLog[indexLine].split()[-2])
     xsDataBestCollectionPlan.crystalScale = xsDataCrystalScale
     xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
     return xsDataResultBest
Пример #3
0
 def getBonlyOutputFromLog(self, _strBestLog):
     listLog = _strBestLog.split("\n")
     indexLine = 0
     xsDataResultBest = XSDataResultBest()
     xsDataBestCollectionPlan = XSDataBestCollectionPlan()
     xsDataCrystalScale = XSDataCrystalScale()
     #
     while not "Relative scale" in listLog[indexLine]:
         indexLine += 1
     xsDataCrystalScale.scale = XSDataDouble(listLog[indexLine].split()[-1])
     #
     while not "Overall B-factor" in listLog[indexLine]:
         indexLine += 1
     xsDataCrystalScale.bFactor = XSDataDouble(
         listLog[indexLine].split()[-2])
     xsDataBestCollectionPlan.crystalScale = xsDataCrystalScale
     xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
     return xsDataResultBest
 def testGetXSDataResultBest4(self):
     edPluginBest = self.createPlugin()
     xsDataInputBest = XSDataInputBest()
     edPluginBest.dataInput = xsDataInputBest
     # Test 1
     xsDataResultBest = edPluginBest.getXSDataResultBest(os.path.join(self.strDataPath, "unit_test_4_best.log"))
     xsDataResultBestReference = XSDataResultBest.parseFile(os.path.join(self.strDataPath, "XSDataResultBest_unit_test_4.xml"))
     print xsDataResultBest.marshal()
     EDAssert.equal(xsDataResultBestReference.collectionPlan[0].marshal(), 
                    xsDataResultBest.collectionPlan[0].marshal(), "Collection plan")
Пример #5
0
 def testGetXSDataResultBest4(self):
     edPluginBest = self.createPlugin()
     xsDataInputBest = XSDataInputBest()
     edPluginBest.dataInput = xsDataInputBest
     # Test 1
     xsDataResultBest = edPluginBest.getXSDataResultBest(
         os.path.join(self.strDataPath, "unit_test_4_best.log"))
     xsDataResultBestReference = XSDataResultBest.parseFile(
         os.path.join(self.strDataPath, "XSDataResultBest_unit_test_4.xml"))
     print xsDataResultBest.marshal()
     EDAssert.equal(xsDataResultBestReference.collectionPlan[0].marshal(),
                    xsDataResultBest.collectionPlan[0].marshal(),
                    "Collection plan")
Пример #6
0
    def testGenerateExecutiveSummary(self):
        pyStrInputBest = self.readAndParseFile(self.referenceInputFile)
        pyStrResultBest = self.readAndParseFile(self.referenceResultFile)

        from XSDataBestv1_3 import XSDataInputBest
        from XSDataBestv1_3 import XSDataResultBest

        xsDataInputBest = XSDataInputBest.parseString(pyStrInputBest)
        xsDataResultBest = XSDataResultBest.parseString(pyStrResultBest)
        edPluginBest = self.createPlugin()
        edPluginBest.setDataInput(xsDataInputBest)
        edPluginBest.setDataOutput(xsDataResultBest)
        edPluginBest.generateExecutiveSummary(edPluginBest)
    def testGenerateExecutiveSummary(self):
        pyStrInputBest = self.readAndParseFile (self.referenceInputFile)
        pyStrResultBest = self.readAndParseFile (self.referenceResultFile)

        from XSDataBestv1_3 import XSDataInputBest
        from XSDataBestv1_3 import XSDataResultBest

        xsDataInputBest = XSDataInputBest.parseString(pyStrInputBest)
        xsDataResultBest = XSDataResultBest.parseString(pyStrResultBest)
        edPluginBest = self.createPlugin()
        edPluginBest.setDataInput(xsDataInputBest)
        edPluginBest.setDataOutput(xsDataResultBest)
        edPluginBest.generateExecutiveSummary(edPluginBest)
    def testGetXSDataResultBest2(self):
        edPluginBest = self.createPlugin()
        xsDataInputBest = XSDataInputBest()
        edPluginBest.dataInput = xsDataInputBest
        # Test 1
        xsDataResultBest = edPluginBest.getXSDataResultBest(os.path.join(self.strDataPath, "unit_test_2_best.log"))
        xsDataResultBestReference = XSDataResultBest.parseFile(os.path.join(self.strDataPath, "XSDataResultBest_unit_test_2.xml"))
#        print xsDataResultBest.marshal()
        for index in range(len(xsDataResultBestReference.collectionPlan)):
            try:
                EDAssert.equal(xsDataResultBestReference.collectionPlan[index].marshal(), 
                           xsDataResultBest.collectionPlan[index].marshal(), "Collection plan {0}".format(index))
            except:
                pass
Пример #9
0
 def testGetXSDataResultBest2(self):
     edPluginBest = self.createPlugin()
     xsDataInputBest = XSDataInputBest()
     edPluginBest.dataInput = xsDataInputBest
     # Test 1
     xsDataResultBest = edPluginBest.getXSDataResultBest(
         os.path.join(self.strDataPath, "unit_test_2_best.log"))
     xsDataResultBestReference = XSDataResultBest.parseFile(
         os.path.join(self.strDataPath, "XSDataResultBest_unit_test_2.xml"))
     #        print xsDataResultBest.marshal()
     for index in range(len(xsDataResultBestReference.collectionPlan)):
         try:
             EDAssert.equal(
                 xsDataResultBestReference.collectionPlan[index].marshal(),
                 xsDataResultBest.collectionPlan[index].marshal(),
                 "Collection plan {0}".format(index))
         except:
             pass
Пример #10
0
    def getDataCollectionOutputDataFromLog(self, _strBestLog):
        xsDataResultBest = XSDataResultBest()
        # loop through the lines of the log file
        isScanningWedge = False
        indexLine = 0
        listLog = _strBestLog.split("\n")
        iCollectionPlanNumber = 1
        while indexLine < len(listLog):
            if "Plan of data collection for radiation damage characterisation" in listLog[indexLine]:
                xsDataBestCollectionPlan = XSDataBestCollectionPlan()
                xsDataBestStrategySummary = XSDataBestStrategySummary()
                indexLine += 2
                regEx = re.compile(""" Resolution limit =\s*(\d+\.\d+) Angstrom\s*Distance =\s*(\d+\.\d+)mm""")
                matchObj = regEx.search(listLog[indexLine])
                if matchObj == None:
                    raise BaseException("Cannot parse best log file!")
                resultMatch = matchObj.groups()
                resultion = float(resultMatch[0])
                distance = float(resultMatch[1])
                xsDataBestStrategySummary.resolution = XSDataDouble(resultion)
                xsDataBestStrategySummary.distance = XSDataLength(distance)
                xsDataBestCollectionPlan.strategySummary = xsDataBestStrategySummary
                # Burn strategy
                indexLine += 7
                collectionRunNumber = 1
                while not listLog[indexLine].startswith("-------------------------------"):
                    listLine = listLog[indexLine].split()
                    if listLine[0].startswith("exposure") or listLine[0].startswith("burn"):
                        xsDataBestCollectionRun = XSDataBestCollectionRun()
                        xsDataBestCollectionRun.collectionRunNumber = XSDataInteger(collectionRunNumber)
                        xsDataBestCollectionRun.action = XSDataString(listLine[0])
                        xsDataBestCollectionRun.phiStart = XSDataAngle(listLine[1])
                        xsDataBestCollectionRun.phiWidth = XSDataAngle(listLine[2])
                        xsDataBestCollectionRun.exposureTime = XSDataTime(listLine[3])
                        xsDataBestCollectionRun.numberOfImages = XSDataInteger(listLine[4].split("|")[0])
                        xsDataBestCollectionRun.transmission = XSDataDouble(listLine[5])
                        xsDataBestCollectionPlan.addCollectionRun(xsDataBestCollectionRun)
                        collectionRunNumber += 1
                    indexLine += 1
                xsDataBestCollectionPlan.collectionPlanNumber = XSDataInteger(iCollectionPlanNumber)
                xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            if "Main Wedge" in listLog[indexLine] or "Low resolution Wedge" in listLog[indexLine] \
                or "Strategy for SAD data collection" in listLog[indexLine]:
                isScanningWedge = True
                xsDataBestCollectionPlan = XSDataBestCollectionPlan()
                xsDataBestStrategySummary = XSDataBestStrategySummary()
                if "Main Wedge" in listLog[indexLine]:
                    indexLine += 2
                    # ResolutionReasoning
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString(listLog[indexLine].strip())
                elif "Strategy for SAD data collection" in listLog[indexLine]:
                    indexLine += 2
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString(listLog[indexLine].strip())
                else:
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString("Low-resolution pass, no overloads and full completeness")
                # Resolution, transmission, distance
                indexLine += 1
                while not "Resolution limit" in listLog[indexLine]:
                    indexLine += 1
                regEx = re.compile(""" Resolution limit =\s*(\d+\.\d+) Angstrom   Transmission =\s*(\d+\.\d+)%  Distance =\s*(\d+\.\d+)mm""")
                matchObj = regEx.search(listLog[indexLine])
                if matchObj == None:
                    raise BaseException("Cannot parse best log file!")
                resultMatch = matchObj.groups()
                resultion = float(resultMatch[0])
                transmission = float(resultMatch[1])
                distance = float(resultMatch[2])
                xsDataBestStrategySummary.resolution = XSDataDouble(resultion)
                xsDataBestStrategySummary.transmission = XSDataDouble(transmission)
                xsDataBestStrategySummary.distance = XSDataLength(distance)
                # Resolution, transmission, distance
                indexLine += 8
                while not listLog[indexLine].startswith("-------------------------------"):
                    listLine = listLog[indexLine].split()
                    xsDataBestCollectionRun = XSDataBestCollectionRun()
                    xsDataBestCollectionRun.collectionRunNumber = XSDataInteger(listLine[0])
                    xsDataBestCollectionRun.phiStart = XSDataAngle(listLine[1])
                    xsDataBestCollectionRun.phiWidth = XSDataAngle(listLine[2])
                    xsDataBestCollectionRun.exposureTime = XSDataTime(listLine[3])
                    xsDataBestCollectionRun.numberOfImages = XSDataInteger(listLine[4].split("|")[0])
                    xsDataBestCollectionRun.overlaps = XSDataString(listLine[5])
                    xsDataBestCollectionPlan.addCollectionRun(xsDataBestCollectionRun)
                    indexLine += 1
                #
                xsDataBestStrategySummary.completeness = XSDataDouble(listLine[11])
                #
                while not "Redundancy" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.redundancy = XSDataDouble(listLog[indexLine].split()[-1])
                #
                while not "I/Sigma (outer shell)" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.iSigma = XSDataDouble(listLog[indexLine].split()[6].replace(")", ""))
                #
                while not "Total Exposure time" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.totalExposureTime = XSDataTime(listLog[indexLine].split()[4])
                #
                while not "Total Data Collection time" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.totalDataCollectionTime = XSDataTime(listLog[indexLine].split()[5])
                #
                while not "Wedge Data Collection Statistics according to the Strategy" in listLog[indexLine]:
                    indexLine += 1
                (xsDataBestStatisticalPrediction, indexLine) = self.getXSDataBestStatisticalPrediction(listLog, indexLine)

                xsDataBestCollectionPlan.strategySummary = xsDataBestStrategySummary
                xsDataBestCollectionPlan.statisticalPrediction = xsDataBestStatisticalPrediction
                xsDataBestCollectionPlan.collectionPlanNumber = XSDataInteger(iCollectionPlanNumber)
                iCollectionPlanNumber += 1
                xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            if "Additional information" in listLog[indexLine]:
                #
                while not "Relative scale" in listLog[indexLine]:
                    indexLine += 1
                scale = float(listLog[indexLine].split()[-1])
                #
                while not "Overall B-factor" in listLog[indexLine]:
                    indexLine += 1
                #
                bFactor = float(listLog[indexLine].split()[-2])
                while not "Estimated limit of resolution" in listLog[indexLine]:
                    indexLine += 1
                rankingResolution = float(listLog[indexLine].split()[5])
                for collectionPlan in xsDataResultBest.collectionPlan:
                    xsDataCrystalScale = XSDataCrystalScale()
                    xsDataCrystalScale.scale = XSDataDouble(scale)
                    xsDataCrystalScale.bFactor = XSDataDouble(bFactor)
                    collectionPlan.crystalScale = xsDataCrystalScale
                    collectionPlan.strategySummary.rankingResolution = XSDataDouble(rankingResolution)
            indexLine += 1
        return xsDataResultBest
Пример #11
0
    def getDataCollectionOutputDataFromLog(self, _strBestLog):
        xsDataResultBest = XSDataResultBest()
        # loop through the lines of the log file
        isScanningWedge = False
        indexLine = 0
        listLog = _strBestLog.split("\n")
        iCollectionPlanNumber = 1
        while indexLine < len(listLog):
            if "Plan of data collection for radiation damage characterisation" in listLog[
                    indexLine]:
                xsDataBestCollectionPlan = XSDataBestCollectionPlan()
                xsDataBestStrategySummary = XSDataBestStrategySummary()
                indexLine += 2
                regEx = re.compile(
                    """ Resolution limit =\s*(\d+\.\d+) Angstrom\s*Distance =\s*(\d+\.\d+)mm"""
                )
                matchObj = regEx.search(listLog[indexLine])
                if matchObj == None:
                    raise BaseException("Cannot parse best log file!")
                resultMatch = matchObj.groups()
                resultion = float(resultMatch[0])
                distance = float(resultMatch[1])
                xsDataBestStrategySummary.resolution = XSDataDouble(resultion)
                xsDataBestStrategySummary.distance = XSDataLength(distance)
                xsDataBestCollectionPlan.strategySummary = xsDataBestStrategySummary
                # Burn strategy
                indexLine += 7
                collectionRunNumber = 1
                while not listLog[indexLine].startswith(
                        "-------------------------------"):
                    listLine = listLog[indexLine].split()
                    if listLine[0].startswith(
                            "exposure") or listLine[0].startswith("burn"):
                        xsDataBestCollectionRun = XSDataBestCollectionRun()
                        xsDataBestCollectionRun.collectionRunNumber = XSDataInteger(
                            collectionRunNumber)
                        xsDataBestCollectionRun.action = XSDataString(
                            listLine[0])
                        xsDataBestCollectionRun.phiStart = XSDataAngle(
                            listLine[1])
                        xsDataBestCollectionRun.phiWidth = XSDataAngle(
                            listLine[2])
                        xsDataBestCollectionRun.exposureTime = XSDataTime(
                            listLine[3])
                        xsDataBestCollectionRun.numberOfImages = XSDataInteger(
                            listLine[4].split("|")[0])
                        xsDataBestCollectionRun.transmission = XSDataDouble(
                            listLine[5])
                        xsDataBestCollectionPlan.addCollectionRun(
                            xsDataBestCollectionRun)
                        collectionRunNumber += 1
                    indexLine += 1
                xsDataBestCollectionPlan.collectionPlanNumber = XSDataInteger(
                    iCollectionPlanNumber)
                xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            if "Main Wedge" in listLog[indexLine] or "Low resolution Wedge" in listLog[indexLine] \
                or "Strategy for SAD data collection" in listLog[indexLine]:
                isScanningWedge = True
                xsDataBestCollectionPlan = XSDataBestCollectionPlan()
                xsDataBestStrategySummary = XSDataBestStrategySummary()
                if "Main Wedge" in listLog[indexLine]:
                    indexLine += 2
                    # ResolutionReasoning
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString(
                        listLog[indexLine].strip())
                elif "Strategy for SAD data collection" in listLog[indexLine]:
                    indexLine += 2
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString(
                        listLog[indexLine].strip())
                else:
                    xsDataBestStrategySummary.resolutionReasoning = XSDataString(
                        "Low-resolution pass, no overloads and full completeness"
                    )
                # Resolution, transmission, distance
                indexLine += 1
                while not "Resolution limit" in listLog[indexLine]:
                    indexLine += 1
                regEx = re.compile(
                    """ Resolution limit =\s*(\d+\.\d+) Angstrom   Transmission =\s*(\d+\.\d+)%  Distance =\s*(\d+\.\d+)mm"""
                )
                matchObj = regEx.search(listLog[indexLine])
                if matchObj == None:
                    raise BaseException("Cannot parse best log file!")
                resultMatch = matchObj.groups()
                resultion = float(resultMatch[0])
                transmission = float(resultMatch[1])
                distance = float(resultMatch[2])
                xsDataBestStrategySummary.resolution = XSDataDouble(resultion)
                xsDataBestStrategySummary.transmission = XSDataDouble(
                    transmission)
                xsDataBestStrategySummary.distance = XSDataLength(distance)
                # Resolution, transmission, distance
                indexLine += 8
                while not listLog[indexLine].startswith(
                        "-------------------------------"):
                    listLine = listLog[indexLine].split()
                    xsDataBestCollectionRun = XSDataBestCollectionRun()
                    xsDataBestCollectionRun.collectionRunNumber = XSDataInteger(
                        listLine[0])
                    xsDataBestCollectionRun.phiStart = XSDataAngle(listLine[1])
                    xsDataBestCollectionRun.phiWidth = XSDataAngle(listLine[2])
                    xsDataBestCollectionRun.exposureTime = XSDataTime(
                        listLine[3])
                    xsDataBestCollectionRun.numberOfImages = XSDataInteger(
                        listLine[4].split("|")[0])
                    xsDataBestCollectionRun.overlaps = XSDataString(
                        listLine[5])
                    xsDataBestCollectionPlan.addCollectionRun(
                        xsDataBestCollectionRun)
                    indexLine += 1
                #
                xsDataBestStrategySummary.completeness = XSDataDouble(
                    listLine[11])
                #
                while not "Redundancy" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.redundancy = XSDataDouble(
                    listLog[indexLine].split()[-1])
                #
                while not "I/Sigma (outer shell)" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.iSigma = XSDataDouble(
                    listLog[indexLine].split()[6].replace(")", ""))
                #
                while not "Total Exposure time" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.totalExposureTime = XSDataTime(
                    listLog[indexLine].split()[4])
                #
                while not "Total Data Collection time" in listLog[indexLine]:
                    indexLine += 1
                xsDataBestStrategySummary.totalDataCollectionTime = XSDataTime(
                    listLog[indexLine].split()[5])
                #
                while not "Wedge Data Collection Statistics according to the Strategy" in listLog[
                        indexLine]:
                    indexLine += 1
                (xsDataBestStatisticalPrediction,
                 indexLine) = self.getXSDataBestStatisticalPrediction(
                     listLog, indexLine)

                xsDataBestCollectionPlan.strategySummary = xsDataBestStrategySummary
                xsDataBestCollectionPlan.statisticalPrediction = xsDataBestStatisticalPrediction
                xsDataBestCollectionPlan.collectionPlanNumber = XSDataInteger(
                    iCollectionPlanNumber)
                iCollectionPlanNumber += 1
                xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            if "Additional information" in listLog[indexLine]:
                #
                while not "Relative scale" in listLog[indexLine]:
                    indexLine += 1
                scale = float(listLog[indexLine].split()[-1])
                #
                while not "Overall B-factor" in listLog[indexLine]:
                    indexLine += 1
                #
                bFactor = float(listLog[indexLine].split()[-2])
                while not "Estimated limit of resolution" in listLog[indexLine]:
                    indexLine += 1
                rankingResolution = float(listLog[indexLine].split()[5])
                for collectionPlan in xsDataResultBest.collectionPlan:
                    xsDataCrystalScale = XSDataCrystalScale()
                    xsDataCrystalScale.scale = XSDataDouble(scale)
                    xsDataCrystalScale.bFactor = XSDataDouble(bFactor)
                    collectionPlan.crystalScale = xsDataCrystalScale
                    collectionPlan.strategySummary.rankingResolution = XSDataDouble(
                        rankingResolution)
            indexLine += 1
        return xsDataResultBest