Exemplo n.º 1
0
 def _polishing(self):
     while True:
         if 0:  # Display map
             from crys3d.qttbx import map_viewer
             map_viewer.display(
                 fft_map=self.flipping_iterator.f_calc.fft_map(),
                 iso_level_positive_range_fraction=0.4)
         if self.normalisations:
             # if we have been working on normalised amplitudes
             # (i.e. in practice E's or quasi-E's, it is better to go back to
             # F's before polishing.
             # According to [6], a few cycles of charge flipping on those F's
             # before polishing improves map quality.
             self.flipping_iterator.denormalise(self.normalisations)
             skewness = flex.double()
             for i in xrange(
                     self.extra_iterations_on_f_after_phase_transition):
                 next(self.flipping_iterator)
                 skewness.append(self.flipping_iterator.rho_map.skewness())
                 if i < 3: continue
                 stats = scitbx.math.median_statistics(skewness[-3:])
                 if (stats.median_absolute_deviation <
                         self.map_skewness_stability_threshold):
                     break
         low_density_elimination = low_density_elimination_iterator(
             constant_rho_c=self.flipping_iterator.delta)
         low_density_elimination.start(f_obs=self.flipping_iterator.f_obs,
                                       phases=self.flipping_iterator.f_calc,
                                       f_000=0)
         for i in xrange(self.polishing_iterations):
             next(low_density_elimination)
         yield self.evaluating
Exemplo n.º 2
0
 def _polishing(self):
   while 1:
     if 0: # Display map
       from crys3d.qttbx import map_viewer
       map_viewer.display(fft_map=self.flipping_iterator.f_calc.fft_map(),
                          iso_level_positive_range_fraction=0.4)
     if self.normalisations:
       # if we have been working on normalised amplitudes
       # (i.e. in practice E's or quasi-E's, it is better to go back to
       # F's before polishing.
       # According to [6], a few cycles of charge flipping on those F's
       # before polishing improves map quality.
       self.flipping_iterator.denormalise(self.normalisations)
       skewness = flex.double()
       for i in xrange(self.extra_iterations_on_f_after_phase_transition):
         self.flipping_iterator.next()
         skewness.append(self.flipping_iterator.rho_map.skewness())
         if i < 3: continue
         stats = scitbx.math.median_statistics(skewness[-3:])
         if (stats.median_absolute_deviation
             < self.map_skewness_stability_threshold): break
     low_density_elimination = low_density_elimination_iterator(
       constant_rho_c=self.flipping_iterator.delta)
     low_density_elimination.start(f_obs=self.flipping_iterator.f_obs,
                                   phases=self.flipping_iterator.f_calc,
                                   f_000=0)
     for i in xrange(self.polishing_iterations):
       low_density_elimination.next()
     yield self.evaluating
Exemplo n.º 3
0
def f_calc_symmetrisations(f_obs, f_calc_in_p1, min_cc_peak_height):
  # The fast correlation map as per cctbx.translation_search.fast_nv1995
  # is computed and its peaks studied.
  # Inspiration from phenix.substructure.hyss for the parameters tuning.
  if 0: # Display f_calc_in_p1
    from crys3d.qttbx import map_viewer
    map_viewer.display(window_title="f_calc in P1 before fast CC",
                       fft_map=f_calc_in_p1.fft_map(),
                       iso_level_positive_range_fraction=0.8)

  crystal_gridding = f_obs.crystal_gridding(
    symmetry_flags=translation_search.symmetry_flags(
      is_isotropic_search_model=False,
      have_f_part=False),
    resolution_factor=1/3
  )
  correlation_map = translation_search.fast_nv1995(
    gridding=crystal_gridding.n_real(),
    space_group=f_obs.space_group(),
    anomalous_flag=f_obs.anomalous_flag(),
    miller_indices_f_obs=f_obs.indices(),
    f_obs=f_obs.data(),
    f_part=flex.complex_double(), ## no sub-structure is already fixed
    miller_indices_p1_f_calc=f_calc_in_p1.indices(),
    p1_f_calc=f_calc_in_p1.data()).target_map()

  if 0: # Display correlation_map
    from crys3d.qttbx import map_viewer
    map_viewer.display(window_title="Fast CC map",
                       raw_map=correlation_map,
                       unit_cell=f_calc_in_p1.unit_cell(),
                       positive_iso_level=0.8)

  search_parameters = maptbx.peak_search_parameters(
    peak_search_level=1,
    peak_cutoff=0.5,
    interpolate=True,
    min_distance_sym_equiv=1e-6,
    general_positions_only=False,
    min_cross_distance=f_obs.d_min()/2)
  ## The correlation map is not a miller.fft_map, just a 3D flex.double
  correlation_map_peaks = crystal_gridding.tags().peak_search(
    map=correlation_map,
    parameters=search_parameters)
  # iterate over the strong peak; for each, shift and symmetrised f_calc
  for peak in correlation_map_peaks:
    if peak.height < min_cc_peak_height: break
    sr = symmetry_search.shift_refinement(
      f_obs, f_calc_in_p1, peak.site)
    yield sr.symmetrised_shifted_sf.f_x, sr.shift, sr.goos.correlation
