def test_dilate_points(self): shape = (9, 8, 7) vol = volume.zeros(shape, voxelspacing=1, origin=(1,0,0)) dilate_points(np.asarray([[1, 0, 0]]), np.asarray([1]), vol) answer = volume.zeros(shape, voxelspacing=1, origin=(1,0,0)) answer.array[0, 0, 0] = 1 answer.array[0, 0, 1] = 1 answer.array[0, 0, -1] = 1 answer.array[0, 1, 0] = 1 answer.array[0, -1, 0] = 1 answer.array[1, 0, 0] = 1 answer.array[-1, 0, 0] = 1 self.assertTrue(np.allclose(answer.array, vol.array))
def rsurface(points, radius, shape, voxelspacing): dimensions = [x*voxelspacing for x in shape] origin = volume_origin(points, dimensions) rsurf = volume.zeros(shape, voxelspacing, origin) rsurf = dilate_points(points, radius, rsurf) return rsurf
print(pdbs[2 * n + 1], pdbs[2 * n]) try: p1 = PDB.fromfile(pdbs[2 * n + 1]) p2 = PDB.fromfile(pdbs[2 * n]) shape = grid_shape(p1.coor, p2.coor, VOXELSPACING) vdw_radii = p1.vdw_radius radii = vdw_radii + 3.0 rsurf = rsurface(p1.coor, radii, shape, VOXELSPACING) rcore = rsurface(p1.coor, vdw_radii, shape, VOXELSPACING) lsurf = rsurf.duplicate() lsurf._array.fill(0) lsurf = dilate_points(p2.coor, p2.vdw_radius, lsurf) #rsurf.tofile('rsurf.mrc') #rcore.tofile('rcore.mrc') #lsurf.tofile('lsurf.mrc') overlap = (rsurf.array * lsurf.array).sum() clash = (rcore.array * lsurf.array).sum() overlaps.append(overlap) cores.append(clash) print(pdbs[2 * n][:4]) print('overlap: ', overlap) print('clash: ', clash) print() except:
print(pdbs[2 * n + 1], pdbs[2 * n]) try: p1 = PDB.fromfile(pdbs[2 * n + 1]) p2 = PDB.fromfile(pdbs[2 * n]) shape = grid_shape(p1.coor, p2.coor, VOXELSPACING) vdw_radii = p1.vdw_radius radii = vdw_radii + 3.0 rsurf = rsurface(p1.coor, radii, shape, VOXELSPACING) rcore = rsurface(p1.coor, vdw_radii, shape, VOXELSPACING) lsurf = rsurf.duplicate() lsurf._array.fill(0) lsurf = dilate_points(p2.coor, p2.vdw_radius, lsurf) # rsurf.tofile('rsurf.mrc') # rcore.tofile('rcore.mrc') # lsurf.tofile('lsurf.mrc') overlap = (rsurf.array * lsurf.array).sum() clash = (rcore.array * lsurf.array).sum() overlaps.append(overlap) cores.append(clash) print(pdbs[2 * n][:4]) print("overlap: ", overlap) print("clash: ", clash) print() except:
def _initialize(self): # check if requirements are set if any(x is None for x in (self.receptor, self.ligand)): raise ValueError("Not all requirements are met for a search") if self.weights is None: self.weights = np.ones(self.rotations.shape[0], dtype=np.float64) if len(self.weights) != len(self.rotations): raise ValueError("") d = self.data # determine size for grid shape = grid_shape(self.receptor.coor, self.ligand.coor, self.voxelspacing) # calculate the interaction surface and core of the receptor vdw_radii = self.receptor.vdw_radius radii = vdw_radii + self.interaction_radius d['rsurf'] = rsurface(self.receptor.coor, radii, shape, self.voxelspacing) d['rcore'] = rsurface(self.receptor.coor, vdw_radii, shape, self.voxelspacing) # keep track of some data for later calculations d['origin'] = np.asarray(d['rcore'].origin, dtype=np.float64) d['shape'] = d['rcore'].shape d['start'] = d['rcore'].start d['nrot'] = self.rotations.shape[0] # set ligand center to the origin of the receptor map # and make a grid of the ligand radii = self.ligand.vdw_radius d['lsurf'] = dilate_points((self.ligand.coor - self.ligand.center \ + self.receptor.center), radii, volume.zeros_like(d['rcore'])) d['im_center'] = np.asarray((self.receptor.center - d['rcore'].origin)/self.voxelspacing, dtype=np.float64) d['max_clash'] = self.max_clash/self.voxelspacing**3 d['min_interaction'] = self.min_interaction/self.voxelspacing**3 # SAXS data d['q'] = self._q d['targetIq'] = self._Iq d['sq'] = self._sq if self.coarse_grain: e1, xyz1 = coarse_grain(self.receptor, bpr=self.beads_per_residue) e2, xyz2 = coarse_grain(self.ligand, bpr=self.beads_per_residue) else: e1, xyz1 = self.receptor.elements, self.receptor.coor e2, xyz2 = self.ligand.elements, self.ligand.coor d['base_Iq'] = scattering_curve(self._q, e1, xyz1, bpr=self.beads_per_residue) d['base_Iq'] += scattering_curve(self._q, e2, xyz2, bpr=self.beads_per_residue) d['fifj'], d['rind'], d['lind'] = create_fifj_lookup_table(d['q'], e1, e2, bpr=self.beads_per_residue) d['rxyz'] = xyz1 d['lxyz'] = xyz2 - self.ligand.center d['chi2'] = np.zeros(d['rcore'].shape, dtype=np.float64) d['best_chi2'] = np.zeros_like(d['chi2'])