本文整理汇总了Python中htmd.molecule.molecule.Molecule.box方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.box方法的具体用法?Python Molecule.box怎么用?Python Molecule.box使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htmd.molecule.molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.box方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: viewStates
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import box [as 别名]
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')
示例2: reconstructAdaptiveTraj
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import box [as 别名]
def reconstructAdaptiveTraj(simlist, trajID):
""" Reconstructs a long trajectory out of short adaptive runs.
Parameters
----------
simlist : numpy.ndarray of :class:`Sim <htmd.simlist.Sim>` objects
A simulation list generated by the :func:`simlist <htmd.simlist.simlist>` function
trajID : int
The id of the trajectory from which to start going back.
Returns
-------
mol : :class:`Molecule <htmd.molecule.molecule.Molecule>` object
A Molecule object containing the reconstructed trajectory
chain : np.ndarray
The simulation IDs of all simulations involved
pathlist : np.ndarray of str
The names of all simulations involved.
Examples
--------
>>> mol, chain, pathlist = reconstructAdaptiveTraj(data.simlist, 52)
"""
sim = None
for s in simlist:
if s.simid == trajID:
sim = s
break
if sim is None:
raise NameError('Could not find sim with ID {} in the simlist.'.format(trajID))
pathlist = []
pathlist.append(sim.trajectory[0])
chain = []
chain.append((sim, -1, -1))
epo = None
while epo != 1:
[sim, piece, frame, epo] = _findprevioustraj(simlist, _simName(sim.trajectory[0]))
pathlist.append(sim.trajectory[piece])
chain.append((sim, piece, frame))
pathlist = pathlist[::-1]
chain = chain[::-1]
mol = Molecule(sim.molfile)
mol.coords = np.zeros((mol.numAtoms, 3, 0), dtype=np.float32)
mol.fileloc = []
mol.box = np.zeros((3, 0))
for i, c in enumerate(chain):
tmpmol = Molecule(sim.molfile)
tmpmol.read(c[0].trajectory)
endpiece = c[1]
fileloc = np.vstack(tmpmol.fileloc)
filenames = fileloc[:, 0]
pieces = np.unique(filenames)
firstpieceframe = np.where(filenames == pieces[endpiece])[0][0]
endFrame = firstpieceframe + c[2]
if endFrame != -1:
tmpmol.coords = tmpmol.coords[:, :, 0:endFrame + 1] # Adding the actual respawned frame (+1) since the respawned sim doesn't include it in the xtc
tmpmol.fileloc = tmpmol.fileloc[0:endFrame + 1]
tmpmol.box = tmpmol.box[:, 0:endFrame + 1]
mol.coords = np.concatenate((mol.coords, tmpmol.coords), axis=2)
mol.box = np.concatenate((mol.box, tmpmol.box), axis=1)
mol.fileloc += tmpmol.fileloc
#mol.fileloc[:, 1] = range(np.size(mol.fileloc, 0))
return mol, chain, pathlist
示例3: home
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import box [as 别名]
if ext not in _WRITERS:
_WRITERS[ext] = MDTRAJwrite
if __name__ == '__main__':
from htmd.home import home
from htmd.molecule.molecule import Molecule, mol_equal
from htmd.util import tempname
import numpy as np
import os
testfolder = home(dataDir='metricdistance')
mol = Molecule(os.path.join(testfolder, 'filtered.pdb'))
mol.coords = np.tile(mol.coords, (1, 1, 2))
mol.filter('protein and resid 1 to 20')
mol.boxangles = np.ones((3, 2), dtype=np.float32) * 90
mol.box = np.ones((3, 2), dtype=np.float32) * 15
mol.step = np.arange(2)
mol.time = np.arange(2) * 1E5
for ext in _WRITERS:
tmp = tempname(suffix='.'+ext)
mol.write(tmp)
print('Can write {} files'.format(ext))
# from difflib import Differ
# d = Differ()
#
# with open(tmp, 'rb') as f1, open(a, 'rb') as f2:
# res = d.compare([x.decode('utf8') for x in f1.readlines()], [x.decode('utf8') for x in f2.readlines()])
#