def Scaler(*args, **kwargs): """Create a Scaler implementation.""" scaler = None preselection = get_preferences().get("scaler") if not scaler and (not preselection or preselection == "ccp4a"): try: scaler = CCP4ScalerA(*args, **kwargs) logger.debug("Using CCP4A Scaler") except NotAvailableError: if preselection == "ccp4a": raise RuntimeError("preselected scaler ccp4a not available") if not scaler and (not preselection or preselection == "xdsa"): try: scaler = XDSScalerA(*args, **kwargs) logger.debug("Using XDSA Scaler") except NotAvailableError: if preselection == "xdsa": raise RuntimeError("preselected scaler xdsa not available") if not scaler and (not preselection or preselection == "dials"): try: scaler = DialsScaler(*args, **kwargs) logger.debug("Using DIALS Scaler") except NotAvailableError: if preselection == "dials": raise RuntimeError("preselected scaler dials not available") return scaler
def Scaler(): '''Create a Scaler implementation.''' scaler = None preselection = get_preferences().get('scaler') if not scaler and \ (not preselection or preselection == 'ccp4a'): try: scaler = CCP4ScalerA() Debug.write('Using CCP4A Scaler') except NotAvailableError: if preselection == 'ccp4a': raise RuntimeError('preselected scaler ccp4a not available') if not scaler and \ (not preselection or preselection == 'xdsa'): try: scaler = XDSScalerA() Debug.write('Using XDSA Scaler') except NotAvailableError: if preselection == 'xdsa': raise RuntimeError('preselected scaler xdsa not available') return scaler
def test_xds_scalerA(ccp4, xia2_regression_build, tmpdir, nproc): if nproc is not None: from xia2.Handlers.Phil import PhilIndex PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc template = os.path.join(xia2_regression_build, "test_data", "insulin", "insulin_1_###.img") tmpdir.chdir() tmpdir = tmpdir.strpath from xia2.Modules.Indexer.XDSIndexer import XDSIndexer from xia2.Modules.Integrater.XDSIntegrater import XDSIntegrater from xia2.Modules.Scaler.XDSScalerA import XDSScalerA indexer = XDSIndexer() indexer.set_working_directory(tmpdir) from dxtbx.datablock import DataBlockTemplateImporter importer = DataBlockTemplateImporter([template]) datablocks = importer.datablocks imageset = datablocks[0].extract_imagesets()[0] indexer.add_indexer_imageset(imageset) from xia2.Schema.XCrystal import XCrystal from xia2.Schema.XWavelength import XWavelength from xia2.Schema.XSweep import XSweep from xia2.Schema.XSample import XSample cryst = XCrystal("CRYST1", None) wav = XWavelength("WAVE1", cryst, imageset.get_beam().get_wavelength()) samp = XSample("X1", cryst) directory, image = os.path.split(imageset.get_path(1)) with mock.patch.object(sys, 'argv', []): sweep = XSweep('SWEEP1', wav, samp, directory=directory, image=image) indexer.set_indexer_sweep(sweep) from xia2.Modules.Refiner.XDSRefiner import XDSRefiner refiner = XDSRefiner() refiner.set_working_directory(tmpdir) refiner.add_refiner_indexer(sweep.get_epoch(1), indexer) integrater = XDSIntegrater() integrater.set_working_directory(tmpdir) integrater.setup_from_image(imageset.get_path(1)) integrater.set_integrater_refiner(refiner) #integrater.set_integrater_indexer(indexer) integrater.set_integrater_sweep(sweep) integrater.set_integrater_sweep_name('SWEEP1') integrater.set_integrater_project_info('CRYST1', 'WAVE1', 'SWEEP1') scaler = XDSScalerA() scaler.add_scaler_integrater(integrater) scaler.set_scaler_xcrystal(cryst) scaler.set_scaler_project_info('CRYST1', 'WAVE1') check_scaler_files_exist(scaler) # test serialization of scaler json_str = scaler.as_json() #print json_str scaler2 = XDSScalerA.from_json(string=json_str) scaler2.set_scaler_xcrystal(cryst) check_scaler_files_exist(scaler2) scaler2.set_scaler_finish_done(False) check_scaler_files_exist(scaler2) scaler2.set_scaler_done(False) check_scaler_files_exist(scaler2) scaler2._scalr_integraters = {} # XXX scaler2.add_scaler_integrater(integrater) scaler2.set_scaler_prepare_done(False) check_scaler_files_exist(scaler2)
def test_xds_scalerA(regression_test, ccp4, xds, dials_data, run_in_tmpdir, nproc): if nproc is not None: from xia2.Handlers.Phil import PhilIndex PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc template = dials_data("insulin").join("insulin_1_###.img").strpath tmpdir = run_in_tmpdir.strpath from xia2.Modules.Indexer.XDSIndexer import XDSIndexer from xia2.Modules.Integrater.XDSIntegrater import XDSIntegrater from xia2.Modules.Scaler.XDSScalerA import XDSScalerA indexer = XDSIndexer() indexer.set_working_directory(tmpdir) from dxtbx.model.experiment_list import ExperimentListTemplateImporter importer = ExperimentListTemplateImporter([template]) experiments = importer.experiments imageset = experiments.imagesets()[0] indexer.add_indexer_imageset(imageset) from xia2.Schema.XCrystal import XCrystal from xia2.Schema.XWavelength import XWavelength from xia2.Schema.XSweep import XSweep from xia2.Schema.XSample import XSample cryst = XCrystal("CRYST1", None) wav = XWavelength("WAVE1", cryst, imageset.get_beam().get_wavelength()) samp = XSample("X1", cryst) directory, image = os.path.split(imageset.get_path(1)) with mock.patch.object(sys, "argv", []): sweep = XSweep("SWEEP1", wav, samp, directory=directory, image=image) indexer.set_indexer_sweep(sweep) from xia2.Modules.Refiner.XDSRefiner import XDSRefiner refiner = XDSRefiner() refiner.set_working_directory(tmpdir) refiner.add_refiner_indexer(sweep.get_epoch(1), indexer) integrater = XDSIntegrater() integrater.set_working_directory(tmpdir) integrater.setup_from_image(imageset.get_path(1)) integrater.set_integrater_refiner(refiner) # integrater.set_integrater_indexer(indexer) integrater.set_integrater_sweep(sweep) integrater.set_integrater_sweep_name("SWEEP1") integrater.set_integrater_project_info("CRYST1", "WAVE1", "SWEEP1") scaler = XDSScalerA(base_path=pathlib.Path(tmpdir)) scaler.add_scaler_integrater(integrater) scaler.set_scaler_xcrystal(cryst) scaler.set_scaler_project_info("CRYST1", "WAVE1") check_scaler_files_exist(scaler) # test serialization of scaler json_str = scaler.as_json() # print json_str scaler2 = XDSScalerA.from_json(string=json_str) scaler2.set_scaler_xcrystal(cryst) check_scaler_files_exist(scaler2) scaler2.set_scaler_done(False) check_scaler_files_exist(scaler2) scaler2._scalr_integraters = {} # XXX scaler2.add_scaler_integrater(integrater) scaler2.set_scaler_prepare_done(False) check_scaler_files_exist(scaler2)
def exercise_xds_scaler(nproc=None): if not have_dials_regression: print "Skipping exercise_xds_scaler(): dials_regression not configured" return if nproc is not None: from xia2.Handlers.Phil import PhilIndex PhilIndex.params.xia2.settings.multiprocessing.nproc = nproc xia2_demo_data = os.path.join(dials_regression, "xia2_demo_data") template = os.path.join(xia2_demo_data, "insulin_1_###.img") cwd = os.path.abspath(os.curdir) tmp_dir = os.path.abspath(open_tmp_directory()) os.chdir(tmp_dir) from xia2.Modules.Indexer.XDSIndexer import XDSIndexer from xia2.Modules.Integrater.XDSIntegrater import XDSIntegrater from xia2.Modules.Scaler.XDSScalerA import XDSScalerA indexer = XDSIndexer() indexer.set_working_directory(tmp_dir) from dxtbx.datablock import DataBlockTemplateImporter importer = DataBlockTemplateImporter([template]) datablocks = importer.datablocks imageset = datablocks[0].extract_imagesets()[0] indexer.add_indexer_imageset(imageset) from xia2.Schema.XCrystal import XCrystal from xia2.Schema.XWavelength import XWavelength from xia2.Schema.XSweep import XSweep from xia2.Schema.XSample import XSample cryst = XCrystal("CRYST1", None) wav = XWavelength("WAVE1", cryst, imageset.get_beam().get_wavelength()) samp = XSample("X1", cryst) directory, image = os.path.split(imageset.get_path(1)) sweep = XSweep('SWEEP1', wav, samp, directory=directory, image=image) indexer.set_indexer_sweep(sweep) from xia2.Modules.Refiner.XDSRefiner import XDSRefiner refiner = XDSRefiner() refiner.set_working_directory(tmp_dir) refiner.add_refiner_indexer(sweep.get_epoch(1), indexer) integrater = XDSIntegrater() integrater.set_working_directory(tmp_dir) integrater.setup_from_image(imageset.get_path(1)) integrater.set_integrater_refiner(refiner) #integrater.set_integrater_indexer(indexer) integrater.set_integrater_sweep(sweep) integrater.set_integrater_sweep_name('SWEEP1') integrater.set_integrater_project_info('CRYST1', 'WAVE1', 'SWEEP1') scaler = XDSScalerA() scaler.add_scaler_integrater(integrater) scaler.set_scaler_xcrystal(cryst) scaler.set_scaler_project_info('CRYST1', 'WAVE1') check_scaler_files_exist(scaler) # test serialization of scaler json_str = scaler.as_json() #print json_str scaler2 = XDSScalerA.from_json(string=json_str) scaler2.set_scaler_xcrystal(cryst) check_scaler_files_exist(scaler2) scaler2.set_scaler_finish_done(False) check_scaler_files_exist(scaler2) scaler2.set_scaler_done(False) check_scaler_files_exist(scaler2) scaler2._scalr_integraters = {} # XXX scaler2.add_scaler_integrater(integrater) scaler2.set_scaler_prepare_done(False) check_scaler_files_exist(scaler2)