def run_scaling(params, experiments, reflections): """Run scaling algorithms; stats only, cross validation or standard.""" if params.stats_only: Script.stats_only(reflections, experiments, params) sys.exit() if params.export_mtz_only: Script.export_mtz_only(reflections, experiments, params) sys.exit() if params.output.delete_integration_shoeboxes: for r in reflections: del r["shoebox"] if params.cross_validation.cross_validation_mode: from dials.algorithms.scaling.cross_validation.cross_validate import ( cross_validate, ) from dials.algorithms.scaling.cross_validation.crossvalidator import ( DialsScaleCrossValidator, ) cross_validator = DialsScaleCrossValidator(experiments, reflections) try: cross_validate(params, cross_validator) except ValueError as e: raise Sorry(e) logger.info( "Cross validation analysis does not produce scaling output files, rather\n" "it gives insight into the dataset. Choose an appropriate parameterisation\n" "and rerun scaling without cross_validation_mode.\n" ) else: script = Script(params, experiments, reflections) # Register the observers at the highest level if params.output.html: register_default_scaling_observers(script) else: register_merging_stats_observers(script) if params.filtering.method: if script.scaler.id_ != "multi": raise Sorry( """ Scaling and filtering can only be performed in multi-dataset scaling mode (not single dataset or scaling against a reference)""" ) register_scale_and_filter_observers(script) script.run_scale_and_filter() with open(params.filtering.output.scale_and_filter_results, "w") as f: json.dump(script.filtering_results.to_dict(), f, indent=2) else: script.run() script.export()
def run_script(self, params, config_no): """Run the scaling script with the params, get the free/work set results and add to the results dict""" from dials.command_line.scale import Script params.scaling_options.__setattr__("use_free_set", True) script = Script( params, experiments=deepcopy(self.experiments), reflections=deepcopy(self.reflections), ) register_merging_stats_observers(script) script.run() results = self.get_results_from_script(script) self.add_results_to_results_dict(config_no, results)
def run_scaling(params, experiments, reflections): """Run scaling algorithms; cross validation, scaling + filtering or standard. Returns: experiments: an experiment list with scaled data (if created) joint_table: a single reflection table containing scaled data (if created). """ if params.output.delete_integration_shoeboxes: for r in reflections: del r["shoebox"] if params.cross_validation.cross_validation_mode: from dials.algorithms.scaling.cross_validation.cross_validate import ( cross_validate, ) from dials.algorithms.scaling.cross_validation.crossvalidator import ( DialsScaleCrossValidator, ) cross_validator = DialsScaleCrossValidator(experiments, reflections) cross_validate(params, cross_validator) logger.info( "Cross validation analysis does not produce scaling output files, rather\n" "it gives insight into the dataset. Choose an appropriate parameterisation\n" "and rerun scaling without cross_validation_mode.\n") return (None, None) else: # Register the observers at the highest level if params.filtering.method: algorithm = ScaleAndFilterAlgorithm(params, experiments, reflections) register_scale_and_filter_observers(algorithm) else: algorithm = ScalingAlgorithm(params, experiments, reflections) if params.output.html: register_default_scaling_observers(algorithm) else: register_merging_stats_observers(algorithm) algorithm.run() experiments, joint_table = algorithm.finish() return experiments, joint_table