def parseLogFile(self, _strLogFilePath): xsDataResultXOalign = XSDataResultXOalign() if os.path.exists(_strLogFilePath): strLogText = EDUtilsFile.readFile(_strLogFilePath) listLog = strLogText.split("\n") iIndex = 0 bContinue = True while bContinue: if "Independent Solutions" in listLog[iIndex]: iIndex += 3 while listLog[iIndex] != "" and iIndex < len(listLog): xsDataXOalignSolution = XSDataXOalignSolution() # Remove multiple white spaces strTmp = " ".join(listLog[iIndex].split()) # Split the string at white spaces listSettings = strTmp.split(" ") fKappa = float(listSettings[1]) if fKappa >= self.fMinKappaAngle and fKappa <= self.fMaxKappaAngle: xsDataXOalignSolution.kappa = XSDataDouble(fKappa) fPhi = float(listSettings[2]) # Offset phi with omega value fNewPhi = (fPhi-self.fOmega) % 360 xsDataXOalignSolution.phi = XSDataDouble(fNewPhi) strSettings = "".join(listSettings[3:]) xsDataXOalignSolution.settings = XSDataString(strSettings) xsDataResultXOalign.addSolution(xsDataXOalignSolution) iIndex += 1 iIndex += 1 if iIndex >= len(listLog): bContinue = False return xsDataResultXOalign
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'detector_name': obj_ = XSDataString() obj_.build(child_) self.setDetector_name(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'image_format': obj_ = XSDataString() obj_.build(child_) self.setImage_format(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'nx': obj_ = XSDataInteger() obj_.build(child_) self.setNx(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'ny': obj_ = XSDataInteger() obj_.build(child_) self.setNy(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'qx': obj_ = XSDataDouble() obj_.build(child_) self.setQx(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'qy': obj_ = XSDataDouble() obj_.build(child_) self.setQy(obj_) XSData.buildChildren(self, child_, nodeName_)
def create_processing_input_file(self, processing_input_filename): """Creates dozor input file base on data collection parameters :param processing_input_filename :type : str """ input_file = XSDataInputControlDozor() input_file.setTemplate(XSDataString(self.params_dict["template"])) input_file.setFirst_image_number( XSDataInteger(self.params_dict["first_image_num"])) input_file.setLast_image_number( XSDataInteger(self.params_dict["images_num"])) input_file.setFirst_run_number( XSDataInteger(self.params_dict["run_number"])) input_file.setLast_run_number( XSDataInteger(self.params_dict["run_number"])) input_file.setLine_number_of( XSDataInteger(self.params_dict["lines_num"])) input_file.setReversing_rotation( XSDataBoolean(self.params_dict["reversing_rotation"])) input_file.setPixelMin( XSDataInteger(self.detector_hwobj.get_pixel_min())) input_file.setPixelMax( XSDataInteger(self.detector_hwobj.get_pixel_max())) input_file.setBeamstopSize(XSDataDouble( self.beamstop_hwobj.get_size())) input_file.setBeamstopDistance( XSDataDouble(self.beamstop_hwobj.get_distance())) input_file.setBeamstopDirection( XSDataString(self.beamstop_hwobj.get_direction())) input_file.exportToFile(processing_input_filename)
def parseDistributionData(self, idx_start, idx_stop, dataLines, tmpR, tmpPr, tmpErr): for idx in range(idx_start, idx_stop): dataLine = dataLines[idx].split() tmpR.append(XSDataDouble(float(dataLine[0]))) tmpPr.append(XSDataDouble(float(dataLine[1]))) tmpErr.append(XSDataDouble(float(dataLine[2])))
def generateXSDataStatisticsIntegrationAverageAndNumberOfReflections( _xsDataMOSFLMIntegrationStatistics): xsDataStatisticsIntegrationAverageAndNumberOfReflections = None if (_xsDataMOSFLMIntegrationStatistics is not None): xsDataStatisticsIntegrationAverageAndNumberOfReflections = XSDataStatisticsIntegrationAverageAndNumberOfReflections( ) if (_xsDataMOSFLMIntegrationStatistics.getAverageIntensity() is not None): xsDataStatisticsIntegrationAverageAndNumberOfReflections.setAverageIntensity( XSDataDouble(_xsDataMOSFLMIntegrationStatistics. getAverageIntensity().getValue())) if (_xsDataMOSFLMIntegrationStatistics.getAverageIOverSigma() is not None): xsDataStatisticsIntegrationAverageAndNumberOfReflections.setAverageIOverSigma( XSDataDouble(_xsDataMOSFLMIntegrationStatistics. getAverageIOverSigma().getValue())) if (_xsDataMOSFLMIntegrationStatistics.getAverageSigma() is not None): xsDataStatisticsIntegrationAverageAndNumberOfReflections.setAverageSigma( XSDataDouble(_xsDataMOSFLMIntegrationStatistics. getAverageSigma().getValue())) if (_xsDataMOSFLMIntegrationStatistics.getNumberOfReflections() is not None): xsDataStatisticsIntegrationAverageAndNumberOfReflections.setNumberOfReflections( XSDataInteger(_xsDataMOSFLMIntegrationStatistics. getNumberOfReflections().getValue())) return xsDataStatisticsIntegrationAverageAndNumberOfReflections
def testCheckParameters(self): xsDataInput = XSDataInputGnom() edPluginExecGnom = self.createPlugin() xsDataInput.rMax = XSDataDouble() xsDataInput.experimentalDataQ = [XSDataDouble()] xsDataInput.experimentalDataValues = [XSDataDouble()] edPluginExecGnom.setDataInput(xsDataInput) edPluginExecGnom.checkParameters()
def testCreateEnergyCalibrationArray(self): xsDataEnergyCalibration = XSDataEnergyCalibration() xsDataEnergyCalibration.a = XSDataDouble(1.0e0) xsDataEnergyCalibration.b = XSDataDouble(1.0e-1) xsDataEnergyCalibration.c = XSDataDouble(1.0e-2) xsDataEnergyCalibration.d = XSDataDouble(1.0e-3) edPluginExecReadDataID24 = self.createPlugin() numpyArray = edPluginExecReadDataID24.createEnergyCalibrationArray(100, xsDataEnergyCalibration)
def preProcess(self, _edObject=None): """ The pre-process of ED Plugin Control DiffractionCT Powder Integration consists in preparing the input data for SPD Cake. and declares the execution plugin as EDPluginFit2DCacke """ EDPluginControl.preProcess(self) EDVerbose.DEBUG("EDPluginControlDCTPowderIntegrationv1_1.preProcess") # Load the execution plugin self.m_edPluginPowderIntegration = self.loadPlugin(self.m_edStringControlledPluginName) #Retrive its'datamodel xsDataInputSPDCake = XSDataInputSPDCake() instrumentParameters = self.getDataInput().getInstrumentParameters() imageParameters = self.getDataInput().getImageParameters() xsDataInputSPDCake.setInputFile(self.getDataInput().getImageFile()) xsDataInputSPDCake.setWavelength(instrumentParameters.get_diffrn_radiation_wavelength()) xsDataInputSPDCake.setSampleToDetectorDistance(instrumentParameters.get_pd_instr_dist_spec_detc()) xsDataInputSPDCake.setAngleOfTilt(imageParameters.get_pd_instr_special_details_tilt_angle()) xsDataInputSPDCake.setTiltRotation(imageParameters.get_pd_instr_special_details_tilt_rotation()) xsDataInputSPDCake.setDarkCurrentImageFile(imageParameters.get_file_correction_image_dark_current()) xsDataInputSPDCake.setFlatFieldImageFile(imageParameters.get_file_correction_image_flat_field()) xsDataInputSPDCake.setSpatialDistortionFile(imageParameters.get_file_correction_spline_spatial_distortion()) # EDVerbose.screen("imageParameters.get_array_element_size_1: %s" % imageParameters.get_array_element_size_1().marshal()) xsDataInputSPDCake.setBeamCentreInPixelsX(XSDataDouble(\ EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_1()) / \ EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_1()))) xsDataInputSPDCake.setBeamCentreInPixelsY(XSDataDouble(\ EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_2()) / \ EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_2()))) xsDataInputSPDCake.setPixelSizeX(imageParameters.get_array_element_size_1()) #imageParameters.get_diffrn_detector_element_center_1()) xsDataInputSPDCake.setPixelSizeY(imageParameters.get_array_element_size_2()) #imageParameters.get_diffrn_detector_element_center_1()) xsDataInputSPDCake.setBufferSizeX(XSDataInteger(2048)) xsDataInputSPDCake.setBufferSizeY(XSDataInteger(2048)) xsDataInputSPDCake.setStartAzimuth(XSDataAngle(0)) xsDataInputSPDCake.setStopAzimuth(XSDataAngle(360)) xsDataInputSPDCake.setStepAzimuth(XSDataAngle(360)) xsDataInputSPDCake.setOutputDirCake(self.getDataInput().getDestinationDir()) xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(True)) try: self.m_edPluginPowderIntegration.setDataInput(xsDataInputSPDCake) except Exception, error: # This exception handling needs to be rethought, see bug #43. errorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginControlDCTPowderIntegrationv1_1.preProcess: Unexpected error in SPD handler: ", error) EDVerbose.error(errorMessage) self.addErrorMessage(errorMessage) raise RuntimeError, errorMessage
def populateXSDataInputSPDCake(dictID11): xsDataInputSPDCake = XSDataInputSPDCake() # Angle of tilt xsDataInputSPDCake.setAngleOfTilt( XSDataAngle(float(dictID11["ANGLE OF TILT"]))) # Dark current if dictID11["DARK CURRENT"] == "YES": xsDataInputSPDCake.setDarkCurrentImageFile( XSDataFile(XSDataString(dictID11["DC FILE"]))) #xsDataFile = XSDataFile() #xsDataFile.setPath(XSDataString(dictID11["DC FILE "])) #xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile) if dictID11["FLAT-FIELD"] == "YES": xsDataInputSPDCake.setFlatFieldImageFile( XSDataFile(XSDataString(dictID11["FF FILE"]))) if dictID11["FF SCALE"] == "NO": xsDataInputSPDCake.setFlatFieldImageFile( XSDataFile(XSDataString(dictID11["FF MULTIPLIER"]))) if dictID11["SPATIAL DIS."] == "YES": xsDataInputSPDCake.setSpatialDistortionFile( XSDataFile(XSDataString(dictID11["SD FILE"]))) xsDataInputSPDCake.setStartAzimuth( XSDataAngle(float(dictID11["START AZIMUTH"]))) xsDataInputSPDCake.setStopAzimuth( XSDataAngle(float(dictID11["END AZIMUTH"]))) xsDataInputSPDCake.setInnerRadius( XSDataDouble(float(dictID11["INNER RADIUS"]))) xsDataInputSPDCake.setOuterRadius( XSDataDouble(float(dictID11["OUTER RADIUS"]))) xsDataInputSPDCake.setBufferSizeX( XSDataInteger(int(dictID11["X-PIXEL SIZE"]))) xsDataInputSPDCake.setBufferSizeY( XSDataInteger(int(dictID11["Y-PIXEL SIZE"]))) xsDataInputSPDCake.setSampleToDetectorDistance( XSDataLength(float(dictID11["DISTANCE"]))) xsDataInputSPDCake.setWavelength( XSDataLength(float(dictID11["WAVELENGTH"]))) xsDataInputSPDCake.setBeamCentreInPixelsX( XSDataDouble(float(dictID11["X-BEAM CENTRE"]))) xsDataInputSPDCake.setBeamCentreInPixelsY( XSDataDouble(float(dictID11["Y-BEAM CENTRE"]))) xsDataInputSPDCake.setTiltRotation( XSDataAngle(float(dictID11["TILT ROTATION"]))) xsDataInputSPDCake.setOutputFileType( XSDataFile(XSDataString(dictID11["saving_format"]))) xsDataInputSPDCake.setOutputFileType( XSDataFile(XSDataString(dictID11["output_dir"]))) # TODO : some parameters remain not inserted in this file because not in the datamodel print xsDataInputSPDCake.marshal()
def parseDamselLog(self): damselLog = open(os.path.join(self.getWorkingDirectory(), "damsel.log")) for line in damselLog: wordsLine = [tmpStr for tmpStr in line.split(' ') if tmpStr is not ''] if wordsLine[:4] == ['Mean', 'value', 'of', 'NSD']: self.__xsDataResult.setMeanNSD(XSDataDouble(float(wordsLine[-1]))) if wordsLine[:3] == ['Variation', 'of', 'NSD']: self.__xsDataResult.setVariationNSD(XSDataDouble(float(wordsLine[-1])))
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bestXmlFile': obj_ = XSDataFile() obj_.build(child_) self.setBestXmlFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'xdsHklFile': obj_ = XSDataFile() obj_.build(child_) self.xdsHklFile.append(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'dmin': obj_ = XSDataDouble() obj_.build(child_) self.setDmin(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'defaultBeta': obj_ = XSDataDouble() obj_.build(child_) self.setDefaultBeta(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'defaultGama': obj_ = XSDataDouble() obj_.build(child_) self.setDefaultGama(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bFactorMtvplotFile': obj_ = XSDataFile() obj_.build(child_) self.setBFactorMtvplotFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bFactorGlePlotFile': obj_ = XSDataFile() obj_.build(child_) self.setBFactorGlePlotFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bScaleIntensityMtvPlotFile': obj_ = XSDataFile() obj_.build(child_) self.setBScaleIntensityMtvPlotFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bScaleIntensityGleFile': obj_ = XSDataFile() obj_.build(child_) self.setBScaleIntensityGleFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'resultsFile': obj_ = XSDataFile() obj_.build(child_) self.setResultsFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'resultsXmlFile': obj_ = XSDataFile() obj_.build(child_) self.setResultsXmlFile(obj_) XSDataInput.buildChildren(self, child_, nodeName_)
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
def postProcess(self, _edObject=None): EDPluginExecProcessScript.postProcess(self) self.DEBUG("EDPluginExecDamminv0_2.postProcess") # Create some output data cwd = self.getWorkingDirectory() model = XSDataSaxsModel(name=XSDataString("dammin")) xsDataResult = XSDataResultDammin(model=model) pathLogFile = os.path.join(cwd, "dammin.log") pathFitFile = os.path.join(cwd, "dammin.fit") pathFirFile = os.path.join(cwd, "dammin.fir") pathMoleculeFile = os.path.join(cwd, "dammin-1.pdb") pathSolventFile = os.path.join(cwd, "dammin-0.pdb") try: res = parse_atsas.parsePDB(pathMoleculeFile, pathMoleculeFile) except Exception as error: self.ERROR("EDPluginExecDamminv0_2:parsePDB: %s" % error) else: for k in res: self.__setattr__(k, res[k]) if os.path.exists(pathLogFile): xsDataResult.logFile = model.logFile = XSDataFile( XSDataString(pathLogFile)) if not self.Rfactor: self.Rfactor = self.returnDamminRFactor() if self.Rfactor: xsDataResult.rfactor = model.rfactor = XSDataDouble( self.Rfactor) if os.path.exists(pathFitFile): xsDataResult.fitFile = model.fitFile = XSDataFile( XSDataString(pathFitFile)) if os.path.exists(pathFirFile): model.firFile = XSDataFile(XSDataString(pathFirFile)) xsDataResult.chiSqrt = model.chiSqrt = self.returnDamminChiSqrt() if os.path.exists(pathMoleculeFile): xsDataResult.pdbMoleculeFile = model.pdbFile = XSDataFile( XSDataString(pathMoleculeFile)) if os.path.exists(pathSolventFile): xsDataResult.pdbSolventFile = XSDataFile( XSDataString(pathSolventFile)) if self.volume: model.volume = XSDataDouble(self.volume) if self.Rg: model.rg = XSDataDouble(self.Rg) if self.Dmax: model.dmax = XSDataDouble(self.Dmax) self.generateExecutiveSummary() xsDataResult.status = XSDataStatus( message=self.getXSDataMessage(), executiveSummary=XSDataString( os.linesep.join(self.getListExecutiveSummaryLines()))) self.dataOutput = xsDataResult
def readJesfResults(self): xsDataResultJesf = XSDataResultJesf() strWorkDir = self.getWorkingDirectory() # Read log file strLog = self.readProcessLogFile() listLogLines = strLog.split("\n") for strLogLine in listLogLines: if strLogLine.startswith(" MATRICE SINGOLARE!!!!!"): strErrorMessage = "Jesf reports singular matrix!" self.error(strErrorMessage) self.addErrorMessage(strErrorMessage) self.setFailure() break if strLogLine.startswith(" EDGE="): fEdge = float(strLogLine.split("=")[1]) xsDataResultJesf.edge = XSDataDouble(fEdge) elif strLogLine.startswith(" SLOPE="): fSlope = float(strLogLine.split("=")[1]) xsDataResultJesf.slope = XSDataDouble(fSlope) elif strLogLine.startswith(" JUMP="): fJump = float(strLogLine.split("=")[1]) xsDataResultJesf.jump = XSDataDouble(fJump) elif strLogLine.startswith(" EWL="): fEWL = float(strLogLine.split("=")[1]) xsDataResultJesf.ewl = XSDataDouble(fEWL) elif strLogLine.startswith(" hwl="): fHwl = float(strLogLine.split("=")[1]) xsDataResultJesf.hwl = XSDataDouble(fHwl) if not self.isFailure(): # Read fort92 numpyFort92 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.92")) xsDataArrayFort92 = EDUtilsArray.arrayToXSData(numpyFort92) xsDataResultJesf.setFort92(xsDataArrayFort92) # Read fort95 numpyFort95 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.95")) xsDataArrayFort95 = EDUtilsArray.arrayToXSData(numpyFort95) xsDataResultJesf.setFort95(xsDataArrayFort95) # Read fort96 numpyFort96 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.96")) xsDataArrayFort96 = EDUtilsArray.arrayToXSData(numpyFort96) xsDataResultJesf.setFort96(xsDataArrayFort96) # Read fort97 numpyFort97 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.97")) xsDataArrayFort97 = EDUtilsArray.arrayToXSData(numpyFort97) xsDataResultJesf.setFort97(xsDataArrayFort97) # Read fort98 numpyFort98 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.98")) xsDataArrayFort98 = EDUtilsArray.arrayToXSData(numpyFort98) xsDataResultJesf.setFort98(xsDataArrayFort98) # Read fort99 numpyFort99 = numpy.genfromtxt(os.path.join(strWorkDir, "fort.99")) xsDataArrayFort99 = EDUtilsArray.arrayToXSData(numpyFort99) xsDataResultJesf.setFort99(xsDataArrayFort99) return xsDataResultJesf
def getDefaultChemicalComposition(self, _xsDataSample, _inumOperators): """ """ xsDataCell = _xsDataSample.getCrystal().getCell() a = xsDataCell.getLength_a().getValue() b = xsDataCell.getLength_b().getValue() c = xsDataCell.getLength_c().getValue() alpha = math.radians(xsDataCell.getAngle_alpha().getValue()) beta = math.radians(xsDataCell.getAngle_beta().getValue()) gamma = math.radians(xsDataCell.getAngle_gamma().getValue()) fUnitCellVolume = a * b * c * ( math.sqrt(1 - math.cos(alpha) * math.cos(alpha) - math.cos(beta) * math.cos(beta) - math.cos(gamma) * math.cos(gamma) + 2 * math.cos(alpha) * math.cos(beta) * math.cos(gamma))) fPolymerVolume = fUnitCellVolume * (1 - self.fAverageCrystalSolventContent) fNumberOfMonomersPerUnitCell = fPolymerVolume / self.fAverageAminoAcidVolume fNumberOfMonomersPerAsymmetricUnit = fNumberOfMonomersPerUnitCell / _inumOperators iNumberOfSulfurAtom = int( round(fNumberOfMonomersPerAsymmetricUnit * self.fAverageSulfurContentPerAminoacid)) xsDataAtom = XSDataAtom() xsDataAtom.setSymbol(XSDataString("S")) xsDataAtom.setNumberOf(XSDataDouble(iNumberOfSulfurAtom)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom) xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfMonomers( XSDataDouble(round(fNumberOfMonomersPerAsymmetricUnit))) xsDataChain.setNumberOfCopies(XSDataDouble(1)) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure = XSDataStructure() xsDataStructure.addChain(xsDataChain) xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(1)) xsDataAtomSolvent = XSDataAtom() xsDataAtomSolvent.setSymbol(XSDataString("S")) xsDataAtomSolvent.setConcentration( XSDataDouble(self.fAverageSulfurConcentration)) xsDataAtomicCompositionSolvent = XSDataAtomicComposition() xsDataAtomicCompositionSolvent.addAtom(xsDataAtomSolvent) xsDataSolvent = XSDataSolvent() xsDataSolvent.setAtoms(xsDataAtomicCompositionSolvent) xsDataChemicalCompositionMM = XSDataChemicalCompositionMM() xsDataChemicalCompositionMM.setSolvent(xsDataSolvent) xsDataChemicalCompositionMM.setStructure(xsDataStructure) return xsDataChemicalCompositionMM
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG( "EDPluginDistlSignalStrengthThinClientv1_1.parseLabelitDistlOutput" ) xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setSpotTotal( XSDataInteger(iSpotTotal)) elif strLine.find("Method-2 Resolution Total") != -1: iInResTotal = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResTotal( XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[-1]) xsDataImageQualityIndicators.setGoodBraggCandidates( XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[-1]) xsDataImageQualityIndicators.setIceRings( XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod1Res( XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMethod2Res( XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[-1]) xsDataImageQualityIndicators.setMaxUnitCell( XSDataDouble(fMaxUnitCell)) elif strLine.find("Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[-2]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks( XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-resolution overloaded spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[-1]) xsDataImageQualityIndicators.setInResolutionOvrlSpots( XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find( "Total integrated signal, pixel-ADC units above local background" ) != -1: fTotalIntegratedSignal = float(strLine.split()[-1]) xsDataImageQualityIndicators.setTotalIntegratedSignal( XSDataDouble(fTotalIntegratedSignal)) return xsDataImageQualityIndicators
def testMergeAtomicComposition(self): from XSDataRaddosev10 import XSDataAtomicComposition from XSDataRaddosev10 import XSDataAtom from XSDataCommon import XSDataDouble from XSDataCommon import XSDataString from XSDataCommon import XSDataInteger xsDataAtomicComposition1 = XSDataAtomicComposition() xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("S")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition1.addAtom(xsDataAtom1) xsDataAtom2 = XSDataAtom() xsDataAtom2.setSymbol(XSDataString("Se")) xsDataAtom2.setNumberOf(XSDataDouble(3)) xsDataAtomicComposition1.addAtom(xsDataAtom2) xsDataAtomicComposition2 = XSDataAtomicComposition() xsDataAtom3 = XSDataAtom() xsDataAtom3.setSymbol(XSDataString("S")) xsDataAtom3.setNumberOf(XSDataDouble(1)) xsDataAtomicComposition2.addAtom(xsDataAtom3) xsDataAtom4 = XSDataAtom() xsDataAtom4.setSymbol(XSDataString("Fe")) xsDataAtom4.setNumberOf(XSDataDouble(5)) xsDataAtomicComposition2.addAtom(xsDataAtom4) from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10 xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10( ).mergeAtomicComposition(xsDataAtomicComposition1, xsDataAtomicComposition2) EDAssert.equal(3, len(xsDataMergedAtomicComposition.getAtom())) for atom in xsDataMergedAtomicComposition.getAtom(): if (atom.getSymbol().getValue() == "S"): EDAssert.equal(5, atom.getNumberOf().getValue()) if (atom.getSymbol().getValue() == "Se"): EDAssert.equal(3, atom.getNumberOf().getValue()) if (atom.getSymbol().getValue() == "Fe"): EDAssert.equal(5, atom.getNumberOf().getValue()) xsDataMergedAtomicComposition = EDHandlerXSDataRaddosev10( ).mergeAtomicComposition(XSDataAtomicComposition(), xsDataAtomicComposition2) EDAssert.equal(2, len(xsDataMergedAtomicComposition.getAtom())) for atom in xsDataMergedAtomicComposition.getAtom(): if (atom.getSymbol().getValue() == "S"): EDAssert.equal(1, atom.getNumberOf().getValue()) if (atom.getSymbol().getValue() == "Fe"): EDAssert.equal(5, atom.getNumberOf().getValue())
def testUpdateChemicalCompositionWithNativeSulfurAtom(self): edPluginStrategy = self.createPlugin() strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(), "XSConfiguration_ESRF.xml") edConfiguration = EDConfiguration(strPathToTestConfigFile) dictItem = edConfiguration.get(edPluginStrategy.getPluginName()) edPluginStrategy.setConfig(dictItem) edPluginStrategy.configure() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition( xsDataComposition) EDAssert.equal( 3, updatedChemicalComposition.getStructure().getChain() [0].getHeavyAtoms().getAtom()[0].getNumberOf().getValue()) EDAssert.equal( "S", updatedChemicalComposition.getStructure().getChain() [0].getHeavyAtoms().getAtom()[0].getSymbol().getValue()) xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataChain.setNumberOfMonomers(XSDataDouble(60)) xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addChain(xsDataChain) xsDataComposition.setStructure(xsDataStructure) updatedChemicalComposition = edPluginStrategy.updateChemicalComposition( xsDataComposition) heavyAtoms = updatedChemicalComposition.getStructure().getChain( )[0].getHeavyAtoms().getAtom() for heavyAtom in heavyAtoms: self.unitTest(heavyAtom.getSymbol().getValue() + " : " + str(heavyAtom.getNumberOf().getValue())) if (heavyAtom.getSymbol().getValue() == "S"): EDAssert.equal(3, heavyAtom.getNumberOf().getValue())
def readGnomDataFile(self, fileName): tmpExperimentalDataQ = [] tmpExperimentalDataValues = [] dataLines = EDUtilsFile.readFile(fileName).splitlines()[1:] for line in dataLines: lineList = line.split() if len(lineList) > 0: tmpExperimentalDataQ.append(XSDataDouble(float(lineList[0]))) tmpExperimentalDataValues.append(XSDataDouble(float(lineList[1]))) dataInput = self.plugin.dataInput dataInput.setExperimentalDataQ(tmpExperimentalDataQ) dataInput.setExperimentalDataValues(tmpExperimentalDataValues) dataInput.exportToFile("XSDataInputGnom_reference_list.xml")
def parseLabelitDistlOutput(self, _strLabelitDistlLogText): self.DEBUG("EDPluginLabelitDistlv1_1.parseLabelitDistlOutput") xsDataImageQualityIndicators = None if _strLabelitDistlLogText is not None: xsDataImageQualityIndicators = XSDataImageQualityIndicators() for strLine in _strLabelitDistlLogText.split("\n"): if strLine.find("Spot Total") != -1: iSpotTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setSpotTotal( XSDataInteger(iSpotTotal)) elif strLine.find("In-Resolution Total") != -1: iInResTotal = int(strLine.split()[3]) xsDataImageQualityIndicators.setInResTotal( XSDataInteger(iInResTotal)) elif strLine.find("Good Bragg Candidates") != -1: iGoodBraggCandidates = int(strLine.split()[4]) xsDataImageQualityIndicators.setGoodBraggCandidates( XSDataInteger(iGoodBraggCandidates)) elif strLine.find("Ice Rings") != -1: iIceRings = int(strLine.split()[3]) xsDataImageQualityIndicators.setIceRings( XSDataInteger(iIceRings)) elif strLine.find("Method 1 Resolution") != -1: fMethod1Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod1Res( XSDataDouble(fMethod1Res)) elif strLine.find("Method 2 Resolution") != -1: if strLine.split()[4] != "None": fMethod2Res = float(strLine.split()[4]) xsDataImageQualityIndicators.setMethod2Res( XSDataDouble(fMethod2Res)) elif strLine.find("Maximum unit cell") != -1: if strLine.split()[4] != "None": fMaxUnitCell = float(strLine.split()[4]) xsDataImageQualityIndicators.setMaxUnitCell( XSDataDouble(fMaxUnitCell)) elif strLine.find("%Saturation, Top 50 Peaks") != -1: fPctSaturationTop50Peaks = float(strLine.split()[5]) xsDataImageQualityIndicators.setPctSaturationTop50Peaks( XSDataDouble(fPctSaturationTop50Peaks)) elif strLine.find("In-Resolution Ovrld Spots") != -1: iInResolutionOvrlSpots = int(strLine.split()[4]) xsDataImageQualityIndicators.setInResolutionOvrlSpots( XSDataInteger(iInResolutionOvrlSpots)) elif strLine.find( "Bin population cutoff for method 2 resolution") != -1: fBinPopCutOffMethod2Res = float(strLine.split()[7][:-1]) xsDataImageQualityIndicators.setBinPopCutOffMethod2Res( XSDataDouble(fBinPopCutOffMethod2Res)) return xsDataImageQualityIndicators
def postProcess(self, _edObject=None): EDPluginExecProcessScript.postProcess(self) self.DEBUG("EDPluginExecSiftOffsetv1_0.postProcess") xsDataResult = XSDataResultMeasureOffsetSift() if os.path.isfile(self.outFile): xsdStr = XSDataString(self.outFile) xsdFile = XSDataFile() xsdFile.setPath(xsdStr) xsDataResult.setPanoFile(xsdFile) dx = [] dy = [] for oneLine in open(self.outFile).readlines(): if oneLine.startswith("c"): x = 0 X = 0 y = 0 Y = 0 for oneWord in oneLine.strip().split(" "): if oneWord.startswith("x"): x = float(oneWord[1:]) elif oneWord.startswith("X"): X = float(oneWord[1:]) elif oneWord.startswith("y"): y = float(oneWord[1:]) elif oneWord.startswith("Y"): Y = float(oneWord[1:]) if x != 0 and y != 0 and X != 0 and Y != 0 and abs( X - x) < 100 and abs(Y - y) < 100: dx.append(X - x) dy.append(Y - y) else: self.DEBUG("%s %s %s %s %s %s %s" % (oneLine, x, y, X, Y, X - x, Y - y)) dx.sort() dy.sort() subDx = dx[int(round(0.1 * len(dx))):int(round(0.9 * len(dx)))] subDy = dy[int(round(0.1 * len(dy))):int(round(0.9 * len(dy)))] sum1 = 0.0 sum2 = 0.0 for i in subDx: sum1 += i for i in subDy: sum2 += i xsDataResult.setOffset([ XSDataDouble(-sum2 / max(1, len(subDy))), XSDataDouble(-sum1 / max(1, len(subDx))) ]) # Create some output data self.setDataOutput(xsDataResult)
def readGnomDataFile(self, fileName): tmpExperimentalDataQ = [] tmpExperimentalDataValues = [] for line in open(fileName): words = line.split() try: q = float(words[0]) I = float(words[1]) except (IndexError, ValueError): continue tmpExperimentalDataQ.append(XSDataDouble(q)) tmpExperimentalDataValues.append(XSDataDouble(I)) self.plugin.dataInput.experimentalDataQ = tmpExperimentalDataQ self.plugin.dataInput.experimentalDataValues = tmpExperimentalDataValues
def testCheckParameters(self): xsDataInput = XSDataInputBioSaxsAveragev1_0() xsDataInput.setIntegratedImageSize(XSDataInteger()) xsDataInput.setIntegratedImage([XSDataImage(), XSDataImage()]) xsDataInput.setAveragedCurve(XSDataFile()) xsDataInput.setNormalizationFactor(XSDataDouble()) xsDataInput.setAveragedImage(XSDataImage()) xsDataInput.setConcentration(XSDataDouble()) xsDataInput.setComments(XSDataString()) xsDataInput.setCode(XSDataString()) xsDataInput.setLogFile(XSDataFile()) edPluginExec = self.createPlugin() edPluginExec.setDataInput(xsDataInput) edPluginExec.checkParameters()
def createTestDataInput(self): xsDataInputRdfit = XSDataInputRdfit() xsDataInputRdfit.setBestXmlFile(XSDataFile(XSDataString("1.xml"))) xsDataInputRdfit.addXdsHklFile(XSDataFile(XSDataString("xds_1.hkl"))) xsDataInputRdfit.addXdsHklFile(XSDataFile(XSDataString("xds_2.hkl"))) xsDataInputRdfit.addXdsHklFile(XSDataFile(XSDataString("xds_3.hkl"))) xsDataInputRdfit.addXdsHklFile(XSDataFile(XSDataString("xds_4.hkl"))) xsDataInputRdfit.setDmin(XSDataDouble(1.0)) xsDataInputRdfit.setDefaultBeta(XSDataDouble(2.0)) xsDataInputRdfit.setDefaultGama(XSDataDouble(3.0)) xsDataInputRdfit.setBFactorMtvplotFile(XSDataFile(XSDataString("2"))) xsDataInputRdfit.setBScaleIntensityMtvPlotFile(XSDataFile(XSDataString("3"))) xsDataInputRdfit.setBScaleIntensityGleFile(XSDataFile(XSDataString("4"))) xsDataInputRdfit.setResultsFile(XSDataFile(XSDataString("5"))) xsDataInputRdfit.setResultsXmlFile(XSDataFile(XSDataString("6"))) return xsDataInputRdfit
def updateChemicalComposition(self, _xsDataChemicalComposition): xsDataChemicalComposition = _xsDataChemicalComposition for chain in xsDataChemicalComposition.getStructure().getChain(): if (chain.getType().getValue() == "protein"): bSulfurExists = False xsDataAtomicCompositionHeavyAtoms = chain.getHeavyAtoms() if (xsDataAtomicCompositionHeavyAtoms is None): xsDataAtomicCompositionHeavyAtoms = XSDataAtomicComposition( ) else: for heavyAtom in xsDataAtomicCompositionHeavyAtoms.getAtom( ): if (heavyAtom.getSymbol().getValue() == "S" or heavyAtom.getSymbol().getValue() == "s"): bSulfurExists = True # all protein chains should contain sulfur atom as a percentage of the number # of amino acids. Add them if the user did not input them. if (bSulfurExists == False): iNumberOfSulfurAtom = int( round(chain.getNumberOfMonomers().getValue() * 0.05)) xsDataSulfurAtom = XSDataAtom() xsDataSulfurAtom.setSymbol(XSDataString("S")) xsDataSulfurAtom.setNumberOf( XSDataDouble(iNumberOfSulfurAtom)) xsDataAtomicCompositionHeavyAtoms.addAtom(xsDataSulfurAtom) chain.setHeavyAtoms(xsDataAtomicCompositionHeavyAtoms) return xsDataChemicalComposition
def parseDouble(self, _strValue): returnValue = None try: returnValue = XSDataDouble(_strValue) except BaseException as ex: self.warning("Error when trying to parse '" + _strValue + "': %r" % ex) return returnValue
def store_processing_results(self, status): GenericParallelProcessing.store_processing_results(self, status) self.display_task.kill() processing_xml_filename = os.path.join(self.params_dict\ ["directory"], "dozor_result.xml") dozor_result = XSDataResultControlDozor() for index in range(self.params_dict["images_num"]): dozor_image = XSDataControlImageDozor() dozor_image.setNumber(XSDataInteger(index)) dozor_image.setScore(XSDataDouble(self.results_raw["score"][index])) dozor_image.setSpots_num_of(XSDataInteger(self.results_raw["spots_num"][index])) dozor_image.setSpots_resolution(XSDataDouble(self.results_raw["spots_resolution"][index])) dozor_result.addImageDozor(dozor_image) dozor_result.exportToFile(processing_xml_filename) logging.getLogger("HWR").info("Parallel processing: Results saved in %s" % processing_xml_filename)
def mergeAtomicComposition(self, _xsDataAtomicComposition1, _xsDataAtomicComposition2): EDFactoryPluginStatic.loadModule("XSDataRaddosev10") mergedAtomicComposition = XSDataAtomicComposition() dictionary = {} for atom in _xsDataAtomicComposition2.getAtom(): dictionary[ atom.getSymbol().getValue()] = atom.getNumberOf().getValue() for atom1 in _xsDataAtomicComposition1.getAtom(): symbol = atom1.getSymbol().getValue() if (self.exists(symbol, _xsDataAtomicComposition2) == True): mergedAtom = XSDataAtom() mergedAtom.setNumberOf( XSDataDouble(atom1.getNumberOf().getValue() + dictionary[symbol])) mergedAtom.setSymbol(XSDataString(symbol)) mergedAtomicComposition.addAtom(mergedAtom) else: mergedAtomicComposition.addAtom(atom1) for atom2 in _xsDataAtomicComposition2.getAtom(): symbol = atom2.getSymbol().getValue() if (self.exists(symbol, _xsDataAtomicComposition1) == False): mergedAtomicComposition.addAtom(atom2) return mergedAtomicComposition
def process(_listInputFile, _output, dummy=0, autoscale=False, center=None, width=None, blending=None, mask=None): """ call EDNA with this options: @param _listInputFile: list of input files as strings @param _output: output file name @param dummy: value for dummy pixels @param autoscale: shall image intensity be scaled (boolean) @param center: 2-list of int representing the center of the ROI @param width: 2-list of int representing the width of the ROI @param blending: blending method: max, mean or min @param mask: name of the file containing the mask """ xsd = XSDataInputStitchImage() xsd.dummyValue = XSDataDouble(dummy) xsd.autoscale = XSDataBoolean(autoscale) if blending: xsd.blending = XSDataString(blending) if mask: xsd.mask = XSDataImage(XSDataString(mask)) xsd.outputImage = XSDataImage(XSDataString(_output)) xsd.inputImages = [XSDataImage(XSDataString(i)) for i in _listInputFile] if isinstance(width, list): xsd.widthROI = [XSDataInteger(i) for i in width] if isinstance(center, list): xsd.centerROI = [XSDataInteger(i) for i in center] job = EDJob(EDNAPluginName) job.setDataInput(xsd) job.execute()
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'identifier': obj_ = XSDataAutoPROCIdentifier() obj_.build(child_) self.identifier.append(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'lowResolutionLimit': obj_ = XSDataDouble() obj_.build(child_) self.setLowResolutionLimit(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'highResolutionLimit': obj_ = XSDataDouble() obj_.build(child_) self.setHighResolutionLimit(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'anomalous': obj_ = XSDataBoolean() obj_.build(child_) self.setAnomalous(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'refMTZ': obj_ = XSDataFile() obj_.build(child_) self.setRefMTZ(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'configDef': obj_ = XSDataFile() obj_.build(child_) self.setConfigDef(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'masterH5': obj_ = XSDataFile() obj_.build(child_) self.setMasterH5(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'symm': obj_ = XSDataString() obj_.build(child_) self.setSymm(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'cell': obj_ = XSDataString() obj_.build(child_) self.setCell(obj_) XSDataInput.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'kappa': obj_ = XSDataDouble() obj_.build(child_) self.setKappa(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'phi': obj_ = XSDataDouble() obj_.build(child_) self.setPhi(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'settings': obj_ = XSDataString() obj_.build(child_) self.setSettings(obj_) XSData.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'concentration': obj_ = XSDataDouble() obj_.build(child_) self.setConcentration(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'numberOf': obj_ = XSDataDouble() obj_.build(child_) self.setNumberOf(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'symbol': obj_ = XSDataString() obj_.build(child_) self.setSymbol(obj_) XSData.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'flux': obj_ = XSDataDouble() obj_.build(child_) self.setFlux(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'resolution': obj_ = XSDataDouble() obj_.build(child_) self.setResolution(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamH': obj_ = XSDataDouble() obj_.build(child_) self.setBeamH(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamV': obj_ = XSDataDouble() obj_.build(child_) self.setBeamV(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'wavelength': obj_ = XSDataDouble() obj_.build(child_) self.setWavelength(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'aperture': obj_ = XSDataDouble() obj_.build(child_) self.setAperture(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'slitX': obj_ = XSDataDouble() obj_.build(child_) self.setSlitX(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'slitY': obj_ = XSDataDouble() obj_.build(child_) self.setSlitY(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rotationRange': obj_ = XSDataDouble() obj_.build(child_) self.setRotationRange(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rotationWidth': obj_ = XSDataDouble() obj_.build(child_) self.setRotationWidth(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'minExposureTime': obj_ = XSDataDouble() obj_.build(child_) self.setMinExposureTime(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'doseLimit': obj_ = XSDataDouble() obj_.build(child_) self.setDoseLimit(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'doseRate': obj_ = XSDataDouble() obj_.build(child_) self.setDoseRate(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'sensitivity': obj_ = XSDataDouble() obj_.build(child_) self.setSensitivity(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalSize': obj_ = XSDataDouble() obj_.build(child_) self.setCrystalSize(obj_) XSDataInput.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beta': obj_ = XSDataDouble() obj_.build(child_) self.setBeta(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'gama': obj_ = XSDataDouble() obj_.build(child_) self.setGama(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'dose_half_th': obj_ = XSDataDouble() obj_.build(child_) self.setDose_half_th(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'dose_half': obj_ = XSDataDouble() obj_.build(child_) self.setDose_half(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'relative_radiation_sensitivity': obj_ = XSDataDouble() obj_.build(child_) self.setRelative_radiation_sensitivity(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def populateXSDataInputSPDCake(self, _inputDict=None): self.DEBUG("EDPluginControlID11v1_0.populateXSDataInputSPDCake") xsDataInputSPDCake = XSDataInputSPDCake() if isinstance(_inputDict, dict): self.__dictID11 = _inputDict # Angle of tilt if "ANGLE OF TILT" in self.__dictID11: xsDataTilt = XSDataAngle() xsDataTilt.setValue(float(self.__dictID11["ANGLE OF TILT"])) xsDataTilt.setUnit(XSDataString("deg")) xsDataInputSPDCake.setAngleOfTilt(xsDataTilt) if "TILT ROTATION" in self.__dictID11: xsDataTiltRot = XSDataAngle() xsDataTiltRot.setValue(float(self.__dictID11["TILT ROTATION"])) xsDataTiltRot.setUnit(XSDataString("deg")) xsDataInputSPDCake.setTiltRotation(xsDataTiltRot) if "X-PIXEL SIZE" in self.__dictID11: xsDataXPixel = XSDataLength() xsDataXPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataXPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeX(xsDataXPixel) if "Y-PIXEL SIZE" in self.__dictID11: xsDataYPixel = XSDataLength() xsDataYPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"])) xsDataYPixel.setUnit(XSDataString("micron")) xsDataInputSPDCake.setPixelSizeY(xsDataYPixel) if "DISTANCE" in self.__dictID11: xsDataDistance = XSDataLength() xsDataDistance.setValue(float(self.__dictID11["DISTANCE"])) xsDataDistance.setUnit(XSDataString("mm")) xsDataInputSPDCake.setSampleToDetectorDistance(xsDataDistance) if "WAVELENGTH" in self.__dictID11: xsDataWaweLength = XSDataWavelength() xsDataWaweLength.setValue(float(self.__dictID11["WAVELENGTH"])) xsDataWaweLength.setUnit(XSDataString("A")) xsDataInputSPDCake.setWavelength(xsDataWaweLength) if "DIM1_DATA" in self.__dictID11: xsDataBufferSizeX = XSDataInteger(int(self.__dictID11["DIM1_DATA"])) xsDataInputSPDCake.setBufferSizeX(xsDataBufferSizeX) if "DIM2_DATA" in self.__dictID11: xsDataBufferSizeY = XSDataInteger(int(self.__dictID11["DIM2_DATA"])) xsDataInputSPDCake.setBufferSizeY(xsDataBufferSizeY) # Dark current if ("DARK CURRENT" in self.__dictID11) and (self.__dictID11["DARK CURRENT"] == "YES") : if ("DC FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["DC FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["DC FILE"])) xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile) else: self.warning("Asked for DC Current correction but no DC current file") if ("FLAT-FIELD" in self.__dictID11) and (self.__dictID11["FLAT-FIELD"] == "YES"): if ("FF FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["FF FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["FF FILE"])) xsDataInputSPDCake.setFlatFieldImageFile(xsDataFile) else: self.warning("Asked for FLAT-FIELD correction but no FLAT-FIELD file") if ("MASK FILE" in self.__dictID11) and (self.__dictID11["USE MASK"] == "YES") : if ("MASK FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["MASK FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["MASK FILE"])) xsDataInputSPDCake.setMaskFile(xsDataFile) else: self.warning("Asked for DC Current correction but no DC current file") if ("FF SCALE" in self.__dictID11) and (self.__dictID11["FF SCALE"] == "YES"): if ("FF MULTIPLIER" in self.__dictID11): try: value = float(self.__dictID11["FF MULTIPLIER"]) except Exception: self.warning("Asked for FF SCALE correction but FF MULTIPLIER provided (%s) in not float !" % (self.__dictID11["FF MULTIPLIER"])) else: xsDataInputSPDCake.setIntensityScaleFactor(XSDataDouble(1 / value)) else: self.warning("Asked for FF SCALE correction but no FF MULTIPLIER provided") if ("SPATIAL DIS." in self.__dictID11) and (self.__dictID11["SPATIAL DIS."] == "YES"): if ("SD FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["SD FILE"]): xsDataFile = XSDataFile() xsDataFile.setPath(XSDataString(self.__dictID11["SD FILE"])) xsDataInputSPDCake.setSpatialDistortionFile(xsDataFile) else : self.warning("Asked for SPATIAL DISTORSION correction but no SPATIAL DISTORSION file") if "START AZIMUTH" in self.__dictID11: xsDataAzimuthStart = XSDataAngle() xsDataAzimuthStart.setValue(float(self.__dictID11["START AZIMUTH"])) xsDataAzimuthStart.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStartAzimuth(xsDataAzimuthStart) if "END AZIMUTH" in self.__dictID11: xsDataAzimuthStop = XSDataAngle() xsDataAzimuthStop.setValue(float(self.__dictID11["END AZIMUTH"])) xsDataAzimuthStop.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStopAzimuth(xsDataAzimuthStop) if "AZIMUTH BINS" in self.__dictID11: xsDataAzimuthStep = XSDataAngle() xsDataAzimuthStep.setValue((float(self.__dictID11["END AZIMUTH"]) - float(self.__dictID11["START AZIMUTH"])) / float(self.__dictID11["AZIMUTH BINS"])) xsDataAzimuthStep.setUnit(XSDataString("deg")) xsDataInputSPDCake.setStepAzimuth(xsDataAzimuthStep) if "INNER RADIUS" in self.__dictID11: xsDataInnerRadius = XSDataDouble() xsDataInnerRadius.setValue(float(self.__dictID11["INNER RADIUS"])) xsDataInputSPDCake.setInnerRadius(xsDataInnerRadius) if "OUTER RADIUS" in self.__dictID11: xsDataOuterRadius = XSDataDouble() xsDataOuterRadius.setValue(float(self.__dictID11["OUTER RADIUS"])) xsDataInputSPDCake.setOuterRadius(xsDataOuterRadius) if "X-BEAM CENTRE" in self.__dictID11: xsDataXBeamCentre = XSDataDouble() xsDataXBeamCentre.setValue(float(self.__dictID11["X-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsX(xsDataXBeamCentre) if "Y-BEAM CENTRE" in self.__dictID11: xsDataYBeamCentre = XSDataDouble() xsDataYBeamCentre.setValue(float(self.__dictID11["Y-BEAM CENTRE"])) xsDataInputSPDCake.setBeamCentreInPixelsY(xsDataYBeamCentre) # if "saving_format" in self.__dictID11: # xsSaveFormat = XSDataString() # if self.__dictID11["saving_format"] == "SPREAD SHEET": # xsSaveFormat.setValue("spr") # elif self.__dictID11["saving_format"] == "CIF": # xsSaveFormat.setValue("cif") # elif self.__dictID11["saving_format"] == "CHIPLOT": # xsSaveFormat.setValue("chi") # else: # xsSaveFormat.setValue("edf") # xsDataInputSPDCake.setOutputFileType(xsSaveFormat) if "output_dir" in self.__dictID11: xsOutputDir = XSDataFile() xsOutputDir.setPath(XSDataString(self.__dictID11["output_dir"])) xsDataInputSPDCake.setOutputDir(xsOutputDir) #Default options to SPD xsDataInputSPDCake.setOutputFileType(XSDataString("azim")) xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(not self.isVerboseDebug())) xsDataInputSPDCake.setCorrectTiltMask(XSDataBoolean(self.bCorrectMask)) return xsDataInputSPDCake
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'edge': obj_ = XSDataDouble() obj_.build(child_) self.setEdge(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'slope': obj_ = XSDataDouble() obj_.build(child_) self.setSlope(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'jump': obj_ = XSDataDouble() obj_.build(child_) self.setJump(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'hwl': obj_ = XSDataDouble() obj_.build(child_) self.setHwl(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'ewl': obj_ = XSDataDouble() obj_.build(child_) self.setEwl(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort92': obj_ = XSDataArray() obj_.build(child_) self.setFort92(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort95': obj_ = XSDataArray() obj_.build(child_) self.setFort95(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort96': obj_ = XSDataArray() obj_.build(child_) self.setFort96(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort97': obj_ = XSDataArray() obj_.build(child_) self.setFort97(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort98': obj_ = XSDataArray() obj_.build(child_) self.setFort98(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fort99': obj_ = XSDataArray() obj_.build(child_) self.setFort99(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beta': obj_ = XSDataDouble() obj_.build(child_) self.setBeta(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'gama': obj_ = XSDataDouble() obj_.build(child_) self.setGama(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'dose_half_th': obj_ = XSDataDouble() obj_.build(child_) self.setDose_half_th(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'dose_half': obj_ = XSDataDouble() obj_.build(child_) self.setDose_half(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'relative_radiation_sensitivity': obj_ = XSDataDouble() obj_.build(child_) self.setRelative_radiation_sensitivity(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'scaleIntensityPlot': obj_ = XSDataFile() obj_.build(child_) self.setScaleIntensityPlot(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'bFactorPlot': obj_ = XSDataFile() obj_.build(child_) self.setBFactorPlot(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'htmlPage': obj_ = XSDataFile() obj_.build(child_) self.setHtmlPage(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'jsonPath': obj_ = XSDataFile() obj_.build(child_) self.setJsonPath(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'absorbedDose': obj_ = XSDataDouble() obj_.build(child_) self.setAbsorbedDose(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'absorbedDoseRate': obj_ = XSDataAbsorbedDoseRate() obj_.build(child_) self.setAbsorbedDoseRate(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'pathToLogFile': obj_ = XSDataFile() obj_.build(child_) self.setPathToLogFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'timeToReachHendersonLimit': obj_ = XSDataTime() obj_.build(child_) self.setTimeToReachHendersonLimit(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'corelationFitValues': obj_ = XSDataDouble() obj_.build(child_) self.corelationFitValues.append(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fitFile': obj_ = XSDataFile() obj_.build(child_) self.setFitFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'lineProfileFitQuality': obj_ = XSDataDouble() obj_.build(child_) self.setLineProfileFitQuality(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'logFile': obj_ = XSDataFile() obj_.build(child_) self.setLogFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'pdbMoleculeFile': obj_ = XSDataFile() obj_.build(child_) self.setPdbMoleculeFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'pdbSolventFile': obj_ = XSDataFile() obj_.build(child_) self.setPdbSolventFile(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'scatteringFitQ': obj_ = XSDataDouble() obj_.build(child_) self.scatteringFitQ.append(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'scatteringFitValues': obj_ = XSDataDouble() obj_.build(child_) self.scatteringFitValues.append(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'scatteringFitQArray': obj_ = XSDataArray() obj_.build(child_) self.setScatteringFitQArray(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'scatteringFitIarray': obj_ = XSDataArray() obj_.build(child_) self.setScatteringFitIarray(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'meanNSD': obj_ = XSDataDouble() obj_.build(child_) self.setMeanNSD(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'variationNSD': obj_ = XSDataDouble() obj_.build(child_) self.setVariationNSD(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'centroidFrame': obj_ = XSDataDouble() obj_.build(child_) self.setCentroidFrame(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'centroidX': obj_ = XSDataDouble() obj_.build(child_) self.setCentroidX(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'centroidY': obj_ = XSDataDouble() obj_.build(child_) self.setCentroidY(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'IoverSigma': obj_ = XSDataDouble() obj_.build(child_) self.setIoverSigma(obj_) XSData.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'exposureTimePerImage': obj_ = XSDataDouble() obj_.build(child_) self.setExposureTimePerImage(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'transmission': obj_ = XSDataDouble() obj_.build(child_) self.setTransmission(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'numberOfImages': obj_ = XSDataDouble() obj_.build(child_) self.setNumberOfImages(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rotationWidth': obj_ = XSDataDouble() obj_.build(child_) self.setRotationWidth(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'resolution': obj_ = XSDataDouble() obj_.build(child_) self.setResolution(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'totalDose': obj_ = XSDataDouble() obj_.build(child_) self.setTotalDose(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'totalExposureTime': obj_ = XSDataDouble() obj_.build(child_) self.setTotalExposureTime(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'doseRate': obj_ = XSDataDouble() obj_.build(child_) self.setDoseRate(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'sensitivity': obj_ = XSDataDouble() obj_.build(child_) self.setSensitivity(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'minExposure': obj_ = XSDataDouble() obj_.build(child_) self.setMinExposure(obj_) XSDataResult.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rMaxStart': obj_ = XSDataDouble() obj_.build(child_) self.setRMaxStart(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rMaxStop': obj_ = XSDataDouble() obj_.build(child_) self.setRMaxStop(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rMaxIntervals': obj_ = XSDataInteger() obj_.build(child_) self.setRMaxIntervals(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'rMaxAbsTol': obj_ = XSDataDouble() obj_.build(child_) self.setRMaxAbsTol(obj_) XSData.buildChildren(self, child_, nodeName_)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'a': obj_ = XSDataDouble() obj_.build(child_) self.setA(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'b': obj_ = XSDataDouble() obj_.build(child_) self.setB(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'c': obj_ = XSDataDouble() obj_.build(child_) self.setC(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'd': obj_ = XSDataDouble() obj_.build(child_) self.setD(obj_)