本文整理汇总了Python中simtk.openmm.app.PDBFile.writeHeader方法的典型用法代码示例。如果您正苦于以下问题:Python PDBFile.writeHeader方法的具体用法?Python PDBFile.writeHeader怎么用?Python PDBFile.writeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simtk.openmm.app.PDBFile
的用法示例。
在下文中一共展示了PDBFile.writeHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: report
# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeHeader [as 别名]
def report(self, simulation, state):
"""Generate a report.
Parameters:
- simulation (Simulation) The Simulation to generate a report for
- state (State) The current state of the simulation
"""
if self._nextModel == 0:
PDBFile.writeHeader(simulation.topology, self._out)
self._topology = simulation.topology
self._nextModel += 1
PDBFile.writeModel(simulation.topology, state.getPositions(), self._out, self._nextModel)
self._nextModel += 1
示例2: report
# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeHeader [as 别名]
def report(self, simulation, state):
"""Generate a report.
Parameters
----------
simulation : Simulation
The Simulation to generate a report for
state : State
The current state of the simulation
"""
if self._nextModel == 0:
PDBFile.writeHeader(simulation.topology, self._out)
self._topology = simulation.topology
self._nextModel += 1
PDBFile.writeModel(simulation.topology, state.getPositions(), self._out, self._nextModel)
self._nextModel += 1
if hasattr(self._out, 'flush') and callable(self._out.flush):
self._out.flush()
示例3: report
# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeHeader [as 别名]
def report(self, simulation, _):
"""Generate a report.
Parameters
----------
simulation : Simulation
The Simulation to generate a report for
_ : State
The current state of the simulation
"""
state = simulation.context.getState(getPositions=True, enforcePeriodicBox=self._enforcePeriodicBox)
if self._nextModel == 0:
PDBFile.writeHeader(simulation.topology, self._out)
self._topology = simulation.topology
self._nextModel += 1
PDBFile.writeModel(simulation.topology, state.getPositions(), self._out, self._nextModel)
self._nextModel += 1
if hasattr(self._out, 'flush') and callable(self._out.flush):
self._out.flush()
示例4: integrate
# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeHeader [as 别名]
#.........这里部分代码省略.........
elif direction == 'delete':
for parameter_name in available_parameters:
context.setParameter(parameter_name, 1)
# Compute initial potential of alchemical state.
initial_potential = self.beta * context.getState(getEnergy=True).getPotentialEnergy()
if np.isnan(initial_potential):
raise NaNException("Initial potential of 'insert' operation is NaN (unmodified potential was %.3f kT, alchemical potential was %.3f kT before changing lambda)" % (unmodified_potential, alchemical_potential))
from perses.tests.utils import compute_potential_components
#print("initial potential before '%s' : %f kT" % (direction, initial_potential))
#print("initial potential components: %s" % str(compute_potential_components(context))) # DEBUG
# Take a single integrator step since all switching steps are unrolled in NCMCAlchemicalIntegrator.
try:
# Write PDB file if requested.
if self.write_pdb_interval:
if direction == 'insert':
topology = topology_proposal.new_topology
indices = topology_proposal.unique_new_atoms
else:
topology = topology_proposal.old_topology
indices = topology_proposal.unique_old_atoms
# Write atom indices that are changing
import pickle
filename = 'ncmc-%s-%d-atomindices.pkl' % (direction, self.nattempted)
outfile = open(filename, 'wb')
pickle.dump(indices, outfile)
outfile.close()
from simtk.openmm.app import PDBFile
filename = 'ncmc-%s-%d.pdb' % (direction, self.nattempted)
outfile = open(filename, 'w')
PDBFile.writeHeader(topology, file=outfile)
modelIndex = 0
PDBFile.writeModel(topology, context.getState(getPositions=True).getPositions(asNumpy=True), file=outfile, modelIndex=modelIndex)
try:
for step in range(self.nsteps):
integrator.step(1)
if (step+1)%self.write_pdb_interval == 0:
modelIndex += 1
PDBFile.writeModel(topology, context.getState(getPositions=True).getPositions(asNumpy=True), file=outfile, modelIndex=modelIndex)
except ValueError as e:
# System is exploding and coordinates won't fit in PDB ATOM fields
print(e)
PDBFile.writeFooter(topology, file=outfile)
outfile.close()
else:
integrator.step(self.nsteps)
except Exception as e:
# Trap NaNs as a special exception (allowing us to reject later, if desired)
if str(e) == "Particle coordinate is nan":
raise NaNException(str(e))
else:
raise e
# Set final context parameters.
if direction == 'insert':
for parameter_name in available_parameters:
context.setParameter(parameter_name, 1)
elif direction == 'delete':
for parameter_name in available_parameters:
context.setParameter(parameter_name, 0)
示例5: print
# 需要导入模块: from simtk.openmm.app import PDBFile [as 别名]
# 或者: from simtk.openmm.app.PDBFile import writeHeader [as 别名]
nsteps = 5 # number of timesteps per iteration
niterations = 500 # number of iterations
mctrials = 10 # number of Monte Carlo trials per iteration
nsalt = 0 # current number of salt pairs
tol = 1e-6 # constraint tolerance
# Determine number of molecules
nmolecules = 0
for residue in topology.residues():
nmolecules += 1
print('system originally has %d water molecules' % nmolecules)
# Open PDB file for writing.
from simtk.openmm.app import PDBFile
pdbfile = open('output.pdb', 'w')
PDBFile.writeHeader(topology, file=pdbfile)
PDBFile.writeModel(topology, positions, file=pdbfile, modelIndex=0)
# Simulate
for iteration in range(niterations):
print('iteration %5d / %5d' % (iteration, niterations))
# Create a simulation
from openmmtools.integrators import VelocityVerletIntegrator
integrator = VelocityVerletIntegrator(timestep)
integrator.setConstraintTolerance(tol)
context = openmm.Context(system, integrator)
context.setPositions(positions)
# Propagate dynamics at constant counterion number.
print('propagating dynamics for %d steps...' % nsteps)