def drawIsoSurface(values3d, resolution=1., plot_center=None, viewer=None): from htmd.vmdviewer import getCurrentViewer from htmd.molecule.util import writeVoxels # plot_center should be - molecule.get_center() + 12 if len(values3d.shape) != 3: raise ValueError("Your provided a box of {} dimensions." "\nThis only works with dimension of 3".format( len(values3d.shape))) from htmd.util import tempname if viewer is None: viewer = getCurrentViewer() mincoor = np.zeros(3, dtype=np.float64) maxcoor = np.array(values3d.shape, dtype=np.float64) rescoor = np.array([resolution] * 3) # Adjust the plotting center if plot_center is None: plot_center = maxcoor / 2. else: plot_center = np.array(plot_center) mincoor -= (plot_center + 0.5 ) # TODO: Fix so it will work in case resolution != 1. maxcoor -= (plot_center + 0.5) outf = tempname(suffix='.cube') writeVoxels(values3d, outf, mincoor, maxcoor, rescoor) viewer.send( 'mol new {} type cube first 0 last -1 step 1 waitfor 1 volsets {{0 }}'. format(outf)) viewer.send('mol modstyle 0 top Isosurface 0.75 0 2 0 1 1')
def drawIsoSurface(values3d, resolution=1., plot_center=None, viewer=None): from htmd.vmdviewer import getCurrentViewer from htmd.molecule.util import writeVoxels # plot_center should be - molecule.get_center() + 12 if len(values3d.shape) != 3: raise ValueError("Your provided a box of {} dimensions." "\nThis only works with dimension of 3".format(len(values3d.shape))) from htmd.util import tempname if viewer is None: viewer = getCurrentViewer() mincoor = np.zeros(3, dtype=np.float64) maxcoor = np.array(values3d.shape, dtype=np.float64) rescoor = np.array([resolution] * 3) # Adjust the plotting center if plot_center is None: plot_center = maxcoor / 2. else: plot_center = np.array(plot_center) mincoor -= (plot_center + 0.5) # TODO: Fix so it will work in case resolution != 1. maxcoor -= (plot_center + 0.5) outf = tempname(suffix='.cube') writeVoxels(values3d, outf, mincoor, maxcoor, rescoor) viewer.send('mol new {} type cube first 0 last -1 step 1 waitfor 1 volsets {{0 }}'.format(outf)) viewer.send('mol modstyle 0 top Isosurface 0.75 0 2 0 1 1')
def volumetric_map(): sims = simlist(glob('data/*/'), glob('data/*/structure.pdb'), glob('input/*/')) sim_num = len(sims) for s in sims: print("\nSimulation", s.simid + 1, "of", sim_num) if s.simid == 0: (traj, traj_wat, ref_traj) = prepare_traject(s) (min_d, max_d) = define_extremes(traj_wat) else: (traj, traj_wat, ref_traj) = prepare_traject(s, ref_traj) traj_wat.moveBy([max_d / 2, max_d / 2, max_d / 2]) w_count = create_count_dict(min_d, max_d) avg_wat = calculate_occupancy(traj_wat, w_count, min_d, max_d) try: occup_all += avg_wat except NameError: occup_all = avg_wat occup_all = occup_all / sim_num occup_all += 1e-40 pot = chemical_pot(occup_all) writeVoxels(pot, "cubefile.cube", np.array([min_d, min_d, min_d]), np.array([max_d, max_d, max_d]), np.array([1, 1, 1])) print("\nVolumetric file created.\n") view_vmd(traj, max_d)
def isosurface_generator(grid, cubedistance,output): for x,y,z in itertools.product(*map(range, (grid.shape[0], grid.shape[1],grid.shape[2]))): prob = grid[x][y][z] if prob == 0: continue else: grid[x][y][z] = (np.log(grid[x][y][z])) * 0.001987191 * 298 * -1 print("Energy calculated!") min_vec= np.array([0,0,0]) max_vec=np.array([cubedistance,cubedistance,cubedistance]) res_vec=np.array([1,1,1]) writeVoxels(grid, output+'.cube', min_vec, max_vec, res_vec) print("Output file "+output+".cube generated on the current directory")
def isosurface_generator(grid, cubedistance, output): for x, y, z in itertools.product( *map(range, (grid.shape[0], grid.shape[1], grid.shape[2]))): prob = grid[x][y][z] if prob == 0: continue else: grid[x][y][z] = (np.log(grid[x][y][z])) * 0.001987191 * 298 * -1 print("Energy calculated!") min_vec = np.array([0, 0, 0]) max_vec = np.array([cubedistance, cubedistance, cubedistance]) res_vec = np.array([1, 1, 1]) writeVoxels(grid, output + '.cube', min_vec, max_vec, res_vec) print("Output file " + output + ".cube generated on the current directory")
def volumetric_map(): sims = simlist(glob('data/*/'), glob('data/*/structure.pdb'), glob('input/*/')) sim_num=len(sims) for s in sims: print("\nSimulation", s.simid +1, "of", sim_num) if s.simid == 0: (traj,traj_wat,ref_traj)=prepare_traject(s) (min_d,max_d)=define_extremes(traj_wat) else: (traj,traj_wat,ref_traj)=prepare_traject(s,ref_traj) traj_wat.moveBy([max_d/2,max_d/2,max_d/2]) w_count=create_count_dict(min_d,max_d) avg_wat = calculate_occupancy(traj_wat,w_count,min_d,max_d) try: occup_all += avg_wat except NameError: occup_all = avg_wat occup_all=occup_all/sim_num occup_all += 1e-40 pot=chemical_pot(occup_all) writeVoxels(pot,"cubefile.cube",np.array([min_d,min_d,min_d]),np.array([max_d,max_d,max_d]),np.array([1,1,1])) print("\nVolumetric file created.\n") view_vmd(traj,max_d)