コード例 #1
0
def exercise_split_unmerged():
  import random
  random.seed(42)
  flex.set_random_seed(42)

  from cctbx import crystal
  base_set = miller.build_set(
    crystal_symmetry=crystal.symmetry(
      unit_cell=(10,10,10,90,90,90), space_group_symbol="P1"),
    d_min=1.6,
    anomalous_flag=False)
  indices = base_set.indices()
  assert (len(indices) == 510)
  unmerged_hkl = flex.miller_index()
  unmerged_data = flex.double()
  unmerged_sigmas = flex.double()
  redundancies = flex.size_t()
  # XXX grossly overengineered, but I wanted to get a realistic CC to make sure
  # the reflections are being split properly
  for i, hkl in enumerate(indices):
    n_obs = min(8, 1 + i % 12)
    redundancies.append(n_obs)
    intensity_merged = (510 - i) + (510 % 27)
    for j in range(n_obs):
      unmerged_hkl.append(hkl)
      intensity = intensity_merged + 20 * (510 % (7 * (j+1)))
      sigma = max(0.5, i % 10)
      unmerged_data.append(intensity)
      unmerged_sigmas.append(sigma)
  assert (unmerged_hkl.size() == 2877)
  unmerged_array = miller.set(
    crystal_symmetry=base_set,
    indices=unmerged_hkl,
    anomalous_flag=False).array(data=unmerged_data, sigmas=unmerged_sigmas)
  split = miller.split_unmerged(
    unmerged_indices=unmerged_hkl,
    unmerged_data=unmerged_data,
    unmerged_sigmas=unmerged_sigmas)
  assert (split.data_1.size() == split.data_2.size() == 467)
  cc = miller.compute_cc_one_half(unmerged_array)
  assert approx_equal(cc, 0.861, eps=0.001)
  unmerged_array.setup_binner(n_bins=10)
  unmerged_array.set_observation_type_xray_intensity()
  result = unmerged_array.cc_one_half(use_binning=True)
  assert approx_equal(
    result.data[1:-1],
    [0.549, 0.789, 0.843, 0.835, 0.863, 0.860, 0.893, 0.847, 0.875, 0.859],
    eps=0.05)
コード例 #2
0
def exercise_split_unmerged () :
  import random
  random.seed(42)
  flex.set_random_seed(42)

  from cctbx import crystal
  base_set = miller.build_set(
    crystal_symmetry=crystal.symmetry(
      unit_cell=(10,10,10,90,90,90), space_group_symbol="P1"),
    d_min=1.6,
    anomalous_flag=False)
  indices = base_set.indices()
  assert (len(indices) == 510)
  unmerged_hkl = flex.miller_index()
  unmerged_data = flex.double()
  unmerged_sigmas = flex.double()
  redundancies = flex.size_t()
  # XXX grossly overengineered, but I wanted to get a realistic CC to make sure
  # the reflections are being split properly
  for i, hkl in enumerate(indices) :
    n_obs = min(8, 1 + i % 12)
    redundancies.append(n_obs)
    intensity_merged = (510 - i) + (510 % 27)
    for j in range(n_obs) :
      unmerged_hkl.append(hkl)
      intensity = intensity_merged + 20 * (510 % (7 * (j+1)))
      sigma = max(0.5, i % 10)
      unmerged_data.append(intensity)
      unmerged_sigmas.append(sigma)
  assert (unmerged_hkl.size() == 2877)
  unmerged_array = miller.set(
    crystal_symmetry=base_set,
    indices=unmerged_hkl,
    anomalous_flag=False).array(data=unmerged_data, sigmas=unmerged_sigmas)
  split = miller.split_unmerged(
    unmerged_indices=unmerged_hkl,
    unmerged_data=unmerged_data,
    unmerged_sigmas=unmerged_sigmas)
  assert (split.data_1.size() == split.data_2.size() == 467)
  cc = miller.compute_cc_one_half(unmerged_array)
  assert approx_equal(cc, 0.861, eps=0.001)
  unmerged_array.setup_binner(n_bins=10)
  unmerged_array.set_observation_type_xray_intensity()
  result = unmerged_array.cc_one_half(use_binning=True)
  assert approx_equal(
    result.data[1:-1],
    [0.549, 0.789, 0.843, 0.835, 0.863, 0.860, 0.893, 0.847, 0.875, 0.859],
    eps=0.05)
コード例 #3
0
def fast_merging_stats(array):
    """
    Quickly calculate required merging stats for intensity combination.

    This is a cut-down version of iobtx.merging_statistics.merging_stats.
    """
    assert array.sigmas() is not None
    positive_sel = array.sigmas() > 0
    array = array.select(positive_sel)
    array = array.sort("packed_indices")
    merge_ext = miller_ext.merge_equivalents_obs(array.indices(),
                                                 array.data(),
                                                 array.sigmas(),
                                                 use_internal_variance=True)
    r_meas = merge_ext.r_meas
    cc_one_half = miller.compute_cc_one_half(unmerged=array,
                                             return_n_refl=False)
    return r_meas, cc_one_half