def write_files(self, results, f_obs): if (self.params.mask_output): masks = [ results.mask_data_all, results.mask_data_omit, results.mask_data_polder ] filenames = ["all", "omit", "polder"] for mask_data, filename in zip(masks, filenames): ccp4_map.write_ccp4_map(file_name="mask_" + filename + ".ccp4", unit_cell=f_obs.unit_cell(), space_group=f_obs.space_group(), map_data=mask_data, labels=flex.std_string([""])) mtz_dataset = results.mc_polder.as_mtz_dataset( column_root_label="mFo-DFc_polder") mtz_dataset.add_miller_array(miller_array=results.mc_omit, column_root_label="mFo-DFc_omit") if (self.params.debug): mtz_dataset.add_miller_array(miller_array=results.mc_biased, column_root_label="mFo-DFc_bias_omit") mtz_object = mtz_dataset.mtz_object() polder_file_name = "polder_map_coeffs.mtz" if (self.params.output_file_name_prefix is not None): polder_file_name = self.params.output_file_name_prefix + "_" + polder_file_name mtz_object.write(file_name=polder_file_name) print('File %s was written.' % polder_file_name, file=self.logger)
def write_ccp4_map(map_data, cs, file_name): from iotbx import ccp4_map ccp4_map.write_ccp4_map(file_name=file_name, unit_cell=cs.unit_cell(), space_group=cs.space_group(), map_data=map_data, labels=flex.std_string([""]))
def write_map_box(self, box, filename): ccp4_map.write_ccp4_map( file_name=filename, unit_cell=box.xray_structure_box.unit_cell(), space_group=box.xray_structure_box.space_group(), map_data=box.map_box, labels=flex.std_string([""]))
def write_files(results, mask_output, debug, f_obs, prefix, log): # write mask files (if specified) if (mask_output): masks = [ results.mask_data_all, results.mask_data_omit, results.mask_data_polder ] filenames = ["all", "omit", "polder"] for mask_data, filename in zip(masks, filenames): ccp4_map.write_ccp4_map(file_name="mask_" + filename + ".ccp4", unit_cell=f_obs.unit_cell(), space_group=f_obs.space_group(), map_data=mask_data, labels=flex.std_string([""])) mtz_dataset = results.mc_polder.as_mtz_dataset( column_root_label="mFo-DFc_polder") # add map coeffs for biased map if debug=True if (debug): mtz_dataset.add_miller_array(miller_array=results.mc_biased, column_root_label="mFo-DFc_bias_omit") mtz_dataset.add_miller_array(miller_array=results.mc_omit, column_root_label="mFo-DFc_omit") mtz_object = mtz_dataset.mtz_object() polder_file_name = "polder_map_coeffs.mtz" if (prefix is not None): polder_file_name = prefix + "_" + polder_file_name mtz_object.write(file_name=polder_file_name) print >> log, 'File %s was written.' % polder_file_name
def output_map(f_obs, r_free_flags, xray_structure, mask_data, filename, params, log): f_calc = f_obs.structure_factors_from_scatterers( xray_structure=xray_structure).f_calc() mask = f_obs.structure_factors_from_map(map=mask_data, use_scale=True, anomalous_flag=False, use_sg=False) # is it really use_sg = false? fmodel = mmtbx.f_model.manager(f_obs=f_obs, r_free_flags=r_free_flags, f_calc=f_calc, f_mask=mask) fmodel.update_all_scales() print >> log, "r_work=%6.4f r_free=%6.4f" % (fmodel.r_work(), fmodel.r_free()) print >> log, "*" * 79 mc_diff = map_tools.electron_density_map(fmodel=fmodel).map_coefficients( map_type="mFo-DFc", isotropize=True, fill_missing=False) if (params.mask_output and filename != 'bias_omit'): ccp4_map.write_ccp4_map(file_name="mask_" + filename + ".ccp4", unit_cell=f_obs.unit_cell(), space_group=f_obs.space_group(), map_data=mask_data, labels=flex.std_string([""])) return mc_diff
def output_map(f_obs, r_free_flags, xray_structure, mask_data, filename, params, log): f_calc = f_obs.structure_factors_from_scatterers( xray_structure = xray_structure).f_calc() mask = f_obs.structure_factors_from_map( map = mask_data, use_scale = True, anomalous_flag = False, use_sg = False) # is it really use_sg = false? fmodel = mmtbx.f_model.manager( f_obs = f_obs, r_free_flags = r_free_flags, f_calc = f_calc, f_mask = mask) fmodel.update_all_scales() print >> log, "r_work=%6.4f r_free=%6.4f" % (fmodel.r_work(), fmodel.r_free()) print >> log, "*"*79 mc_diff = map_tools.electron_density_map( fmodel = fmodel).map_coefficients( map_type = "mFo-DFc", isotropize = True, fill_missing = False) if (params.mask_output and filename != 'bias_omit'): ccp4_map.write_ccp4_map( file_name = "mask_"+filename+".ccp4", unit_cell = f_obs.unit_cell(), space_group = f_obs.space_group(), map_data = mask_data, labels = flex.std_string([""])) return mc_diff
def write_ccp4_map(crystal_symmetry, file_name, map_data): from iotbx import ccp4_map ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=crystal_symmetry.unit_cell(), space_group=crystal_symmetry.space_group(), map_data=map_data, labels=flex.std_string([""]))
def write_ccp4_map(map_data, cs, file_name): from iotbx import ccp4_map ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=cs.unit_cell(), space_group=cs.space_group(), map_data=map_data, labels=flex.std_string([""]))
def ccp4_map(crystal_symmetry, file_name, map_data): from iotbx import ccp4_map ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=crystal_symmetry.unit_cell(), space_group=crystal_symmetry.space_group(), #gridding_first=(0,0,0),# This causes a bug (map gets shifted) #gridding_last=n_real, # This causes a bug (map gets shifted) map_data=map_data, labels=flex.std_string([""]))
def ccp4_map_type(map, N, radius, file_name='map.ccp4'): grid = flex.grid(N * 2 + 1, N * 2 + 1, N * 2 + 1) map.reshape(grid) ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=uctbx.unit_cell(" %s" % (radius * 2.0) * 3 + "90 90 90"), space_group=sgtbx.space_group_info("P1").group(), gridding_first=(0, 0, 0), gridding_last=(N * 2, N * 2, N * 2), map_data=map, labels=flex.std_string(["generated from zernike moments"]))
def write_local_map(self, input_map_data, filename_base, peak_object): #writes out map in std setting last_grid = peak_object.grid_last write_ccp4_map(file_name=filename_base + ".ccp4", unit_cell=peak_object.so4_xrs.unit_cell(), space_group=sgtbx.space_group_info("P1").group(), gridding_first=(0, 0, 0), gridding_last=(last_grid, last_grid, last_grid), map_data=input_map_data, labels=flex.std_string([ "local_map", ]))
def shift_map_to_zero_origin(target_map, cg, map_out, return_map=False): em_data = target_map.data.as_double() em_data = em_data.shift_origin() ccp4_map.write_ccp4_map( file_name=map_out, unit_cell=cg.unit_cell(), space_group=cg.space_group(), map_data=em_data, labels=flex.std_string([""])) if return_map is True: shifted_map = file_reader.any_file(map_out).file_object return em_data, shifted_map
def debug_write_ccp4_map(self, map_data, file_name): from iotbx import ccp4_map gridding_first = (0,0,0) gridding_last = map_data.all() labels = ["cctbx.miller.fft_map"] ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=self.fft_cell, space_group=sgtbx.space_group("P1"), gridding_first=gridding_first, gridding_last=gridding_last, map_data=map_data, labels=flex.std_string(labels))
def ccp4_map(cg, file_name, mc=None, map_data=None): assert [mc, map_data].count(None)==1 if(map_data is None): map_data = get_map(mc=mc, cg=cg) from iotbx import ccp4_map ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=cg.unit_cell(), space_group=cg.space_group(), #gridding_first=(0,0,0),# This causes a bug (map gets shifted) #gridding_last=n_real, # This causes a bug (map gets shifted) map_data=map_data, labels=flex.std_string([""]))
def main(filenames, map_file, npoints=192, max_resolution=6, reverse_phi=False): rec_range = 1 / max_resolution image = ImageFactory(filenames[0]) panel = image.get_detector()[0] beam = image.get_beam() s0 = beam.get_s0() pixel_size = panel.get_pixel_size() xlim, ylim = image.get_raw_data().all() xy = recviewer.get_target_pixels(panel, s0, xlim, ylim, max_resolution) s1 = panel.get_lab_coord(xy * pixel_size[0]) # FIXME: assumed square pixel s1 = s1 / s1.norms() * (1 / beam.get_wavelength()) # / is not supported... S = s1 - s0 grid = flex.double(flex.grid(npoints, npoints, npoints), 0) cnts = flex.int(flex.grid(npoints, npoints, npoints), 0) for filename in filenames: print "Processing image", filename try: fill_voxels(ImageFactory(filename), grid, cnts, S, xy, reverse_phi, rec_range) except: print " Failed to process. Skipped this." recviewer.normalize_voxels(grid, cnts) uc = uctbx.unit_cell((npoints, npoints, npoints, 90, 90, 90)) ccp4_map.write_ccp4_map(map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), grid.all(), grid, flex.std_string(["cctbx.miller.fft_map"])) return from scitbx import fftpack fft = fftpack.complex_to_complex_3d(grid.all()) grid_complex = flex.complex_double(reals=flex.pow2(grid), imags=flex.double(grid.size(), 0)) grid_transformed = flex.abs(fft.backward(grid_complex)) print flex.max(grid_transformed), flex.min( grid_transformed), grid_transformed.all() ccp4_map.write_ccp4_map(map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), grid.all(), grid_transformed, flex.std_string(["cctbx.miller.fft_map"]))
def debug_write_ccp4_map(self, map_data, file_name): from iotbx import ccp4_map gridding_first = (0, 0, 0) gridding_last = map_data.all() labels = ["cctbx.miller.fft_map"] ccp4_map.write_ccp4_map( file_name=file_name, unit_cell=self.fft_cell, space_group=sgtbx.space_group("P1"), gridding_first=gridding_first, gridding_last=gridding_last, map_data=map_data, labels=flex.std_string(labels), )
def run(self, args=None): # Parse the command line params, options = self.parser.parse_args(args, show_diff_phil=True) if not params.rs_mapper.map_file: raise RuntimeError("Please specify output map file (map_file=)") else: self.map_file = params.rs_mapper.map_file # Ensure we have either a data block or an experiment list self.experiments = flatten_experiments(params.input.experiments) if len(self.experiments) != 1: self.parser.print_help() print("Please pass either an experiment list\n") return self.reverse_phi = params.rs_mapper.reverse_phi self.grid_size = params.rs_mapper.grid_size self.max_resolution = params.rs_mapper.max_resolution self.ignore_mask = params.rs_mapper.ignore_mask self.grid = flex.double( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0 ) self.counts = flex.int( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0 ) for experiment in self.experiments: self.process_imageset(experiment.imageset) recviewer.normalize_voxels(self.grid, self.counts) # Let's use 1/(100A) as the unit so that the absolute numbers in the # "cell dimensions" field of the ccp4 map are typical for normal # MX maps. The values in 1/A would give the "cell dimensions" around # or below 1 and some MX programs would not handle it well. box_size = 100 * 2.0 / self.max_resolution uc = uctbx.unit_cell((box_size, box_size, box_size, 90, 90, 90)) ccp4_map.write_ccp4_map( self.map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), self.grid.all(), self.grid, flex.std_string(["cctbx.miller.fft_map"]), )
def run(self): from dials.util.command_line import Command from dials.util.options import flatten_datablocks # Parse the command line params, options = self.parser.parse_args(show_diff_phil=True) # Ensure we have a data block datablocks = flatten_datablocks(params.input.datablock) if len(datablocks) == 0: self.parser.print_help() return elif len(datablocks) != 1: raise RuntimeError("only 1 datablock can be processed at a time") if not params.rs_mapper.map_file: raise RuntimeError("Please specify output map file (map_file=)") else: self.map_file = params.rs_mapper.map_file self.datablocks = flatten_datablocks(params.input.datablock) if len(self.datablocks) == 0: self.parser.print_help() return self.reverse_phi = params.rs_mapper.reverse_phi self.grid_size = params.rs_mapper.grid_size self.max_resolution = params.rs_mapper.max_resolution self.grid = flex.double(flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) self.cnts = flex.int(flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) for datablock in self.datablocks: for imageset in datablock.extract_imagesets(): self.process_imageset(imageset) recviewer.normalize_voxels(self.grid, self.cnts) uc = uctbx.unit_cell((self.grid_size, self.grid_size, self.grid_size, 90, 90, 90)) ccp4_map.write_ccp4_map( self.map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), self.grid.all(), self.grid, flex.std_string(["cctbx.miller.fft_map"]), )
def run(self): from dials.util.options import flatten_datablocks # Parse the command line params, options = self.parser.parse_args(show_diff_phil=True) # Ensure we have a data block datablocks = flatten_datablocks(params.input.datablock) if len(datablocks) == 0: self.parser.print_help() return elif len(datablocks) != 1: raise RuntimeError('only 1 datablock can be processed at a time') if not params.rs_mapper.map_file: raise RuntimeError('Please specify output map file (map_file=)') else: self.map_file = params.rs_mapper.map_file self.datablocks = flatten_datablocks(params.input.datablock) if len(self.datablocks) == 0: self.parser.print_help() return self.reverse_phi = params.rs_mapper.reverse_phi self.grid_size = params.rs_mapper.grid_size self.max_resolution = params.rs_mapper.max_resolution self.grid = flex.double( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) self.cnts = flex.int( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) for datablock in self.datablocks: for imageset in datablock.extract_imagesets(): self.process_imageset(imageset) recviewer.normalize_voxels(self.grid, self.cnts) # Let's use 1/(100A) as the unit so that the absolute numbers in the # "cell dimensions" field of the ccp4 map are typical for normal # MX maps. The values in 1/A would give the "cell dimensions" around # or below 1 and some MX programs would not handle it well. box_size = 100 * 2.0 / self.max_resolution uc = uctbx.unit_cell((box_size, box_size, box_size, 90, 90, 90)) ccp4_map.write_ccp4_map(self.map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), self.grid.all(), self.grid, flex.std_string(["cctbx.miller.fft_map"]))
def run(self): from dials.util.command_line import Command from dials.util.options import flatten_datablocks # Parse the command line params, options = self.parser.parse_args(show_diff_phil=True) # Ensure we have a data block datablocks = flatten_datablocks(params.input.datablock) if len(datablocks) == 0: self.parser.print_help() return elif len(datablocks) != 1: raise RuntimeError('only 1 datablock can be processed at a time') if not params.rs_mapper.map_file: raise RuntimeError('Please specify output map file (map_file=)') else: self.map_file = params.rs_mapper.map_file self.datablocks = flatten_datablocks(params.input.datablock) if len(self.datablocks) == 0: self.parser.print_help() return self.reverse_phi = params.rs_mapper.reverse_phi self.grid_size = params.rs_mapper.grid_size self.max_resolution = params.rs_mapper.max_resolution self.grid = flex.double( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) self.cnts = flex.int( flex.grid(self.grid_size, self.grid_size, self.grid_size), 0) for datablock in self.datablocks: for imageset in datablock.extract_imagesets(): self.process_imageset(imageset) recviewer.normalize_voxels(self.grid, self.cnts) uc = uctbx.unit_cell( (self.grid_size, self.grid_size, self.grid_size, 90, 90, 90)) ccp4_map.write_ccp4_map(self.map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), self.grid.all(), self.grid, flex.std_string(["cctbx.miller.fft_map"]))
def main(filenames, map_file, npoints=192, max_resolution=6, reverse_phi=False): rec_range = 1 / max_resolution image = ImageFactory(filenames[0]) panel = image.get_detector()[0] beam = image.get_beam() s0 = beam.get_s0() pixel_size = panel.get_pixel_size() xlim, ylim = image.get_raw_data().all() xy = recviewer.get_target_pixels(panel, s0, xlim, ylim, max_resolution) s1 = panel.get_lab_coord(xy * pixel_size[0]) # FIXME: assumed square pixel s1 = s1 / s1.norms() * (1 / beam.get_wavelength()) # / is not supported... S = s1 - s0 grid = flex.double(flex.grid(npoints, npoints, npoints), 0) cnts = flex.int(flex.grid(npoints, npoints, npoints), 0) for filename in filenames: print "Processing image", filename try: fill_voxels(ImageFactory(filename), grid, cnts, S, xy, reverse_phi, rec_range) except: print " Failed to process. Skipped this." recviewer.normalize_voxels(grid, cnts) uc = uctbx.unit_cell((npoints, npoints, npoints, 90, 90, 90)) ccp4_map.write_ccp4_map(map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), grid.all(), grid, flex.std_string(["cctbx.miller.fft_map"])) return from scitbx import fftpack fft = fftpack.complex_to_complex_3d(grid.all()) grid_complex = flex.complex_double( reals=flex.pow2(grid), imags=flex.double(grid.size(), 0)) grid_transformed = flex.abs(fft.backward(grid_complex)) print flex.max(grid_transformed), flex.min(grid_transformed), grid_transformed.all() ccp4_map.write_ccp4_map(map_file, uc, sgtbx.space_group("P1"), (0, 0, 0), grid.all(), grid_transformed, flex.std_string(["cctbx.miller.fft_map"]))
def compute_model_map(xrs, target_map, symm, d_min, table, model_map_out): xrs.scattering_type_registry( d_min=d_min, table=table) fc = xrs.structure_factors(d_min=d_min).f_calc() cg = maptbx.crystal_gridding( unit_cell=symm.unit_cell(), space_group_info=symm.space_group_info(), pre_determined_n_real=target_map.data.all()) fc_map = fc.fft_map( crystal_gridding=cg).apply_sigma_scaling().real_map_unpadded() try: assert (fc_map.all() == fc_map.focus() == target_map.data.all()) except AssertionError: print "Different dimension of experimental and simulated model map." ccp4_map.write_ccp4_map( file_name=model_map_out, unit_cell=cg.unit_cell(), space_group=cg.space_group(), map_data=fc_map, labels=flex.std_string([""])) return cg, fc_map
def run(args, log=sys.stdout): """phenix.mtriage: Given map file and optionally model and half-map files compute map statistics. How to run: phenix.mtriage model_file_name=m.pdb map_file_name=m.map half_map_file_name_1=m1.map half_map_file_name_2=m2.map Optional: model_file_name=, half_map_file_name_1=, half_map_file_name_2= Feedback: [email protected] [email protected] """ assert len(locals().keys()) == 2 # intentional print >> log, "-" * 79 print >> log, run.__doc__ print >> log, "-" * 79 # Get inputs inputs = get_inputs(args=args, log=log, master_params=master_params) # Map map_data = inputs.map_data if (map_data is None): raise Sorry("Map is not defined.") # Model broadcast(m="Input model:", log=log) if (inputs.pdb_hierarchy is None): print >> log, "No model specified." else: inputs.pdb_hierarchy.show(level_id="chain") # Crystal symmetry broadcast(m="Box (unit cell) info:", log=log) if (inputs.crystal_symmetry is None): raise Sorry("Box (unit cell) parameters are not defined.") inputs.crystal_symmetry.show_summary(f=log) # task_obj = mmtbx.maps.mtriage.mtriage( map_data=inputs.map_data, crystal_symmetry=inputs.crystal_symmetry, params=inputs.params, half_map_data_1=inputs.half_map_data_1, half_map_data_2=inputs.half_map_data_2, pdb_hierarchy=inputs.pdb_hierarchy) task_obj.validate() task_obj.run() results = task_obj.get_results() # # Map statistics # broadcast(m="Map statistics:", log=log) print >> log, "Map:" print >> log, " origin: ", results.map_counts.origin print >> log, " last: ", results.map_counts.last print >> log, " focus: ", results.map_counts.focus print >> log, " all: ", results.map_counts.all print >> log, " min,max,mean:", results.map_counts.min_max_mean # print >> log, "Half-maps:" if (inputs.half_map_data_1 is None): print >> log, " Half-maps are not provided." else: for i, m in enumerate( [results.half_map_1_counts, results.half_map_2_counts]): print >> log, " half-map:", i + 1 print >> log, " origin:", m.origin print >> log, " last: ", m.last print >> log, " focus: ", m.focus print >> log, " all: ", m.all print >> log, " min,max,mean:", m.min_max_mean # print >> log, "Histogram(s) of map values:" show_histogram(map_histograms=results.map_histograms, log=log) # show results print >> log, "Map resolution estimates:" print >> log, " using map alone (d99) :", results.d99 print >> log, " comparing with model (d_model) :", results.d_model print >> log, " b_iso_overall :", results.b_iso_overall print >> log, " comparing with model (d_model_b0):", results.d_model_b0 print >> log, " b_iso_overall=0" print >> log, " d_fsc_model:" print >> log, " FSC(map,model map)=0 :", results.d_fsc_model_0 print >> log, " FSC(map,model map)=0.143 :", results.d_fsc_model_0143 print >> log, " FSC(map,model map)=0.5 :", results.d_fsc_model print >> log, " d99 (half map 1) :", results.d99_1 print >> log, " d99 (half map 2) :", results.d99_2 print >> log, " FSC(half map 1,2)=0.143 (d_fsc) :", results.d_fsc print >> log # print >> log, "Radius used for mask smoothing:", results.radius_smooth print >> log # file_name = "%s.mtriage.log" % inputs.params.fsc_model_plot_file_name_prefix task_obj.write_fsc_curve_model_plot_data(file_name=file_name) print >> log, "FSC(model map, map) is written to %s" % file_name # file_name = "%s.mtriage.log" % inputs.params.fsc_half_maps_file_name_prefix task_obj.write_fsc_curve_plot_data(file_name=file_name) print >> log, "FSC(half map 1, half map 1) is written to %s" % file_name # if (inputs.params.write_mask_file and results.mask is not None): print >> log, "Mask is written to %s" % inputs.params.mask_file_name ccp4_map.write_ccp4_map( file_name=inputs.params.mask_file_name, unit_cell=inputs.crystal_symmetry.unit_cell(), space_group=inputs.crystal_symmetry.space_group(), map_data=results.mask, labels=flex.std_string(["mask"])) # # required for GUI return results
def run(args, log=sys.stdout): """phenix.mtriage: Given map file and optionally model and half-map files compute map statistics. How to run: phenix.mtriage model_file_name=m.pdb map_file_name=m.map half_map_file_name_1=m1.map half_map_file_name_2=m2.map Optional: model_file_name=, half_map_file_name_1=, half_map_file_name_2= Feedback: [email protected] [email protected] """ assert len(locals().keys()) == 2 # intentional print >> log, "-" * 79 print >> log, run.__doc__ print >> log, "-" * 79 introspection.virtual_memory_info().show_if_available( out=null_out(), show_max=True) # just to initialize something # Get inputs inputs = get_inputs(args=args, log=log, master_params=master_params) # task_obj = mmtbx.maps.mtriage.mtriage(map_inp=inputs.map_inp, map_inp_1=inputs.map_inp_1, map_inp_2=inputs.map_inp_2, pdb_inp=inputs.pdb_inp, params=inputs.params) results = task_obj.get_results() # # Map statistics # broadcast(m="Map statistics:", log=log) print >> log, "Map:" print >> log, " origin: ", results.counts.origin print >> log, " last: ", results.counts.last print >> log, " focus: ", results.counts.focus print >> log, " all: ", results.counts.all print >> log, " min,max,mean:", results.counts.min_max_mean print >> log, " d_min_corner:", "%7.3f" % results.counts.d_min_corner # print >> log, "Half-maps:" if (inputs.map_inp_1 is None): print >> log, " Half-maps are not provided." # print >> log, "Histogram(s) of map values (masked):" show_histogram(map_histograms=results.histograms, log=log) # show results fv = format_value fs = "%8.2f" rm = results.masked ru = results.unmasked if ([rm, ru].count(None) == 0): print >> log, "Map resolution estimates: masked unmasked" print >> log, " using map alone (d99) :", fv( fs, rm.d99), fv(fs, ru.d99) print >> log, " using map alone (d9999) :", fv( fs, rm.d9999), fv(fs, ru.d9999) print >> log, " comparing with model (d_model) :", fv( fs, rm.d_model), fv(fs, ru.d_model) print >> log, " b_iso_overall :", fv( fs, rm.b_iso_overall), fv(fs, ru.b_iso_overall) print >> log, " comparing with model (d_model_b0):", fv( fs, rm.d_model_b0), fv(fs, ru.d_model_b0) print >> log, " b_iso_overall=0" print >> log, " d_fsc_model:" print >> log, " FSC(map,model map)=0 :", fv( fs, rm.d_fsc_model_0), fv(fs, ru.d_fsc_model_0) print >> log, " FSC(map,model map)=0.143 :", fv( fs, rm.d_fsc_model_0143), fv(fs, ru.d_fsc_model_0143) print >> log, " FSC(map,model map)=0.5 :", fv( fs, rm.d_fsc_model_05), fv(fs, ru.d_fsc_model_05) print >> log, " d99 (half map 1) :", fv( fs, rm.d99_1), fv(fs, ru.d99_1) print >> log, " d99 (half map 2) :", fv( fs, rm.d99_2), fv(fs, ru.d99_2) print >> log, " FSC(half map 1,2)=0.143 (d_fsc) :", fv( fs, rm.d_fsc), fv(fs, ru.d_fsc) print >> log # print >> log, "Radius used for mask smoothing:", format_value( "%6.2f", results.masked.radius_smooth) print >> log else: r = rm if (r is None): r = ru print >> log, "Map resolution estimates: masked unmasked" print >> log, " using map alone (d99) :", fv(fs, r.d99) print >> log, " using map alone (d9999) :", fv(fs, r.d9999) print >> log, " comparing with model (d_model) :", fv(fs, r.d_model) print >> log, " b_iso_overall :", fv( fs, r.b_iso_overall) print >> log, " comparing with model (d_model_b0):", fv( fs, r.d_model_b0) print >> log, " b_iso_overall=0" print >> log, " d_fsc_model:" print >> log, " FSC(map,model map)=0 :", fv( fs, r.d_fsc_model_0) print >> log, " FSC(map,model map)=0.143 :", fv( fs, r.d_fsc_model_0143) print >> log, " FSC(map,model map)=0.5 :", fv( fs, r.d_fsc_model_05) print >> log, " d99 (half map 1) :", fv(fs, r.d99_1) print >> log, " d99 (half map 2) :", fv(fs, r.d99_2) print >> log, " FSC(half map 1,2)=0.143 (d_fsc) :", fv(fs, r.d_fsc) print >> log # print >> log, "Radius used for mask smoothing:", format_value( "%s", str(r.radius_smooth)) print >> log # for r in [(results.masked, "masked"), (results.unmasked, "unmasked")]: if (r[0] is None): continue # FSC_model curve if (r[0].fsc_curve_model is not None): file_name = "%s.%s.mtriage.log" % ( inputs.params.fsc_model_plot_file_name_prefix, r[1]) of = open(file_name, "w") for a, b in zip(r[0].fsc_curve_model.d_inv, r[0].fsc_curve_model.fsc): print >> of, "%15.9f %15.9f" % (a, b) of.close() print >> log, "FSC(model map, map) is written to %s" % file_name # Mask if (inputs.params.write_mask_file and r[0].mask is not None): print >> log, "Mask is written to %s" % inputs.params.mask_file_name ccp4_map.write_ccp4_map( file_name=inputs.params.mask_file_name, unit_cell=inputs.crystal_symmetry.unit_cell(), space_group=inputs.crystal_symmetry.space_group(), map_data=r[0].mask, labels=flex.std_string(["mask"])) # FSC (half-maps) curve if (r[0].fsc_curve is not None): file_name = "%s.%s.mtriage.log" % ( inputs.params.fsc_half_maps_file_name_prefix, r[1]) of = open(file_name, "w") for a, b in zip(r[0].fsc_curve.fsc.d_inv, r[0].fsc_curve.fsc.fsc): print >> of, "%15.9f %15.9f" % (a, b) of.close() print >> log, "FSC(half map 1, half map 1) is written to %s" % file_name # return results # required for GUI