Example results page: a box that overlaps a map by one plane

Ready. The one-plane box now keeps its plane; the proving test fails on the old code and passes on the new.

Still to do: commit the change (not committed yet); then, after the full test suite passes, push. The commits a push would publish are listed at the end of this page.

The changes

ChangeProblemNowStatus
1. A box that overlaps the map by one plane keeps that planeA box that shared only one grid plane with a non-wrapping map came out all zeros.Such a box keeps the values of that one plane and is zero elsewhere.not committed

1. A box that overlaps the map by one plane keeps that plane

Problem

Boxing a non-wrapping map with bounds that overlap it by exactly one grid plane gave a box of zeros.

Cause

get_bounds_of_valid_region marks the region empty with last_valid <= first_valid. With a one-plane overlap the first and last valid planes are the same, so a region of one plane counted as empty, and the whole box was zeroed.

Fix: how it solves the problem

The test is now last_valid < first_valid: a region is empty only when its last plane is before its first.

Essential code

    if last_valid <  first_valid:
      some_valid_points = False

What the tests show

Show the full change, tests and results

The full change

cctbx/maptbx/box.py (not committed)

@@ -1251,7 +1251,7 @@
     upper_allowed_bounds.append(last_valid)
     if f < o or l >=  a+o:
       inside_allowed_bounds = False
-    if last_valid <=  first_valid:
+    if last_valid <  first_valid:
       some_valid_points = False

   return group_args(

The new and changed tests

cctbx/regression/tst_maptbx_box.py (not committed)

@@ -300,7 +300,33 @@

   print ("OK")

+def exercise_box_overlapping_map_by_one_plane():
+  # A box that shares only one grid plane with the map keeps that plane
+  from cctbx import crystal
+  map_data = flex.double(flex.grid(10, 10, 10), 1.)
+  mm = map_manager(
+    unit_cell_grid             = map_data.all(),
+    unit_cell_crystal_symmetry = crystal.symmetry(
+      unit_cell = (10, 10, 10, 90, 90, 90), space_group_symbol = "P1"),
+    origin_shift_grid_units    = (0, 0, 0),
+    map_data                   = map_data,
+    wrapping                   = False)
+  # 1 x 4 x 4 points of the first two boxes are inside the map
+  for lower_bounds, upper_bounds, n_inside in (
+      ((9, 2, 2), (14, 5, 5), 16),   # last plane in x
+      ((-5, 2, 2), (0, 5, 5), 16),   # first plane in x
+      ((10, 2, 2), (14, 5, 5), 0)):  # just past the last plane
+    box = cctbx.maptbx.box.with_bounds(
+      map_manager  = mm.deep_copy(),
+      lower_bounds = lower_bounds,
+      upper_bounds = upper_bounds,
+      wrapping     = False)
+    assert box.map_manager().map_data().as_1d().count(1) == n_inside, \
+      (lower_bounds, upper_bounds)
+  print ("OK")
+
 if (__name__  ==  "__main__"):
+  exercise_box_overlapping_map_by_one_plane()
   if libtbx.env.has_module('phenix'):
     exercise_around_model()
   else:

What the tests printed (last lines)

tst_maptbx_box, old code (current minus the change): failed

AssertionError: ((9, 2, 2), (14, 5, 5))

tst_maptbx_box, new code (current): passed

New end:  [34, 39, 35]
lowest, highest out of box: -6 4
Reboxing cubic map to stay inside current map
lowest, highest out of box: 0 0
Final start:  [1, 6, 2]
Final end:  [30, 35, 31]
Final box:  [30, 30, 30]
OK

Commits and files

  • Repository: cctbx_project
  • Commits: none
  • Status: local
  • Files: cctbx/maptbx/box.py, cctbx/regression/tst_maptbx_box.py

The outside review

No outside review was run for this job; the report offers one.

How the changes were tested

Old-code runs load the job's saved copy of cctbx/maptbx/box.py from before the job.


Commits to push

Pushing these repositories publishes all of the commits below.

Found with git log origin/master..HEAD in each repository when this page was made.