def testParsePseudotranslationLogFile(self): edPluginPhenixXtriagev1_1 = self.createPlugin() logFilePseudotranslation = os.path.join(self.getPluginTestsDataHome(), "PhenixXtriage_pseudotranslation.log") xsDataResultPhenixXtriage = edPluginPhenixXtriagev1_1.parseLogFile(logFilePseudotranslation) # Check log file EDAssert.equal(True, os.path.exists(xsDataResultPhenixXtriage.logFile.path.value), "Log file") # Reference data xmlFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultPhenixXtriage_pseudotranslation.xml") xml = self.readAndParseFile(xmlFile) xsDataResultPhenixXtriageReference = XSDataResultPhenixXtriage.parseString(xml) # Remove the paths to the log file before comparison xsDataResultPhenixXtriage.logFile = None xsDataResultPhenixXtriageReference.logFile = None EDAssert.equal(xsDataResultPhenixXtriageReference.marshal(), xsDataResultPhenixXtriage.marshal(), "Output values")
def testParseLogFile(self): edPluginPhenixXtriagev1_1 = self.createPlugin() logFile = os.path.join( self.getPluginTestsDataHome(), "PhenixXtriage_noTwinning_noPseudotranslation.log") xsDataResultPhenixXtriage = edPluginPhenixXtriagev1_1.parseLogFile( logFile) # Check log file EDAssert.equal( True, os.path.exists(xsDataResultPhenixXtriage.logFile.path.value), "Log file") # Reference data xmlFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultPhenixXtriage_reference.xml") xml = self.readAndParseFile(xmlFile) xsDataResultPhenixXtriageReference = XSDataResultPhenixXtriage.parseString( xml) # Remove the paths to the log file before comparison xsDataResultPhenixXtriage.logFile = None xsDataResultPhenixXtriageReference.logFile = None EDAssert.equal(xsDataResultPhenixXtriageReference.marshal(), xsDataResultPhenixXtriage.marshal(), "Output values")
def __init__(self): EDPluginExecProcessScript.__init__(self) self.setXSDataInputClass(XSDataInputPhenixXtriage) self.setDataOutput(XSDataResultPhenixXtriage()) self.strPathToLocalMtz = None
def parseLogFile(self, _strPathToLogFile): xsDataResultPhenixXtriage = XSDataResultPhenixXtriage() hasTwinning = False hasPseudotranslation = False if os.path.exists(_strPathToLogFile): xsDataResultPhenixXtriage.logFile = XSDataFile(XSDataString(_strPathToLogFile)) strLog = EDUtilsFile.readFile(_strPathToLogFile) iIndex = 0 listLines = strLog.split("\n") bContinue = True while bContinue: if listLines[iIndex].startswith("Statistics depending on twin laws"): #------------------------------------------------------ #| Operator | type | R obs. | Britton alpha | H alpha | #------------------------------------------------------ #| k,h,-l | PM | 0.025 | 0.458 | 0.478 | #| -h,k,-l | PM | 0.017 | 0.459 | 0.487 | #------------------------------------------------------ iIndex +=4 while not listLines[iIndex].startswith("---------"): listLine = listLines[iIndex].split("|") xsDataTwinLawsStatistics =XSDataTwinLawsStatistics() xsDataTwinLawsStatistics.operator = XSDataString(listLine[1].replace(" ", "")) xsDataTwinLawsStatistics.twinType = XSDataString(listLine[2].replace(" ", "")) xsDataTwinLawsStatistics.rObs = XSDataDouble(float(listLine[3])) xsDataTwinLawsStatistics.brittonAlpha = XSDataDouble(float(listLine[4])) xsDataTwinLawsStatistics.hAlpha = XSDataDouble(float(listLine[5])) xsDataTwinLawsStatistics.mlAlpha = XSDataDouble(float(listLine[6])) xsDataResultPhenixXtriage.addTwinLawStatistics(xsDataTwinLawsStatistics) iIndex += 1 elif listLines[iIndex].startswith("Patterson analyses"): # - Largest peak height : 6.089 iIndex += 1 pattersonLargestPeakHeight = float(listLines[iIndex].split(":")[1]) xsDataResultPhenixXtriage.pattersonLargestPeakHeight = XSDataDouble(pattersonLargestPeakHeight) # (corresponding p value : 6.921e-01) iIndex += 1 pattersonPValue = float(listLines[iIndex].split(":")[1].split(")")[0]) xsDataResultPhenixXtriage.pattersonPValue = XSDataDouble(pattersonPValue) elif "indicating pseudo translational symmetry" in listLines[iIndex]: # The analyses of the Patterson function reveals a significant off-origin # peak that is 66.43 % of the origin peak, indicating pseudo translational symmetry. # The chance of finding a peak of this or larger height by random in a # structure without pseudo translational symmetry is equal to the 6.0553e-06. # The detected translational NCS is most likely also responsible for the elevated intensity ratio. # See the relevant section of the logfile for more details. hasPseudotranslation = True elif "As there are twin laws possible given the crystal symmetry, twinning could" in listLines[iIndex]: # The results of the L-test indicate that the intensity statistics # are significantly different than is expected from good to reasonable, # untwinned data. # As there are twin laws possible given the crystal symmetry, twinning could # be the reason for the departure of the intensity statistics from normality. hasTwinning = True iIndex += 1 if iIndex == len(listLines): bContinue = False xsDataResultPhenixXtriage.twinning = XSDataBoolean(hasTwinning) xsDataResultPhenixXtriage.pseudotranslation = XSDataBoolean(hasPseudotranslation) return xsDataResultPhenixXtriage