Exemplo n.º 4
0
def f_calc_symmetrisations(f_obs, f_calc_in_p1, min_cc_peak_height):
    # The fast correlation map as per cctbx.translation_search.fast_nv1995
    # is computed and its peaks studied.
    # Inspiration from phenix.substructure.hyss for the parameters tuning.
    if 0:  # Display f_calc_in_p1
        from crys3d.qttbx import map_viewer
        map_viewer.display(window_title="f_calc in P1 before fast CC",
                           fft_map=f_calc_in_p1.fft_map(),
                           iso_level_positive_range_fraction=0.8)

    crystal_gridding = f_obs.crystal_gridding(
        symmetry_flags=translation_search.symmetry_flags(
            is_isotropic_search_model=False, have_f_part=False),
        resolution_factor=1 / 3)
    correlation_map = translation_search.fast_nv1995(
        gridding=crystal_gridding.n_real(),
        space_group=f_obs.space_group(),
        anomalous_flag=f_obs.anomalous_flag(),
        miller_indices_f_obs=f_obs.indices(),
        f_obs=f_obs.data(),
        f_part=flex.complex_double(),  ## no sub-structure is already fixed
        miller_indices_p1_f_calc=f_calc_in_p1.indices(),
        p1_f_calc=f_calc_in_p1.data()).target_map()

    if 0:  # Display correlation_map
        from crys3d.qttbx import map_viewer
        map_viewer.display(window_title="Fast CC map",
                           raw_map=correlation_map,
                           unit_cell=f_calc_in_p1.unit_cell(),
                           positive_iso_level=0.8)

    search_parameters = maptbx.peak_search_parameters(
        peak_search_level=1,
        peak_cutoff=0.5,
        interpolate=True,
        min_distance_sym_equiv=1e-6,
        general_positions_only=False,
        min_cross_distance=f_obs.d_min() / 2)
    ## The correlation map is not a miller.fft_map, just a 3D flex.double
    correlation_map_peaks = crystal_gridding.tags().peak_search(
        map=correlation_map, parameters=search_parameters)
    # iterate over the strong peak; for each, shift and symmetrised f_calc
    for peak in correlation_map_peaks:
        if peak.height < min_cc_peak_height: break
        sr = symmetry_search.shift_refinement(f_obs, f_calc_in_p1, peak.site)
        yield sr.symmetrised_shifted_sf.f_x, sr.shift, sr.goos.correlation
Exemplo n.º 5
0
 def cross_correlation_peaks(self):
     f0 = self.f_in_p1
     for op in self.possible_point_group_generators():
         f, op_times_f = f0.common_sets(f0.change_basis(
             sgtbx.change_of_basis_op(op)),
                                        assert_is_similar_symmetry=False)
         #assert f.size() == f0.size()
         #XXX a better sanity check is needed here to check the amount of overlap
         #XXX between transformed indices
         cc_sf = f * op_times_f.conjugate().data() / f.sum_sq()
         cc_map = cc_sf.fft_map(
             symmetry_flags=maptbx.use_space_group_symmetry,
             resolution_factor=self.grid_resolution_factor)
         if 0:  # display 3D map
             from crys3d.qttbx import map_viewer
             map_viewer.display(window_title=op.as_xyz(),
                                fft_map=cc_map,
                                iso_level_positive_range_fraction=0.8,
                                wires=True,
                                orthographic=True)
         cc_map_peaks = cc_map.peak_search(self.search_parameters)
         peak = cc_map_peaks.next()
         yield (op.r(), mat.col(peak.site))
Exemplo n.º 6
0
 def cross_correlation_peaks(self):
   f0 = self.f_in_p1
   for op in self.possible_point_group_generators():
     f, op_times_f = f0.common_sets(
       f0.change_basis(sgtbx.change_of_basis_op(op)),
       assert_is_similar_symmetry=False)
     #assert f.size() == f0.size()
     #XXX a better sanity check is needed here to check the amount of overlap
     #XXX between transformed indices
     cc_sf = f * op_times_f.conjugate().data() / f.sum_sq()
     cc_map = cc_sf.fft_map(
       symmetry_flags=maptbx.use_space_group_symmetry,
       resolution_factor=self.grid_resolution_factor)
     if 0: # display 3D map
       from crys3d.qttbx import map_viewer
       map_viewer.display(window_title=op.as_xyz(),
                          fft_map = cc_map,
                          iso_level_positive_range_fraction=0.8,
                          wires=True,
                          orthographic=True)
     cc_map_peaks = cc_map.peak_search(self.search_parameters)
     peak = cc_map_peaks.next()
     yield (op.r(), mat.col(peak.site))