Skip to content

Commit

Permalink
solvent mask: update cctbx-compatible option
Browse files Browse the repository at this point in the history
rprobe (solvent_radius in cctbx) was changed from 1.11 to 1.1 in Dec 2021
cctbx/cctbx_project@2243cc9

and add more tests
  • Loading branch information
wojdyr committed Nov 11, 2023
1 parent d8eee02 commit e548e58
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/grid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ The parameters of SolventMasker can be inspected and changed:
>>> masker.atomic_radii_set
<AtomicRadiiSet.Cctbx: 1>
>>> masker.rprobe
1.11
1.1
>>> masker.rshrink
0.9
>>> masker.island_min_volume # 0 = unused
Expand Down
8 changes: 6 additions & 2 deletions examples/maskcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,24 @@ def maskcheck(mask_path, coor_path, output_diff_map=None, verbose=False):
grid2.copy_metadata_from(grid)
masker.put_mask_on_int8_grid(grid2, st[0])

compare_mask_arrays(grid, grid2)
compare_mask_arrays(grid, grid2, verbose)
if verbose:
print_nearby_atoms(st, grid, grid2)
if output_diff_map:
write_diff_map(grid, grid2, output_diff_map)


def compare_mask_arrays(grid1, grid2):
def compare_mask_arrays(grid1, grid2, verbose):
arr1 = numpy.array(grid1, copy=False)
arr2 = numpy.array(grid2, copy=False)
if arr1.shape != arr2.shape:
sys.exit('Different grid sizes %s and %s. Exiting.' %
(arr1.shape, arr2.shape))
print('Size: %d x %d x %d,' % arr1.shape, 'total', arr1.size, 'points')
if (arr1 == arr2).all():
print("Identical.")
if not verbose:
return
t = 2 * (arr1 != 0) + (arr2 != 0)
print('File-Gemmi Count Fraction')
for (a, b) in [(0, 0), (1, 1), (0, 1), (1, 0)]:
Expand Down
2 changes: 1 addition & 1 deletion include/gemmi/solmask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct SolventMasker {
island_min_volume = 0.;
break;
case AtomicRadiiSet::Cctbx:
rprobe = 1.11;
rprobe = 1.1;
rshrink = 0.9;
island_min_volume = 0.;
break;
Expand Down
14 changes: 13 additions & 1 deletion run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

# I use this script for building, testing and updating docs.

Expand Down Expand Up @@ -144,3 +144,15 @@ if [ $1 = w -o $1 = a ]; then
(cd wasm/mtz && ./compile.sh)
(cd ../wasm/convert && make clean && make)
fi

if [ $1 = M -o $1 = a ]; then
echo "check bulk solvent mask against cctbx"
for code in 1keb 1mru 5oo5 6dd6; do
echo Testing mask for $code ...
pdb="${PDB_DIR}/structures/divided/pdb/${code:1:2}/pdb${code}.ent.gz"
zcat $pdb > /tmp/file.pdb
mmtbx.python -m mmtbx.command_line.mask /tmp/file.pdb
$PYTHON examples/maskcheck.py mask.ccp4 /tmp/file.pdb
/bin/rm mask.ccp4
done
fi
8 changes: 4 additions & 4 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def test_maskcheck(self):
Generating CCTBX-compatible mask ...
Size: 72 x 72 x 150, total 777600 points
File-Gemmi Count Fraction
0-0 511128 65.73%
1-1 265740 34.17%
0-1 0 0.00%
1-0 732 0.09%
0-0 509676 65.54%
1-1 265788 34.18%
0-1 1452 0.19%
1-0 684 0.09%
'''
self.assertEqual(output.splitlines(), expected_output.splitlines())

Expand Down

0 comments on commit e548e58

Please sign in to comment.