def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage, _xsDataExperimentalCondition): """ This method retrieves the flux and beamsize from ISPyB """ xsDataExperimentalCondition = None if (_xsDataExperimentalCondition is not None): bFoundValidFlux = False xsDataExperimentalCondition = _xsDataExperimentalCondition.copy() xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection( ) xsDataInputRetrieveDataCollection.setImage( XSDataImage(_xsDataFirstImage.getPath())) self.edPluginISPyBRetrieveDataCollection.setDataInput( xsDataInputRetrieveDataCollection) self.edPluginISPyBRetrieveDataCollection.executeSynchronous() xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput( ) if xsDataResultRetrieveDataCollection is not None: xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection( ) if xsDataISPyBDataCollection is not None: fFlux = xsDataISPyBDataCollection.getFlux() if fFlux is not None: self.screen( "ISPyB reports flux to be: %g photons/sec" % fFlux) if fFlux > self.fFluxThreshold: xsDataExperimentalCondition.getBeam().setFlux( XSDataFlux(fFlux)) bFoundValidFlux = True fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None: self.screen("ISPyB reports beamsize X to be: %.3f mm" % fBeamSizeAtSampleX) self.screen("ISPyB reports beamsize Y to be: %.3f mm" % fBeamSizeAtSampleY) xsDataSize = XSDataSize() xsDataSize.x = XSDataLength(fBeamSizeAtSampleX) xsDataSize.y = XSDataLength(fBeamSizeAtSampleY) xsDataExperimentalCondition.getBeam().setSize( xsDataSize) if not bFoundValidFlux: self.screen( "No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data." ) xsDataBeam = xsDataExperimentalCondition.getBeam() xsDataBeamFlux = xsDataBeam.getFlux() if xsDataBeamFlux is not None: fFluxMXCuBE = xsDataBeamFlux.getValue() self.screen("MXCuBE reports flux to be: %g photons/sec" % fFluxMXCuBE) if fFluxMXCuBE < self.fFluxThreshold: self.screen("MXCuBE flux invalid!") return xsDataExperimentalCondition
def createInputCharacterisationFromSubWedges(self): EDVerbose.DEBUG( "EDPluginControlInterfacev2_0.createInputCharacterisationFromSubWedges" ) xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput( ) self.xsDataInputCharacterisation = XSDataInputCharacterisation() xsDataCollection = XSDataCollection() # Default exposure time (for the moment, this value should be # possible to read from the command line) xsDataDiffractionPlan = XSDataDiffractionPlan() if (not xsDataResultSubWedgeAssemble is None): pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge() xsDataCollection.setSubWedge(pyListSubWedge) for xsDataSubWedge in pyListSubWedge: if (self.strComplexity is not None): xsDataDiffractionPlan.setComplexity( XSDataString(self.strComplexity)) if (self.fFlux is not None): xsDataSubWedge.getExperimentalCondition().getBeam( ).setFlux(XSDataFloat(self.fFlux)) if (self.fBeamSize is not None): xsDataSize = XSDataSize() xsDataSize.setX(XSDataLength(self.fBeamSize)) xsDataSize.setY(XSDataLength(self.fBeamSize)) xsDataSubWedge.getExperimentalCondition().getBeam( ).setSize(xsDataSize) if (self.fBeamPosX is not None): xsDataSubWedge.getExperimentalCondition().getDetector( ).setBeamPositionX(XSDataLength(self.fBeamPosX)) if (self.fBeamPosY is not None): xsDataSubWedge.getExperimentalCondition().getDetector( ).setBeamPositionY(XSDataLength(self.fBeamPosY)) if (self.fMinExposureTimePerImage is not None): xsDataSubWedge.getExperimentalCondition().getBeam( ).setMinExposureTimePerImage( XSDataFloat(self.fMinExposureTimePerImage)) if (self.fTransmission is not None): xsDataSubWedge.getExperimentalCondition().getBeam( ).setTransmission(XSDataDouble(self.fTransmission)) if (self.strForcedSpaceGroup is not None): xsDataDiffractionPlan.setForcedSpaceGroup( XSDataString(self.strForcedSpaceGroup)) xsDataDiffractionPlan.setAnomalousData( XSDataBoolean(self.bAnomalousData)) xsDataDiffractionPlan.setMaxExposureTimePerDataCollection( XSDataTime(self.fMaxExposureTimePerDataCollection)) if (self.strStrategyOption is not None): xsDataDiffractionPlan.setStrategyOption( XSDataString(self.strStrategyOption)) xsDataCollection.setDiffractionPlan(xsDataDiffractionPlan) self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage, _xsDataExperimentalCondition): """ This method retrieves the flux and beamsize from ISPyB """ xsDataExperimentalCondition = None if (_xsDataExperimentalCondition is not None): bFoundValidFlux = False xsDataExperimentalCondition = _xsDataExperimentalCondition.copy() xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection() xsDataInputRetrieveDataCollection.setImage(XSDataImage(_xsDataFirstImage.getPath())) self.edPluginISPyBRetrieveDataCollection.setDataInput(xsDataInputRetrieveDataCollection) self.edPluginISPyBRetrieveDataCollection.executeSynchronous() xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput() if xsDataResultRetrieveDataCollection is not None: xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection() if xsDataISPyBDataCollection is not None: fFlux = xsDataISPyBDataCollection.getFlux_end() if fFlux is not None: self.screen("ISPyB reports flux to be: %g photons/sec" % fFlux) if fFlux > self.fFluxThreshold: xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(fFlux)) bFoundValidFlux = True fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None: self.screen("ISPyB reports beamsize X to be: %.3f mm" % fBeamSizeAtSampleX) self.screen("ISPyB reports beamsize Y to be: %.3f mm" % fBeamSizeAtSampleY) xsDataSize = XSDataSize() xsDataSize.x = XSDataLength(fBeamSizeAtSampleX) xsDataSize.y = XSDataLength(fBeamSizeAtSampleY) xsDataExperimentalCondition.getBeam().setSize(xsDataSize) # Get transmission if it's not already there if xsDataExperimentalCondition.beam.transmission is None: fTransmission = xsDataISPyBDataCollection.transmission xsDataExperimentalCondition.beam.transmission = XSDataDouble(fTransmission) if not bFoundValidFlux: self.screen("No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data.") xsDataBeam = xsDataExperimentalCondition.getBeam() xsDataBeamFlux = xsDataBeam.getFlux() if xsDataBeamFlux is not None: fFluxMXCuBE = xsDataBeamFlux.getValue() self.screen("MXCuBE reports flux to be: %g photons/sec" % fFluxMXCuBE) if fFluxMXCuBE < self.fFluxThreshold: self.screen("MXCuBE flux lower than threshold flux %g photons/s!" % self.fFluxThreshold) self.screen("Forcing flux to 0.0 photons/s") xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0)) else: # Force missing flux to 0.0 self.screen("No flux neither in ISPyB nor in mxCuBE, forcing flux to 0.0 photon/s") xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0)) return xsDataExperimentalCondition
def createInputCharacterisationFromSubWedges(self): self.DEBUG("EDPluginControlInterfacev1_2.createInputCharacterisationFromSubWedges") xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput() self.xsDataInputCharacterisation = XSDataInputCharacterisation() xsDataCollection = XSDataCollection() # Default exposure time (for the moment, this value should be # possible to read from the command line) if self.xsDataDiffractionPlan is None: self.xsDataDiffractionPlan = XSDataDiffractionPlan() if (not xsDataResultSubWedgeAssemble is None): pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge() xsDataCollection.setSubWedge(pyListSubWedge) for xsDataSubWedge in pyListSubWedge: if (self.strComplexity is not None): self.xsDataDiffractionPlan.setComplexity(XSDataString(self.strComplexity)) if (self.fFlux is not None): xsDataSubWedge.getExperimentalCondition().getBeam().setFlux(XSDataFlux(self.fFlux)) if (self.fBeamSizeX is not None) and (self.fBeamSizeY is not None): xsDataSize = XSDataSize() xsDataSize.setX(XSDataLength(self.fBeamSizeX)) xsDataSize.setY(XSDataLength(self.fBeamSizeY)) xsDataSubWedge.getExperimentalCondition().getBeam().setSize(xsDataSize) if (self.fBeamPosX is not None): xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionX(XSDataLength(self.fBeamPosX)) if (self.fBeamPosY is not None): xsDataSubWedge.getExperimentalCondition().getDetector().setBeamPositionY(XSDataLength(self.fBeamPosY)) if (self.fMinExposureTimePerImage is not None): xsDataSubWedge.getExperimentalCondition().getBeam().setMinExposureTimePerImage(XSDataTime(self.fMinExposureTimePerImage)) if (self.fTransmission is not None): xsDataSubWedge.getExperimentalCondition().getBeam().setTransmission(XSDataDouble(self.fTransmission)) if (self.fWavelength is not None): xsDataSubWedge.getExperimentalCondition().getBeam().setWavelength(XSDataWavelength(self.fWavelength)) if self.fMinOscillationWidth != None: xsDataSubWedge.getExperimentalCondition().getGoniostat().setMinOscillationWidth(XSDataAngle(self.fMinOscillationWidth)) if self.fMaxOscillationSpeed != None: xsDataSubWedge.getExperimentalCondition().getGoniostat().setMaxOscillationSpeed(XSDataAngularSpeed(self.fMaxOscillationSpeed)) if (self.strForcedSpaceGroup is not None): self.xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString(self.strForcedSpaceGroup)) self.xsDataDiffractionPlan.setAnomalousData(XSDataBoolean(self.bAnomalousData)) self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataTime(self.fMaxExposureTimePerDataCollection)) if (self.strStrategyOption is not None): self.xsDataDiffractionPlan.setStrategyOption(XSDataString(self.strStrategyOption)) xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan) if self.xsDataSample is not None: xsDataCollection.setSample(XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal())) self.xsDataInputCharacterisation.setDataCollection(xsDataCollection) self.xsDataInputCharacterisation.setToken(self.xsDataToken)
def from_params(self, data_collection, char_params): edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input) if data_collection.id: edna_input.setDataCollectionId(XSDataInteger(data_collection.id)) #Beam object beam = edna_input.getExperimentalCondition().getBeam() try: transmission = self.collect_obj.get_transmission() beam.setTransmission(XSDataDouble(transmission)) except AttributeError: pass try: wavelength = self.collect_obj.get_wavelength() beam.setWavelength(XSDataWavelength(wavelength)) except AttributeError: pass try: beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity())) except AttributeError: pass try: beamsize = self.get_beam_size() if not None in beamsize: beam.setSize( XSDataSize(x=XSDataLength(float(beamsize[0])), y=XSDataLength(float(beamsize[1])))) except AttributeError: pass #Optimization parameters diff_plan = edna_input.getDiffractionPlan() aimed_i_sigma = XSDataDouble(char_params.aimed_i_sigma) aimed_completness = XSDataDouble(char_params.aimed_completness) aimed_multiplicity = XSDataDouble(char_params.aimed_multiplicity) aimed_resolution = XSDataDouble(char_params.aimed_resolution) complexity = char_params.strategy_complexity complexity = XSDataString(qme.STRATEGY_COMPLEXITY[complexity]) permitted_phi_start = XSDataAngle(char_params.permitted_phi_start) _range = char_params.permitted_phi_end - char_params.permitted_phi_start rotation_range = XSDataAngle(_range) diff_plan.setAimedIOverSigmaAtHighestResolution(aimed_i_sigma) diff_plan.setAimedCompleteness(aimed_completness) if char_params.use_aimed_multiplicity: diff_plan.setAimedMultiplicity(aimed_multiplicity) if char_params.use_aimed_resolution: diff_plan.setAimedResolution(aimed_resolution) diff_plan.setComplexity(complexity) if char_params.use_permitted_rotation: diff_plan.setUserDefinedRotationStart(permitted_phi_start) diff_plan.setUserDefinedRotationRange(rotation_range) #Vertical crystal dimension sample = edna_input.getSample() sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim)) sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim)) #Radiation damage model sample.setSusceptibility(XSDataDouble(char_params.rad_suscept)) sample.setChemicalComposition(None) sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta / 1e6)) sample.setRadiationDamageModelGamma( XSDataDouble(char_params.gamma / 1e6)) diff_plan.setForcedSpaceGroup(XSDataString(char_params.space_group)) # Characterisation type - Routine DC if char_params.use_min_dose: pass if char_params.use_min_time: time = XSDataTime(char_params.min_time) diff_plan.setMaxExposureTimePerDataCollection(time) # Account for radiation damage if char_params.induce_burn: diff_plan.setStrategyOption(XSDataString("-DamPar")) else: diff_plan.setStrategyOption(None) # Characterisation type - SAD if char_params.opt_sad: diff_plan.setAnomalousData(XSDataBoolean(True)) else: diff_plan.setAnomalousData(XSDataBoolean(False)) #Data set data_set = XSDataMXCuBEDataSet() acquisition_parameters = data_collection.acquisitions[ 0].acquisition_parameters path_template = data_collection.acquisitions[0].path_template path_str = os.path.join(path_template.directory, path_template.get_image_file_name()) for img_num in range(int(acquisition_parameters.num_images)): image_file = XSDataFile() path = XSDataString() path.setValue(path_str % (img_num + 1)) image_file.setPath(path) data_set.addImageFile(image_file) edna_input.addDataSet(data_set) edna_input.process_directory = path_template.process_directory return edna_input
def getXSDataInputBest(self, _xsDataInputStrategy): xsDataBeam = _xsDataInputStrategy.getExperimentalCondition().getBeam() xsDataSample = _xsDataInputStrategy.getSample() xsDataDetector = _xsDataInputStrategy.getExperimentalCondition( ).getDetector() xsDataGoniostat = _xsDataInputStrategy.getExperimentalCondition( ).getGoniostat() xsDataDiffractionPlan = _xsDataInputStrategy.getDiffractionPlan() xsDataStringBestFileContentDat = _xsDataInputStrategy.getBestFileContentDat( ) xsDataStringBestFileContentPar = _xsDataInputStrategy.getBestFileContentPar( ) xsDataFileXdsBackgroundImage = _xsDataInputStrategy.getXdsBackgroundImage( ) listXSDataStringBestFileContentHKL = _xsDataInputStrategy.getBestFileContentHKL( ) xsDataInputBest = XSDataInputBest() # Sample xsDataAbsorbedDose = None xsDataSusceptibility = None # Could be None if sample has not been set # It could be not None in case Raddose has calculated an absorbed dose with default sample values if (xsDataSample is not None): xsDataAbsorbedDose = xsDataSample.getAbsorbedDoseRate() xsDataSusceptibility = xsDataSample.getSusceptibility() # crystalShape # Default value is 1 (We assume that Xtal is smaller than beam) if xsDataSample.size is not None and xsDataSample.omegaMin is not None: xsDataInputBest.crystalSize = XSDataSize().parseString( xsDataSample.size.marshal()) xsDataInputBest.omegaMin = xsDataSample.omegaMin else: xsDataDoubleCrystalShape = xsDataSample.getShape() if (xsDataDoubleCrystalShape is None): if (xsDataSample.getSize() is None) or (xsDataBeam.getSize() is None): xsDataDoubleCrystalShape = XSDataDouble(1) else: fCrystalSizeY = xsDataSample.getSize().getY().getValue( ) fCrystalSizeZ = xsDataSample.getSize().getZ().getValue( ) fDiagonal = math.sqrt(fCrystalSizeY**2 + fCrystalSizeZ**2) fBeamSizeY = xsDataBeam.getSize().getY().getValue() fCrystalShape = None if fBeamSizeY > fDiagonal: fCrystalShape = 1.0 else: fCrystalShape = int( 10 * fDiagonal / fBeamSizeY) / 10.0 xsDataDoubleCrystalShape = XSDataDouble(fCrystalShape) xsDataInputBest.setCrystalShape(xsDataDoubleCrystalShape) # Radiation damage model parameters xsDataInputBest.setRadiationDamageModelBeta( xsDataSample.getRadiationDamageModelBeta()) xsDataInputBest.setRadiationDamageModelGamma( xsDataSample.getRadiationDamageModelGamma()) # Could be None if Raddose failed to calculate the absorbed dose if (xsDataAbsorbedDose is not None): xsDataInputBest.setCrystalAbsorbedDoseRate( xsDataSample.getAbsorbedDoseRate()) xsDataInputBest.setCrystalSusceptibility(xsDataSusceptibility) # Detector xsDataInputBest.setDetectorType(xsDataDetector.getType()) # Minimum exposure time per image xsDataTimeMinExposureTimePerImage = None if xsDataBeam: xsDataTimeMinExposureTimePerImage = xsDataBeam.getMinExposureTimePerImage( ) if xsDataTimeMinExposureTimePerImage == None: xsDataTimeMinExposureTimePerImage = xsDataDiffractionPlan.getMinExposureTimePerImage( ) xsDataInputBest.setBeamMinExposureTime( xsDataTimeMinExposureTimePerImage) # Max rotation speed xsDataAngularSpeedMax = None if xsDataGoniostat: xsDataAngularSpeedMax = xsDataGoniostat.getMaxOscillationSpeed() if xsDataDiffractionPlan and xsDataAngularSpeedMax == None: xsDataAngularSpeedMax = xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed( ) xsDataInputBest.setGoniostatMaxRotationSpeed(xsDataAngularSpeedMax) # Min rotation width xsDataAngleMin = None if xsDataGoniostat: xsDataAngleMin = xsDataGoniostat.getMinOscillationWidth() if xsDataDiffractionPlan and xsDataAngleMin == None: xsDataAngleMin = xsDataDiffractionPlan.getGoniostatMinOscillationWidth( ) xsDataInputBest.setGoniostatMinRotationWidth(xsDataAngleMin) # Other beam parameters if xsDataBeam: xsDataInputBest.setBeamExposureTime(xsDataBeam.getExposureTime()) if xsDataBeam.getTransmission(): # Fix for bug 741: if the transmission is zero don't set it and warn the user fTransmission = xsDataBeam.getTransmission().getValue() if (abs(fTransmission) < 0.1): EDVerbose.warning( "Input transmission to BEST ignored because it is zero or close to zero: %f" % fTransmission) else: xsDataInputBest.setTransmission( xsDataBeam.getTransmission()) if xsDataBeam.getApertureSize(): xsDataInputBest.setApertureSize(xsDataBeam.getApertureSize()) if xsDataBeam.size: xsDataInputBest.setBeamSize(xsDataBeam.size) if xsDataBeam.flux: xsDataInputBest.setBeamFlux(xsDataBeam.flux) # Other diffraction plan parameters if xsDataDiffractionPlan: xsDataInputBest.setAimedResolution( xsDataDiffractionPlan.getAimedResolution()) xsDataInputBest.setAimedRedundancy( xsDataDiffractionPlan.getAimedMultiplicity()) xsDataInputBest.setAimedCompleteness( xsDataDiffractionPlan.getAimedCompleteness()) xsDataInputBest.setAimedIOverSigma( xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution()) xsDataInputBest.setBeamMaxExposureTime( xsDataDiffractionPlan.getMaxExposureTimePerDataCollection()) xsDataInputBest.setComplexity( xsDataDiffractionPlan.getComplexity()) xsDataInputBest.setAnomalousData( xsDataDiffractionPlan.getAnomalousData()) xsDataInputBest.setStrategyOption( xsDataDiffractionPlan.getStrategyOption()) xsDataInputBest.setMinTransmission( xsDataDiffractionPlan.getMinTransmission()) xsDataInputBest.setNumberOfCrystalPositions( xsDataDiffractionPlan.getNumberOfPositions()) xsDataInputBest.setDetectorDistanceMin( xsDataDiffractionPlan.getDetectorDistanceMin()) xsDataInputBest.setDetectorDistanceMax( xsDataDiffractionPlan.getDetectorDistanceMax()) xsDataInputBest.setUserDefinedRotationStart( xsDataDiffractionPlan.getUserDefinedRotationStart()) xsDataInputBest.setUserDefinedRotationRange( xsDataDiffractionPlan.getUserDefinedRotationRange()) xsDataInputBest.doseLimit = xsDataDiffractionPlan.doseLimit xsDataInputBest.rFriedel = xsDataDiffractionPlan.rFriedel # Best Files xsDataInputBest.setBestFileContentDat(xsDataStringBestFileContentDat) xsDataInputBest.setBestFileContentPar(xsDataStringBestFileContentPar) xsDataInputBest.setBestFileContentHKL( listXSDataStringBestFileContentHKL) xsDataInputBest.setXdsBackgroundImage(xsDataFileXdsBackgroundImage) return xsDataInputBest
def testSetDataModelInput(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() xsDataStrategy = XSDataInputStrategy() # Beam xsExperimentalCondition = XSDataExperimentalCondition() xsBeam = XSDataBeam() xsBeam.setFlux(XSDataFlux(1e+12)) xsBeam.setWavelength(XSDataWavelength(2.41)) xsBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1))) xsBeam.setExposureTime(XSDataTime(1)) xsExperimentalCondition.setBeam(xsBeam) # Detector and Exposure Time xsDataDetector = XSDataDetector() xsDataDetector.setType(XSDataString("q210-2x")) xsExperimentalCondition.setDetector(xsDataDetector) xsDataGoniostat = XSDataGoniostat() xsDataGoniostat.setRotationAxis(XSDataString("phi")) xsExperimentalCondition.setGoniostat(xsDataGoniostat) xsDataStrategy.setExperimentalCondition(xsExperimentalCondition) # Best Files bestFileContentDat = EDUtilsFile.readFile( os.path.join(self.strDataPath, "bestfile.dat")) xsDataStrategy.setBestFileContentDat(XSDataString(bestFileContentDat)) bestFileContentPar = EDUtilsFile.readFile( os.path.join(self.strDataPath, "bestfile.par")) xsDataStrategy.setBestFileContentPar(XSDataString(bestFileContentPar)) bestFileContentHKL = EDUtilsFile.readFile( os.path.join(self.strDataPath, "bestfile1.hkl")) xsDataStrategy.addBestFileContentHKL(XSDataString(bestFileContentHKL)) # Crystal xsDataSampleCrystalMM = XSDataSampleCrystalMM() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataChain.setNumberOfMonomers(XSDataDouble(100)) xsDataStructure.addChain(xsDataChain) xsDataChain2 = XSDataChain() xsDataChain2.setType(XSDataString("rna")) xsDataChain2.setNumberOfCopies(XSDataDouble(1)) xsDataChain2.setNumberOfMonomers(XSDataDouble(60)) xsDataStructure.addChain(xsDataChain2) xsDataLigand = XSDataLigand() xsDataLigand.setNumberOfCopies(XSDataDouble(2)) xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom2 = XSDataAtom() xsDataAtom2.setSymbol(XSDataString("Fe")) xsDataAtom2.setNumberOf(XSDataDouble(1)) xsDataAtomicComposition.addAtom(xsDataAtom2) xsDataLigand.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addLigand(xsDataLigand) xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25)) xsDataSolvent = XSDataSolvent() xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom3 = XSDataAtom() xsDataAtom3.setSymbol(XSDataString("Na")) xsDataAtom3.setConcentration(XSDataDouble(1000)) xsDataAtom4 = XSDataAtom() xsDataAtom4.setSymbol(XSDataString("Cl")) xsDataAtom4.setConcentration(XSDataDouble(1000)) xsDataAtomicComposition.addAtom(xsDataAtom3) xsDataAtomicComposition.addAtom(xsDataAtom4) xsDataSolvent.setAtoms(xsDataAtomicComposition) xsDataComposition.setStructure(xsDataStructure) xsDataComposition.setSolvent(xsDataSolvent) xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition) xsDataSampleCrystalMM.setSize( XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1))) xsDataCrystal = XSDataCrystal() xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0), angle_beta=XSDataAngle(90.0), angle_gamma=XSDataAngle(90.0), length_a=XSDataLength(78.9), length_b=XSDataLength(95.162), length_c=XSDataLength(104.087)) xsDataCrystal.setCell(xsDataCell) xsDataSpaceGroup = XSDataSpaceGroup() xsDataSpaceGroup.setITNumber(XSDataInteger(16)) xsDataCrystal.setSpaceGroup(xsDataSpaceGroup) xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5)) xsDataStrategy.setCrystalRefined(xsDataCrystal) xsDataStrategy.setSample(xsDataSampleCrystalMM) xsDataStrategy.exportToFile(self.strObtainedInputFile) pyStrExpectedInput = self.readAndParseFile(self.strReferenceInputFile) pyStrObtainedInput = self.readAndParseFile(self.strObtainedInputFile) xsDataInputExpected = XSDataInputStrategy.parseString( pyStrExpectedInput) xsDataInputObtained = XSDataInputStrategy.parseString( pyStrObtainedInput) EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
def testSetDataModelInput(self): # Crystal from XSDataRaddosev10 import XSDataRaddoseInput xsDataRaddoseInput = XSDataRaddoseInput() from XSDataCommon import XSDataString from XSDataCommon import XSDataDouble from XSDataCommon import XSDataAngle from XSDataCommon import XSDataLength from XSDataCommon import XSDataSize from XSDataCommon import XSDataInteger from XSDataRaddosev10 import XSDataCell from XSDataRaddosev10 import XSDataAtom from XSDataRaddosev10 import XSDataAtomicComposition xsDataAtomSulfur = XSDataAtom() xsDataAtomSulfur.setNumberOf(XSDataDouble(4)) xsDataAtomSulfur.setSymbol(XSDataString("S")) xsDataAtomSelenium = XSDataAtom() xsDataAtomSelenium.setNumberOf(XSDataDouble(4)) xsDataAtomSelenium.setSymbol(XSDataString("Se")) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomicComposition.addAtom(xsDataAtomSulfur) xsDataAtomicComposition.addAtom(xsDataAtomSelenium) xsDataRaddoseInput.setCrystalPATM(xsDataAtomicComposition) xsDataRaddoseInput.setCrystalNRES(XSDataInteger(295)) xsDataRaddoseInput.setCrystalNMON(XSDataInteger(8)) xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0), angle_beta=XSDataAngle(90.0), angle_gamma=XSDataAngle(90.0), length_a=XSDataLength(78.9), length_b=XSDataLength(95.162), length_c=XSDataLength(104.087)) xsDataSizeCrystal = XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1)) xsDataRaddoseInput.setCrystalCell(xsDataCell) xsDataRaddoseInput.setCrystalSize(xsDataSizeCrystal) # Beam from XSDataCommon import XSDataFlux from XSDataCommon import XSDataWavelength from XSDataCommon import XSDataTime xsDataSize = XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)) xsDataRaddoseInput.setBeamSize(xsDataSize) xsDataRaddoseInput.setBeamFlux(XSDataFlux(1e+12)) xsDataRaddoseInput.setBeamWavelength(XSDataWavelength(2.41)) xsDataRaddoseInput.setBeamExposureTime(XSDataTime(1)) xsDataRaddoseInput.setNumberOfImages(XSDataInteger(1)) xsDataRaddoseInput.exportToFile(self.strObtainedInputFile) strExpectedInput = self.readAndParseFile(self.strReferenceInputFile) strObtainedInput = self.readAndParseFile(self.strObtainedInputFile) xsDataRaddoseInputExpected = XSDataRaddoseInput.parseString( strExpectedInput) xsDataRaddoseInputObtained = XSDataRaddoseInput.parseString( strObtainedInput) EDAssert.equal(xsDataRaddoseInputExpected.marshal(), xsDataRaddoseInputObtained.marshal())
def testSetDataModelInput(self): from XSDataCCP4iv1_1 import XSDataInputCCP4i xsDataInputCCP4i = XSDataInputCCP4i() # Beam from XSDataCommon import XSDataFlux from XSDataCommon import XSDataSize from XSDataCommon import XSDataLength from XSDataCommon import XSDataFloat from XSDataMXv1 import XSDataBeam from XSDataMXv1 import XSDataExperimentalCondition xsExperimentalCondition = XSDataExperimentalCondition() xsBeam = XSDataBeam() xsBeam.setFlux(XSDataFlux(1e+12)) xsBeam.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1))) xsBeam.setMinExposureTimePerImage(XSDataFloat(0.1)) xsExperimentalCondition.setBeam(xsBeam) # Goniostat from XSDataCommon import XSDataSpeed from XSDataCommon import XSDataAngle from XSDataMXv1 import XSDataGoniostat xsDataGoniostat = XSDataGoniostat() xsDataGoniostat.setMaxOscillationSpeed(XSDataSpeed(0.2)) xsDataGoniostat.setMinOscillationWidth(XSDataAngle(0.1)) xsExperimentalCondition.setGoniostat(xsDataGoniostat) xsDataInputCCP4i.setExperimentalCondition(xsExperimentalCondition) # Sample from XSDataCommon import XSDataString from XSDataCommon import XSDataFloat from XSDataCommon import XSDataString from XSDataMXv1 import XSDataStructure from XSDataMXv1 import XSDataChain from XSDataMXv1 import XSDataAtom from XSDataMXv1 import XSDataLigand from XSDataMXv1 import XSDataSampleCrystalMM from XSDataMXv1 import XSDataChemicalCompositionMM from XSDataMXv1 import XSDataAtomicComposition from XSDataMXv1 import XSDataSolvent xsDataSampleCrystalMM = XSDataSampleCrystalMM() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataFloat(2)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataFloat(4)) xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataChain.setNumberOfMonomers(XSDataFloat(100)) xsDataStructure.addChain(xsDataChain) xsDataChain2 = XSDataChain() xsDataChain2.setType(XSDataString("rna")) xsDataChain2.setNumberOfCopies(XSDataFloat(1)) xsDataChain2.setNumberOfMonomers(XSDataFloat(60)) xsDataStructure.addChain(xsDataChain2) xsDataLigand = XSDataLigand() xsDataLigand.setNumberOfCopies(XSDataFloat(2)) xsDataLigand.setNumberOfLightAtoms(XSDataFloat(42)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom2 = XSDataAtom() xsDataAtom2.setSymbol(XSDataString("Fe")) xsDataAtom2.setNumberOf(XSDataFloat(1)) xsDataAtomicComposition.addAtom(xsDataAtom2) xsDataLigand.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addLigand(xsDataLigand) xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataFloat(0.25)) xsDataSolvent = XSDataSolvent() xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom3 = XSDataAtom() xsDataAtom3.setSymbol(XSDataString("Na")) xsDataAtom3.setConcentration(XSDataFloat(1000)) xsDataAtom4 = XSDataAtom() xsDataAtom4.setSymbol(XSDataString("Cl")) xsDataAtom4.setConcentration(XSDataFloat(1000)) xsDataAtomicComposition.addAtom(xsDataAtom3) xsDataAtomicComposition.addAtom(xsDataAtom4) xsDataSolvent.setAtoms(xsDataAtomicComposition) xsDataComposition.setStructure(xsDataStructure) xsDataComposition.setSolvent(xsDataSolvent) xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition) xsDataSampleCrystalMM.setSize(XSDataSize(XSDataLength(0.2), XSDataLength(0.2), XSDataLength(0.2))) xsDataSampleCrystalMM.setSusceptibility(XSDataFloat(1.5)) xsDataSampleCrystalMM.setShape(XSDataFloat(2)) xsDataInputCCP4i.setSample(xsDataSampleCrystalMM) from XSDataMXv1 import XSDataDiffractionPlan xsDataDiffractionPlan = XSDataDiffractionPlan() xsDataDiffractionPlan.setAimedCompleteness(XSDataFloat(95.5)) xsDataDiffractionPlan.setAimedIOverSigmaAtHighestResolution(XSDataFloat(2.5)) xsDataDiffractionPlan.setAimedMultiplicity(XSDataFloat(95.5)) xsDataDiffractionPlan.setAimedResolution(XSDataFloat(3)) xsDataDiffractionPlan.setComplexity(XSDataString("full")) xsDataDiffractionPlan.setForcedSpaceGroup(XSDataString("P222")) xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(XSDataFloat(10000)) xsDataInputCCP4i.setDiffractionPlan(xsDataDiffractionPlan) from XSDataCommon import XSDataFile listInputDataFile = [] xsDataFile = XSDataFile(XSDataString(self.strXSDataGenerateTemplateFile)) listInputDataFile.append(xsDataFile) xsDataInputCCP4i.setDataFile(listInputDataFile)
def testGetXSDataRaddoseInput(self): """ """ from XSDataCommon import XSDataLength from XSDataCommon import XSDataWavelength from XSDataCommon import XSDataFlux from XSDataCommon import XSDataSize from XSDataCommon import XSDataDouble from XSDataCommon import XSDataString from XSDataCommon import XSDataAngle from XSDataCommon import XSDataTime from XSDataCommon import XSDataInteger from XSDataMXv1 import XSDataBeam from XSDataMXv1 import XSDataStructure from XSDataMXv1 import XSDataChain from XSDataMXv1 import XSDataAtom from XSDataMXv1 import XSDataLigand from XSDataMXv1 import XSDataCrystal from XSDataMXv1 import XSDataSpaceGroup from XSDataMXv1 import XSDataSampleCrystalMM from XSDataMXv1 import XSDataChemicalCompositionMM from XSDataMXv1 import XSDataAtomicComposition from XSDataMXv1 import XSDataSolvent from XSDataMXv1 import XSDataCell from EDHandlerXSDataRaddosev10 import EDHandlerXSDataRaddosev10 EDFactoryPluginStatic.loadModule("XSDataRaddosev10") from XSDataRaddosev10 import XSDataRaddoseInput xsDataBeam = XSDataBeam() xsDataBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1))) xsDataBeam.setWavelength(XSDataWavelength(2.41)) xsDataBeam.setFlux(XSDataFlux(1e+12)) xsDataBeam.setExposureTime(XSDataTime(0.037)) xsDataSample = XSDataSampleCrystalMM() xsDataStructure = XSDataStructure() xsDataComposition = XSDataChemicalCompositionMM() xsDataChain = XSDataChain() xsDataChain.setType(XSDataString("protein")) xsDataChain.setNumberOfCopies(XSDataDouble(2)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom1 = XSDataAtom() xsDataAtom1.setSymbol(XSDataString("Se")) xsDataAtom1.setNumberOf(XSDataDouble(4)) xsDataAtomicComposition.addAtom(xsDataAtom1) xsDataAtom2 = XSDataAtom() xsDataAtom2.setSymbol(XSDataString("S")) xsDataAtom2.setNumberOf(XSDataDouble(5)) xsDataAtomicComposition.addAtom(xsDataAtom2) xsDataChain.setHeavyAtoms(xsDataAtomicComposition) xsDataChain.setNumberOfMonomers(XSDataDouble(100)) xsDataStructure.addChain(xsDataChain) xsDataChain2 = XSDataChain() xsDataChain2.setType(XSDataString("rna")) xsDataChain2.setNumberOfCopies(XSDataDouble(1)) xsDataChain2.setNumberOfMonomers(XSDataDouble(60)) xsDataStructure.addChain(xsDataChain2) xsDataLigand = XSDataLigand() xsDataLigand.setNumberOfCopies(XSDataDouble(2)) xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42)) xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtom3 = XSDataAtom() xsDataAtom3.setSymbol(XSDataString("Fe")) xsDataAtom3.setNumberOf(XSDataDouble(1)) xsDataAtomicComposition.addAtom(xsDataAtom3) xsDataLigand.setHeavyAtoms(xsDataAtomicComposition) xsDataStructure.addLigand(xsDataLigand) xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25)) xsDataSolvent = XSDataSolvent() xsDataAtomicComposition = XSDataAtomicComposition() xsDataAtomNa = XSDataAtom() xsDataAtomNa.setSymbol(XSDataString("Na")) xsDataAtomNa.setConcentration(XSDataDouble(1000)) xsDataAtomicComposition.addAtom(xsDataAtomNa) xsDataAtomCl = XSDataAtom() xsDataAtomCl.setSymbol(XSDataString("Cl")) xsDataAtomCl.setConcentration(XSDataDouble(1000)) xsDataAtomicComposition.addAtom(xsDataAtomCl) xsDataSolvent.setAtoms(xsDataAtomicComposition) xsDataComposition.setStructure(xsDataStructure) xsDataComposition.setSolvent(xsDataSolvent) xsDataSample.setChemicalComposition(xsDataComposition) xsDataSample.setSize( XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1))) xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0), angle_beta=XSDataAngle(90.0), angle_gamma=XSDataAngle(90.0), length_a=XSDataLength(78.9), length_b=XSDataLength(95.162), length_c=XSDataLength(104.087)) xsDataCrystal = XSDataCrystal() xsDataSpaceGroup = XSDataSpaceGroup() xsDataCrystal.setCell(xsDataCell) xsDataSpaceGroup.setITNumber(XSDataInteger(16)) xsDataCrystal.setSpaceGroup(xsDataSpaceGroup) xsDataSample.setCrystal(xsDataCrystal) iNumSymOperators = 4 iNumberOfImages = 2 xsDataRaddosev01Input = EDHandlerXSDataRaddosev10( ).getXSDataRaddoseInput(xsDataBeam, xsDataSample, iNumSymOperators, iNumberOfImages) xsDataRaddosev01Input.exportToFile(self.strObtainedInputFile2) strExpectedInput = EDUtilsTest.readAndParseFile( self.strReferenceInputFile2) strObtainedInput = EDUtilsTest.readAndParseFile( self.strObtainedInputFile2) xsDataInputExpected = XSDataRaddoseInput.parseString(strExpectedInput) xsDataInputObtained = XSDataRaddoseInput.parseString(strObtainedInput) EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamExposureTime': obj_ = XSDataTime() obj_.build(child_) self.setBeamExposureTime(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamFlux': obj_ = XSDataFlux() obj_.build(child_) self.setBeamFlux(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamSize': obj_ = XSDataSize() obj_.build(child_) self.setBeamSize(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'beamWavelength': obj_ = XSDataWavelength() obj_.build(child_) self.setBeamWavelength(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalCell': obj_ = XSDataCell() obj_.build(child_) self.setCrystalCell(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalNDNA': obj_ = XSDataInteger() obj_.build(child_) self.setCrystalNDNA(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalNMON': obj_ = XSDataInteger() obj_.build(child_) self.setCrystalNMON(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalNRES': obj_ = XSDataInteger() obj_.build(child_) self.setCrystalNRES(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalNRNA': obj_ = XSDataInteger() obj_.build(child_) self.setCrystalNRNA(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalPATM': obj_ = XSDataAtomicComposition() obj_.build(child_) self.setCrystalPATM(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalSATM': obj_ = XSDataAtomicComposition() obj_.build(child_) self.setCrystalSATM(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'crystalSize': obj_ = XSDataSize() obj_.build(child_) self.setCrystalSize(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'numberOfImages': obj_ = XSDataInteger() obj_.build(child_) self.setNumberOfImages(obj_) XSDataInput.buildChildren(self, child_, nodeName_)