Skip to content

Commit e248cb3

Browse files
committed
fix cube file grid ordering bug, resize_grid point_tree bug & Bq atom validation
The meshgrid in the density code path used default 'xy' indexing which produced (z-slow, x-mid, y-fast) ordering, mismatching the cube file's (x-slow, y-mid, z-fast) density storage. This scrambled occupied grid point positions, giving correct Mol_Vol but wrong %V_Bur. Fixed by using indexing='ij' with .reshape(3,-1).T. Also fixed resize_grid not returning an updated point_tree (sphere volume error ~6% for cube files), and allowed Bq ghost atoms through the VDW radii validation check so --sambvca works when atom1 is H. Adds benzene and Ne test cube files at coarse/medium/fine resolutions.
1 parent b987e30 commit e248cb3

9 files changed

Lines changed: 1497151 additions & 292 deletions

File tree

dbstep/Dbstep.py

Lines changed: 192 additions & 277 deletions
Large diffs are not rendered by default.

dbstep/parse_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def read_input(molecule, ext, options):
2828
DataParser object with parsed molecule data to be used by the rest of the program
2929
"""
3030
if ext == ".cube":
31-
options.surface = "density"
3231
mol = CubeParser(molecule, "cube")
3332
else:
3433
if ext in [".xyz", ".com", ".gjf"]:

dbstep/sterics.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,11 @@ def occupied(grid, coords, radii, origin, options):
143143
for n in range(len(coords)):
144144
center = coords[n] + origin
145145
idx.append(point_tree.query_ball_point(center, radii[n], workers=-1))
146-
# construct a list of indices of the grid array that are occupied / unoccupied
146+
# construct a list of indices of the grid array that are occupied
147147
jdx = [y for x in idx for y in x]
148-
if options.qsar:
149-
kdx = [i for i in range(len(grid)) if i not in jdx]
150148

151149
# removes duplicates since a voxel can only be occupied once
152150
jdx = list(set(jdx))
153-
if options.qsar:
154-
kdx = list(set(kdx))
155-
onehot = np.zeros(len(grid))
156-
onehot[jdx] = 1.0
157151

158152
if options.verbose:
159153
print(" There are {} occupied grid points.".format(len(jdx)))
@@ -167,13 +161,8 @@ def occupied(grid, coords, radii, origin, options):
167161

168162
u = pptk.viewer(grid)
169163
v = pptk.viewer(grid[jdx])
170-
if options.qsar:
171-
w = pptk.viewer(grid[kdx])
172164

173-
if options.qsar:
174-
return grid[jdx], grid[kdx], onehot, point_tree
175-
else:
176-
return grid[jdx], point_tree, occ_vol
165+
return grid[jdx], point_tree, occ_vol
177166

178167

179168
def occupied_dens(grid, dens, options):
@@ -239,8 +228,9 @@ def resize_grid(x_max, y_max, z_max, x_min, y_min, z_min, options, mol):
239228
y_vals = np.linspace(y_min, y_max, mol.ydim)
240229
z_vals = np.linspace(z_min, z_max, mol.zdim)
241230
grid = np.array(np.meshgrid(x_vals, y_vals, z_vals)).T.reshape(-1, 3)
231+
point_tree = spatial.cKDTree(grid, balanced_tree=False, compact_nodes=False)
242232

243-
return grid
233+
return grid, point_tree
244234

245235

246236
def get_classic_sterimol(coords, radii, atoms):

tests/cube_files/Ne.xyz

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
Ne
3+
Ne 1.219400 -0.165200 2.160000

tests/cube_files/Ne_medium.cube

Lines changed: 24343 additions & 0 deletions
Large diffs are not rendered by default.

tests/cube_files/benzene.xyz

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
12
2+
benzene
3+
H -2.426483 0.480591 -0.000006
4+
C -1.364235 0.27023 0.000002
5+
C -0.916128 -1.046358 0.000005
6+
H -1.62943 -1.861106 0.000002
7+
C 0.448089 -1.31655 -0.000008
8+
H 0.797011 -2.341683 -0.00002
9+
C 1.364252 -0.270207 0.000012
10+
H 2.426484 -0.480624 -0.000005
11+
C 0.916127 1.046345 -0.000005
12+
H 1.629476 1.861062 0.000001
13+
C -0.448107 1.316554 0.000001
14+
H -0.797041 2.341678 -0.000018

tests/cube_files/benzene_coarse.cube

Lines changed: 21578 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)