本文整理汇总了Python中htmd.molecule.molecule.Molecule.dropFrames方法的典型用法代码示例。如果您正苦于以下问题:Python Molecule.dropFrames方法的具体用法?Python Molecule.dropFrames怎么用?Python Molecule.dropFrames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类htmd.molecule.molecule.Molecule
的用法示例。
在下文中一共展示了Molecule.dropFrames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _writeInputsFunction
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import dropFrames [as 别名]
def _writeInputsFunction(i, f, epoch, inputpath, coorname):
regex = re.compile('(e\d+s\d+)_')
frameNum = f.frame
piece = f.piece
if f.sim.parent is None:
currSim = f.sim
else:
currSim = f.sim.parent
traj = currSim.trajectory[piece]
if currSim.input is None:
raise NameError('Could not find input folder in simulation lists. Cannot create new simulations.')
wuName = _simName(traj)
res = regex.search(wuName)
if res: # If we are running on top of adaptive, use the first name part for the next sim name
wuName = res.group(1)
# create new job directory
newName = 'e' + str(epoch) + 's' + str(i + 1) + '_' + wuName + 'p' + str(piece) + 'f' + str(frameNum)
newDir = path.join(inputpath, newName, '')
# copy previous input directory including input files
copytree(currSim.input, newDir, symlinks=False, ignore=ignore_patterns('*.coor', '*.rst', '*.out', *_IGNORE_EXTENSIONS))
# overwrite input file with new one. frameNum + 1 as catdcd does 1 based indexing
mol = Molecule(currSim.molfile) # Always read the mol file, otherwise it does not work if we need to save a PDB as coorname
mol.read(traj)
mol.dropFrames(keep=frameNum) # Making sure only specific frame to write is kept
mol.write(path.join(newDir, coorname))
示例2: _viewStatesNGL
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import dropFrames [as 别名]
def _viewStatesNGL(self, states, statetype, protein, ligand, mols, numsamples, gui=False):
from htmd.molecule.util import sequenceID
if states is None:
states = range(self.macronum)
if isinstance(states, int):
states = [states]
if mols is None:
mols = self.getStates(states, statetype, numsamples=min(numsamples, 15))
colors = [0, 1, 3, 4, 5, 6, 7, 9]
hexcolors = {0: '#0000ff', 1: '#ff0000', 2: '#333333', 3: '#ff6600', 4: '#ffff00', 5: '#4c4d00', 6: '#b2b2cc',
7: '#33cc33', 8: '#ffffff', 9: '#ff3399', 10: '#33ccff'}
if protein is None and ligand is None:
raise NameError('Please provide either the "protein" or "ligand" parameter for viewStates.')
k = 0
from nglview import NGLWidget, HTMDTrajectory
view = NGLWidget(gui=gui)
ref = mols[0].copy()
for i, s in enumerate(states):
if protein:
mol = Molecule()
if ligand:
mol = ref.copy()
mol.remove(ligand, _logger=False)
mol.dropFrames(keep=0)
mols[i].filter(ligand, _logger=False)
mols[i].set('chain', '{}'.format(s))
tmpcoo = mols[i].coords
for j in range(mols[i].numFrames):
mols[i].coords = np.atleast_3d(tmpcoo[:, :, j])
if ligand:
mols[i].set('segid', sequenceID(mols[i].resid)+k)
k = int(mols[i].segid[-1])
mol.append(mols[i])
view.add_trajectory(HTMDTrajectory(mol))
# Setting up representations
if ligand:
view[i].add_cartoon('protein', color='sstruc')
view[i].add_hyperball(':{}'.format(s), color=hexcolors[np.mod(i, len(hexcolors))])
if protein:
view[i].add_cartoon('protein', color='residueindex')
self._nglButtons(view, statetype, states)
return view
示例3: DataFrame
# 需要导入模块: from htmd.molecule.molecule import Molecule [as 别名]
# 或者: from htmd.molecule.molecule.Molecule import dropFrames [as 别名]
from pandas import DataFrame
types = []
indexes = []
description = []
for i in atomidx:
types += ['SASA']
indexes += [i]
description += ['SASA of {} {} {}'.format(mol.resname[i], mol.resid[i], mol.name[i])]
return DataFrame({'type': types, 'atomIndexes': indexes, 'description': description})
if __name__ == '__name__':
from htmd.molecule.molecule import Molecule
from htmd.home import home
from os import path
import numpy as np
mol = Molecule(path.join(home(), 'data', 'metricdistance', 'filtered.pdb'))
mol.read(path.join(home(), 'data', 'metricdistance', 'traj.xtc'))
mol.dropFrames(keep=[0, 1]) # Keep only two frames cause it's super slow
metr = MetricSasa(mode='atom')
sasaA = metr.project(mol)
metr = MetricSasa(mode='residue')
sasaR = metr.project(mol)
sasaA_ref = np.load(path.join(home(), 'data', 'test-metrics', 'metricsasa', 'sasaA.npy'))
sasaR_ref = np.load(path.join(home(), 'data', 'test-metrics', 'metricsasa', 'sasaR.npy'))
assert np.array_equal(sasaA, sasaA_ref)
assert np.array_equal(sasaR, sasaR_ref)