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 __init__(self, xyz, color='red', radius=1): """ Displays a sphere in VMD. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- xyz : list The center of the sphere color : str Color of the sphere radius : float The radius of the sphere """ super().__init__(xyz) #self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw sphere "{} {} {}" radius {}\n'.format( xyz[0], xyz[1], xyz[2], radius)) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format( self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def viewStates(self, states=None, statetype='macro', protein=None, ligand=None, viewer=None, mols=None, numsamples=50): """ Visualize macro/micro/cluster states in VMD Parameters ---------- states : ndarray, optional A list of states to visualize statetype : ['macro','micro','cluster'], optional The type of state to visualize protein : bool, optional Set to True to enable pure protein system visualization ligand : str, optional Atomselection string for the ligand viewer : :class:`VMD <htmd.vmdviewer.VMD>` object, optional A viewer in which to visualize the states mols : ndarray, optional An array of :class:`Molecule <htmd.molecule.molecule.Molecule>` objects to visualize numsamples : int Number of samples (conformations) for each state. Examples -------- >>> model = Model(data) >>> model.markovModel(100, 5) >>> model.viewStates(protein=True) >>> model.viewStates(ligand='resname MOL') """ from htmd.config import _config self._integrityCheck(postmsm=(statetype != 'cluster')) if _config['viewer'].lower() == 'ngl': return self._viewStatesNGL(states, statetype, protein, ligand, mols, numsamples) if viewer is None: viewer = getCurrentViewer() if states is None: states = range(self.macronum) if isinstance(states, int): states = [states] if mols is None: mols = self.getStates(states, statetype, numsamples=numsamples) colors = [0, 1, 3, 4, 5, 6, 7, 9] for i, s in enumerate(states): viewer.loadMol(mols[i], name=statetype + ' ' + str(states[i])) if ligand is not None: viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))]) if protein is not None: viewer.rep('protein') viewer.send('start_sscache')
def __init__(self, arr, vecMin, vecRes, color=8, isovalue=0.5): """ Displays an isosurface in VMD The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- arr: np.ndarray 3D array with volumetric data. vecMin: np.ndarray 3D vector denoting the minimal corner of the grid vecRes: np.ndarray 3D vector denoting the resolution of the grid in each dimension color: str The color to be used for the isosurface """ super().__init__(arr) from htmd.util import tempname import numpy as np import os filename = tempname(suffix='.cube') outFile = open(filename, 'w') # conversion to gaussian units L = 1 / 0.52917725 gauss_bin = vecRes * L # minCorner = 0.5*L*(vecMin - vecMax + vecRes) minCorner = L * (vecMin + 0.5 * vecRes) ngrid = arr.shape # write header outFile.write("CUBE FILE\n") outFile.write("OUTER LOOP: X, MIDDLE LOOP: Y, INNER LOOP: Z\n") outFile.write("%5d %12.6f %12.6f %12.6f\n" % (1, minCorner[0], minCorner[1], minCorner[2])) outFile.write("%5d %12.6f %12.6f %12.6f\n" % (ngrid[0], gauss_bin[0], 0, 0)) outFile.write("%5d %12.6f %12.6f %12.6f\n" % (ngrid[1], 0, gauss_bin[1], 0)) outFile.write("%5d %12.6f %12.6f %12.6f\n" % (ngrid[2], 0, 0, gauss_bin[2])) outFile.write("%5d %12.6f %12.6f %12.6f %12.6f\n" % (1, 0, minCorner[0], minCorner[1], minCorner[2])) # main loop cont = 0 for i in range(ngrid[0]): for j in range(ngrid[1]): for k in range(ngrid[2]): outFile.write("%13.5g" % arr[i][j][k]) if np.mod(cont, 6) == 5: outFile.write("\n") cont += 1 outFile.close() vmd = getCurrentViewer() vmd.send('mol new {} type cube first 0 last -1 step 1 waitfor 1 volsets {{0 }}'.format(filename)) vmd.send('mol modstyle top top Isosurface {} 0 2 0 2 1'.format(isovalue)) vmd.send('mol modcolor top top ColorID {}'.format(color)) vmd.send('set htmd_graphics_mol({:d}) [molinfo top]'.format(self.n)) os.unlink(filename)
def __init__(self, text, xyz, color='red'): """ Displays a text in VMD. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- text : str The text xyz : list The position of the text color : str Color of the text """ super().__init__(xyz) self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw text "{} {} {}" "{}"\n'.format( xyz[0], xyz[1], xyz[2], text)) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format( self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def drawCube(mi, ma, viewer=None): from htmd.vmdviewer import getCurrentViewer if viewer is None: viewer = getCurrentViewer() viewer.send('draw materials off') viewer.send('draw color red') c = '' c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], ma[0], mi[1], mi[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], mi[0], ma[1], mi[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], mi[0], mi[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], mi[1], mi[2], ma[0], ma[1], mi[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], mi[1], mi[2], ma[0], mi[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], ma[1], mi[2], ma[0], ma[1], mi[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], ma[1], mi[2], mi[0], ma[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], ma[2], ma[0], mi[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], ma[2], mi[0], ma[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], ma[0], ma[1], mi[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], mi[0], ma[1], ma[2]) c += 'draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], ma[0], mi[1], ma[2]) viewer.send(c) """
def viewStates(self, states=None, statetype='macro', protein=None, ligand=None, viewer=None, mols=None, numsamples=50, wrapsel='protein', alignsel='name CA', gui=False, simlist=None): """ Visualize macro/micro/cluster states in VMD Parameters ---------- states : ndarray, optional A list of states to visualize statetype : ['macro','micro','cluster'], optional The type of state to visualize protein : bool, optional Set to True to enable pure protein system visualization ligand : str, optional Atom selection string for the ligand. See more `here <http://www.ks.uiuc.edu/Research/vmd/vmd-1.9.2/ug/node89.html>`__ viewer : :class:`VMD <htmd.vmdviewer.VMD>` object, optional A viewer in which to visualize the states mols : ndarray, optional An array of :class:`Molecule <htmd.molecule.molecule.Molecule>` objects to visualize numsamples : int Number of samples (conformations) for each state. wrapsel : str, optional, default='protein' Atom selection string to use for wrapping. See more `here <http://www.ks.uiuc.edu/Research/vmd/vmd-1.9.2/ug/node89.html>`__ alignsel : str, optional, default='name CA' Atom selection string used for aligning all frames. See to None to disable aligning. See more `here <http://www.ks.uiuc.edu/Research/vmd/vmd-1.9.2/ug/node89.html>`__ simlist : numpy.ndarray of :class:`Sim <htmd.simlist.Sim>` objects Optionally pass a different (but matching, i.e. filtered) simlist for visualizing the states. Examples -------- >>> model = Model(data) >>> model.markovModel(100, 5) >>> model.viewStates(protein=True) >>> model.viewStates(ligand='resname MOL') """ from htmd.config import _config self._integrityCheck(postmsm=(statetype != 'cluster')) if _config['viewer'].lower() == 'ngl' or _config['viewer'].lower() == 'webgl': return self._viewStatesNGL(states, statetype, protein, ligand, mols, numsamples, gui=gui) if viewer is None: viewer = getCurrentViewer() if states is None: states = range(self.macronum) if isinstance(states, int): states = [states] if mols is None: mols = self.getStates(states, statetype, numsamples=numsamples, wrapsel=wrapsel, alignsel=alignsel, simlist=simlist) colors = [0, 1, 3, 4, 5, 6, 7, 9] for i, s in enumerate(states): viewer.loadMol(mols[i], name=statetype+' '+str(states[i])) if ligand is not None: viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))]) if protein is not None: viewer.rep('protein') viewer.send('start_sscache')
def __init__(self, m, style="", preamble="", solid=False): """Display the convex hull of the given molecule. For preamble and color, see http://www.ks.uiuc.edu/Research/vmd/vmd-1.9.2/ug/node129.html The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- m: Molecule The object of which to show the hull (only 1 frame) style: str Style for wireframe lines preamble: str Commands (material, color) to be prefixed to the output. E.g.: "draw color red; graphics top materials on; graphics top material Transparent". Note that this affects later preamble-less commands. solid: bool Solid or wireframe Examples -------- >>> m=Molecule("3PTB") >>> m.view() >>> mf=m.copy() >>> mf.filter("protein ") >>> gh=htmd.vmdgraphics.VMDConvexHull(mf) # doctest: +ELLIPSIS >>> gh.delete() """ from scipy.spatial import ConvexHull if m.coords.shape[2] != 1: raise Exception("Only one frame is supported") cc = m.coords[:, :, 0] hull = ConvexHull(cc) super().__init__(hull) self.script.write(preamble + "\n") for i in range(hull.nsimplex): v1, v2, v3 = hull.simplices[i, :] c1s = VMDGraphicObject.tq(cc[v1, :]) c2s = VMDGraphicObject.tq(cc[v2, :]) c3s = VMDGraphicObject.tq(cc[v3, :]) if solid: self._remember("draw triangle {:s} {:s} {:s}".format(c1s, c2s, c3s)) else: self._remember("draw line {:s} {:s} {:s}".format(c1s, c2s, style)) self._remember("draw line {:s} {:s} {:s}".format(c1s, c3s, style)) self._remember("draw line {:s} {:s} {:s}".format(c2s, c3s, style)) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format(self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def viewStates(self, states=None, statetype='macro', protein=None, ligand=None, viewer=None, mols=None, numsamples=50, wrapsel='protein', alignsel='name CA', gui=False, simlist=None): """ Visualize macro/micro/cluster states in VMD Parameters ---------- states : ndarray, optional A list of states to visualize statetype : ['macro','micro','cluster'], optional The type of state to visualize protein : bool, optional Set to True to enable pure protein system visualization ligand : str, optional Atomselection string for the ligand viewer : :class:`VMD <htmd.vmdviewer.VMD>` object, optional A viewer in which to visualize the states mols : ndarray, optional An array of :class:`Molecule <htmd.molecule.molecule.Molecule>` objects to visualize numsamples : int Number of samples (conformations) for each state. wrapsel : str, optional, default='protein' A selection to use for wrapping alignsel : str, optional, default='name CA' A selection used for aligning all frames simlist : simlist Optionally pass a different (but matching, i.e. filtered) simlist for visualizing the states. Examples -------- >>> model = Model(data) >>> model.markovModel(100, 5) >>> model.viewStates(protein=True) >>> model.viewStates(ligand='resname MOL') """ from htmd.config import _config self._integrityCheck(postmsm=(statetype != 'cluster')) if _config['viewer'].lower() == 'ngl': return self._viewStatesNGL(states, statetype, protein, ligand, mols, numsamples, gui=gui) if viewer is None: viewer = getCurrentViewer() if states is None: states = range(self.macronum) if isinstance(states, int): states = [states] if mols is None: mols = self.getStates(states, statetype, numsamples=numsamples, wrapsel=wrapsel, alignsel=alignsel, simlist=simlist) colors = [0, 1, 3, 4, 5, 6, 7, 9] for i, s in enumerate(states): viewer.loadMol(mols[i], name=statetype+' '+str(states[i])) if ligand is not None: viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))]) if protein is not None: viewer.rep('protein') viewer.send('start_sscache')
def _prepareViewer(mol, ligandsel): mol.view(sel='protein', style='lines', hold=True) mol.view(sel=ligandsel, style='licorice', hold=True) mol.view() viewer = getCurrentViewer() viewer.send('draw color red') viewer.send('color Display Background black') viewer.send('draw materials off') return viewer
def __init__(self, box, color='red'): """ Displays a box in VMD as lines of its edges. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- box : list The min and max positions of the edges. Given as [xmin, xmax, ymin, ymax, zmin, zmax] color : str Color of the lines """ super().__init__(box) xmin, xmax, ymin, ymax, zmin, zmax = box mi = [xmin, ymin, zmin] ma = [xmax, ymax, zmax] self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], mi[1], mi[2], ma[0], mi[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], mi[1], mi[2], mi[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], mi[1], mi[2], mi[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( ma[0], mi[1], mi[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( ma[0], mi[1], mi[2], ma[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], ma[1], mi[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], ma[1], mi[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], mi[1], ma[2], ma[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( mi[0], mi[1], ma[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( ma[0], ma[1], ma[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( ma[0], ma[1], ma[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format( ma[0], ma[1], ma[2], ma[0], mi[1], ma[2])) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format( self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def _drawForce(start, vec): assert start.ndim == 1 and vec.ndim == 1 from htmd.vmdviewer import getCurrentViewer vmd = getCurrentViewer() vmd.send(""" proc vmd_draw_arrow {start end} { # an arrow is made of a cylinder and a cone draw color green set middle [vecadd $start [vecscale 0.9 [vecsub $end $start]]] graphics top cylinder $start $middle radius 0.15 graphics top cone $middle $end radius 0.25 } """) vmd.send('vmd_draw_arrow {{ {} }} {{ {} }}'.format(' '.join(map(str, start)), ' '.join(map(str, start + vec))))
def __init__(self, mol, selection, molid='top', textsize=0.5, textcolor='green'): """ Displays labels on atoms in VMD. Examples -------- >>> from htmd.ui import * >>> from htmd.vmdgraphics import * >>> mol = Molecule('3ptb') >>> mol.view() >>> x = VMDLabels(mol, 'resid 40') >>> y = VMDLabels(mol, 'resid 50') >>> y.delete() >>> x.delete() """ # TODO: After deleting labels it breaks. Better don't delete or fix the code super().__init__(None) print(VMDLabels.count) idx = mol.atomselect(selection, indexes=True) cmd = '''label textsize {s} color Labels Atoms {c} set molnum [molinfo {molid}] set i {start} foreach n [list {idx}] {{ label add Atoms $molnum/$n label textformat Atoms $i {{%a}} incr i }}'''.format(s=textsize, c=textcolor, sel=selection, molid=molid, idx=' '.join(map(str, idx)), start=VMDLabels.count) self.labelidx = list(range(VMDLabels.count, VMDLabels.count + len(idx))) VMDLabels.count += len(idx) vmd = getCurrentViewer() vmd.send(cmd)
def viewStates(self, protein=None, ligand=None, nsamples=20): from htmd.projections.metric import _singleMolfile from htmd.molecule.molecule import Molecule from htmd.vmdviewer import getCurrentViewer (single, molfile) = _singleMolfile(self.data.simlist) if not single: raise RuntimeError('Can' 't visualize states without unique molfile') viewer = getCurrentViewer() colors = [0, 1, 3, 4, 5, 6, 7, 9] print('Active set includes macrostates: {}'.format( self.hmm.active_set)) # dtraj = np.vstack(self.hmm.discrete_trajectories_full) res = self.hmm.sample_by_observation_probabilities(nsamples) refmol = Molecule(molfile) for i, s in enumerate(self.hmm.active_set): mol = Molecule(molfile) mol.coords = [] mol.box = [] # idx = np.where(dtraj == i)[0] # samples = np.random.choice(idx, 20) # frames = self.data.abs2sim(samples) frames = self.data.rel2sim(res[i]) for f in frames: mol._readTraj(f.sim.trajectory[f.piece], frames=[f.frame], append=True) mol.wrap('protein') mol.align('protein', refmol=refmol) viewer.loadMol(mol, name='hmm macro ' + str(s)) if ligand is not None: viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))]) if protein is not None: viewer.rep('protein') viewer.send('start_sscache')
def __init__(self, box, color='red'): """ Displays a box in VMD as lines of its edges. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- box : list The min and max positions of the edges. Given as [xmin, xmax, ymin, ymax, zmin, zmax] color : str Color of the lines """ super().__init__(box) xmin, xmax, ymin, ymax, zmin, zmax = box mi = [xmin, ymin, zmin] ma = [xmax, ymax, zmax] self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], ma[0], mi[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], mi[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], mi[2], mi[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], mi[1], mi[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], mi[1], mi[2], ma[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], ma[1], mi[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], ma[1], mi[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], ma[2], ma[0], mi[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(mi[0], mi[1], ma[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], ma[0], ma[1], mi[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], mi[0], ma[1], ma[2])) self._remember('draw line "{} {} {}" "{} {} {}"\n'.format(ma[0], ma[1], ma[2], ma[0], mi[1], ma[2])) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format(self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def __init__(self, text, xyz, color='red'): """ Displays a text in VMD. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- text : str The text xyz : list The position of the text color : str Color of the text """ super().__init__(xyz) self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw text "{} {} {}" "{}"\n'.format(xyz[0], xyz[1], xyz[2], text)) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format(self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def __init__(self, xyz, color='red', radius=1): """ Displays a sphere in VMD. The function returns an instance of VMDGraphicsObject. To delete it, use the delete() method. Parameters ---------- xyz : list The center of the sphere color : str Color of the sphere radius : float The radius of the sphere """ super().__init__(xyz) #self._remember('draw materials off') self._remember('draw color {}'.format(color)) self._remember('draw sphere "{} {} {}" radius {}\n'.format(xyz[0], xyz[1], xyz[2], radius)) self.script.write("\n") self.script.write("set htmd_graphics_mol({:d}) [molinfo top]".format(self.n)) cmd = self.script.getvalue() vmd = getCurrentViewer() vmd.send(cmd)
def viewStates(self, protein=None, ligand=None, nsamples=20): from htmd.projections.metric import _singleMolfile from htmd.molecule.molecule import Molecule from htmd.vmdviewer import getCurrentViewer (single, molfile) = _singleMolfile(self.data.simlist) if not single: raise RuntimeError('Can''t visualize states without unique molfile') viewer = getCurrentViewer() colors = [0, 1, 3, 4, 5, 6, 7, 9] print('Active set includes macrostates: {}'.format(self.hmm.active_set)) # dtraj = np.vstack(self.hmm.discrete_trajectories_full) res = self.hmm.sample_by_observation_probabilities(nsamples) refmol = Molecule(molfile) for i, s in enumerate(self.hmm.active_set): mol = Molecule(molfile) mol.coords = [] mol.box = [] # idx = np.where(dtraj == i)[0] # samples = np.random.choice(idx, 20) # frames = self.data.abs2sim(samples) frames = self.data.rel2sim(res[i]) for f in frames: mol._readTraj(f.sim.trajectory[f.piece], frames=[f.frame], append=True) mol.wrap('protein') mol.align('protein', refmol=refmol) viewer.loadMol(mol, name='hmm macro ' + str(s)) if ligand is not None: viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))]) if protein is not None: viewer.rep('protein') viewer.send('start_sscache')
def delete(self): vmd = getCurrentViewer() for i in self.labelidx[::-1]: vmd.send('label delete Atoms {}'.format(i)) VMDLabels.count -= 1
def delete(self): vmd = getCurrentViewer() vmd.send('mol delete htmd_graphics_mol({:d})'.format(self.n))