Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exploit improved CCTBX 'counting_sorted' binning algorithm #1130

Merged
merged 5 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions algorithms/symmetry/laue_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,14 @@ def _estimate_cc_sig_fac(self):
max_n_group = int(min(n_pairs / min_num_groups, 200)) # maximum number in group
min_n_group = int(min(5, max_n_group)) # minimum number in group

if (max_n_group - min_n_group) < 4:
self.cc_sig_fac = 0
return

mean_ccs = flex.double()
rms_ccs = flex.double()
ns = flex.double()
for n in range(min_n_group, max_n_group):
for n in range(min_n_group, max_n_group + 1):
ns.append(n)
ccs = flex.double()
for i in range(200):
Expand All @@ -149,8 +153,10 @@ def _estimate_cc_sig_fac(self):
y = rms_ccs
fit = flex.linear_regression(x, y)

assert fit.is_well_defined()
self.cc_sig_fac = fit.slope()
if fit.is_well_defined():
self.cc_sig_fac = fit.slope()
else:
self.cc_sig_fac = 0

def _estimate_cc_true(self):

Expand Down Expand Up @@ -262,7 +268,10 @@ def __str__(self):
"Estimated expectation value of true correlation coefficient E(CC) = %.3f"
% self.E_cc_true
)
output.append("Estimated sd(CC) = %.3f / sqrt(N)" % self.cc_sig_fac)
if self.cc_sig_fac:
output.append("Estimated sd(CC) = %.3f / sqrt(N)" % self.cc_sig_fac)
else:
output.append("Too few reflections to estimate sd(CC).")
output.append(
"Estimated E(CC) of true correlation coefficient from identity = %.3f"
% self.cc_true
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1130.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix an issue (#1097) whereby aggregating small numbers of reflections into resolution bins could sometimes result in empty bins and consequent errors.
6 changes: 5 additions & 1 deletion util/resolutionizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,12 @@ def miller_array_from_mtz(unmerged_mtz, params):
.expert_level = 2
nbins = 100
.type = int
.help = "Number of resolution bins to use for estimation of resolution limit."
.help = "Maximum number of resolution bins to use for estimation of resolution limit."
.short_caption = "Number of resolution bins."
.expert_level = 1
reflections_per_bin = 10
.type = int
.help = "Minimum number of reflections per bin."
binning_method = *counting_sorted volume
.type = choice
.help = "Use equal-volume bins or bins with approximately equal numbers of reflections per bin."
Expand Down Expand Up @@ -374,6 +377,7 @@ def __init__(self, i_obs, params, batches=None, reference=None):
self._merging_statistics = iotbx.merging_statistics.dataset_statistics(
i_obs=i_obs,
n_bins=self._params.nbins,
reflections_per_bin=self._params.reflections_per_bin,
cc_one_half_significance_level=self._params.cc_half_significance_level,
cc_one_half_method=self._params.cc_half_method,
binning_method=self._params.binning_method,
Expand Down