示例#1
0
# This program reads a trajecory and calculates the average
# configuration, which is then visualized. This is not a particularly
# useful operation, but it illustrates the use of trajectories and
# configuration variables.
#
# Note: In order to create the trajectory file "bala1.nc" which is
#       read by this example, you must run the example
#       MolecularDynamics/protein.py!
#

from MMTK import *
from MMTK.Trajectory import Trajectory
from MMTK.Visualization import view

# Open the input trajectory.
trajectory = Trajectory(None, 'bala1.nc')
universe = trajectory.universe

# Create a zeroed particle vector object.
sum = ParticleVector(universe)

# Loop over all steps and add the configurations to the sum.
for configuration in trajectory.configuration:
    sum = sum + configuration

# Divide by the number of steps.
sum = sum/len(trajectory)

# Visualize the average.
view(universe, sum)
示例#2
0
文件: modes.py 项目: torkos/MMTK
# Standard normal mode calculation.
#

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ForceFields import Amber94ForceField
from MMTK.NormalModes import VibrationalModes
from MMTK.Minimization import ConjugateGradientMinimizer
from MMTK.Trajectory import StandardLogOutput
from MMTK.Visualization import view

# Construct system
universe = InfiniteUniverse(Amber94ForceField())
universe.protein = Protein('bala1')

# Minimize
minimizer = ConjugateGradientMinimizer(universe,
                                       actions=[StandardLogOutput(50)])
minimizer(convergence = 1.e-3, steps = 10000)

# Calculate normal modes
modes = VibrationalModes(universe)

# Print frequencies
for mode in modes:
    print(f"{mode}")

# Show animation of the first non-trivial mode 
view(modes[6])
示例#3
0
from MMTK.Visualization import view
import pylab

# Construct system
universe = InfiniteUniverse(CalphaForceField(2.5))
universe.protein = Protein('insulin.pdb', model='calpha')

# Find a reasonable basis set size and cutoff
nbasis = max(10, universe.numberOfAtoms() / 5)
cutoff, nbasis = estimateCutoff(universe, nbasis)
print(f"Calculating {nbasis} low-frequency modes.")

if cutoff is None:
    # Do full normal mode calculation
    modes = EnergeticModes(universe, 300. * Units.K)
else:
    # Do subspace mode calculation with Fourier basis
    subspace = FourierBasis(universe, cutoff)
    modes = EnergeticModes(universe, 300. * Units.K, subspace)

# Plot the atomic fluctuations in the first three non-zero modes
# for chain A
chain = universe.protein[0]
pylab.xticks(range(len(chain)), [r.name for r in chain])
for i in range(6, 9):
    f = modes[i] * modes[i]
    pylab.plot([f[residue.peptide.C_alpha] for residue in chain])

# Show animation of the first non-trivial mode
view(modes[6], 15.)
示例#4
0
# Standard normal mode calculation.
#

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ForceFields import Amber94ForceField
from MMTK.NormalModes import VibrationalModes
from MMTK.Minimization import ConjugateGradientMinimizer
from MMTK.Trajectory import StandardLogOutput
from MMTK.Visualization import view

# Construct system
universe = InfiniteUniverse(Amber94ForceField())
universe.protein = Protein('bala1')

# Minimize
minimizer = ConjugateGradientMinimizer(universe,
                                       actions=[StandardLogOutput(50)])
minimizer(convergence = 1.e-3, steps = 10000)

# Calculate normal modes
modes = VibrationalModes(universe)

# Print frequencies
for mode in modes:
    print mode

# Show animation of the first non-trivial mode 
view(modes[6])
示例#5
0
文件: protein.py 项目: torkos/MMTK
        TranslationRemover(0, None, 50),
        # Remove global rotation every 50 steps.
        RotationRemover(0, None, 50),
        # Write every second step to the trajectory file.
        TrajectoryOutput(trajectory,
                         ("time", "energy", "thermodynamic", "configuration"),
                         0, None, 2),
        # Write restart data every fifth step.
        RestartTrajectoryOutput("restart.nc", 5),
        # Log output to screen every 10 steps.
        StandardLogOutput(10)
    ])
trajectory.close()

# Print information about the trajectory file
print("Information about the trajectory file 'bala1.nc':")
print(f"{trajectoryInfo('bala1.nc')}")

# Reopen trajectory file
trajectory = Trajectory(universe, "bala1.nc", "r")

# Read step 10 and display configuration
step10 = trajectory[10]
view(universe, step10['configuration'])

# Print the kinetic energy along the trajectory
print("Kinetic energy along trajectory:")
print(f"{trajectory.kinetic_energy}")

trajectory.close()
示例#6
0
文件: lattice.py 项目: torkos/MMTK
# Example: water molecules on a lattice
#
# This example creates a system of water molecules whose centers
# of mass are positioned simple cubic lattice consisting of
# 3x4x5 cells, i.e. there are 60 water molecules in total.
# The molecules are put into a suitably sized periodic universe.
#

from MMTK import *
from Scientific.Geometry.Objects3D import SCLattice
from MMTK.Visualization import view

# Define parameters of the lattice
edge_length = 0.5 * Units.nm
lattice_size = (3, 4, 5)

# Construct the universe
universe = OrthorhombicPeriodicUniverse(
    (edge_length * lattice_size[0], edge_length * lattice_size[1],
     edge_length * lattice_size[2]))

# Add the water molecules
for point in SCLattice(edge_length, lattice_size):
    universe.addObject(Molecule('water', position=point))

# Visualization
view(universe)
示例#7
0
import pylab

# Construct system
universe = InfiniteUniverse(CalphaForceField(2.5))
universe.protein = Protein('insulin.pdb', model='calpha')

# Find a reasonable basis set size and cutoff
nbasis = max(10, universe.numberOfAtoms()/5)
cutoff, nbasis = estimateCutoff(universe, nbasis)
print "Calculating %d low-frequency modes." % nbasis

if cutoff is None:
    # Do full normal mode calculation
    modes = EnergeticModes(universe, 300.*Units.K)
else:
    # Do subspace mode calculation with Fourier basis
    subspace = FourierBasis(universe, cutoff)
    modes = EnergeticModes(universe, 300.*Units.K, subspace)

# Plot the atomic fluctuations in the first three non-zero modes
# for chain A
chain = universe.protein[0]
pylab.xticks(range(len(chain)),
             [r.name for r in chain])
for i in range(6, 9):
    f = modes[i]*modes[i]
    pylab.plot([f[residue.peptide.C_alpha] for residue in chain])

# Show animation of the first non-trivial mode
view(modes[6], 15.)
""" nucleotide_construction.py creates a nucleotide chain with a ligand from PDB file """

from MMTK import *
from MMTK.PDB import PDBConfiguration
from MMTK.NucleicAcids import NucleotideChain
from MMTK.Visualization import view

""" Load PDB entry 110d. It contains a single DNA strand with a ligand daunomycin """
configuration = PDBConfiguration('110d.pdb')

""" Construct nucleotide chain object. This also constructs positions for missing hydrogens, using geometrical criteria. """

chain = configuration.createNucleotideChains()[0]

""" Construct the ligand. There is no definition of it in the database, so it can only be constructed as a collection of atoms. The second argument of createMolecules() is set to one in order to allow this use of an unknown residue. """
ligand = configuration.createMolecules(['DM1'], 1)

# Put everything in a universe and show it graphically
universe = InfiniteUniverse()
universe.addObject(chain)
universe.addObject(ligand)

view(universe)
示例#9
0
# This program reads a trajecory and calculates the average
# configuration, which is then visualized. This is not a particularly
# useful operation, but it illustrates the use of trajectories and
# configuration variables.
#
# Note: In order to create the trajectory file "bala1.nc" which is
#       read by this example, you must run the example
#       MolecularDynamics/protein.py!
#

from MMTK import *
from MMTK.Trajectory import Trajectory
from MMTK.Visualization import view

# Open the input trajectory.
trajectory = Trajectory(None, 'bala1.nc')
universe = trajectory.universe

# Create a zeroed particle vector object.
sum = ParticleVector(universe)

# Loop over all steps and add the configurations to the sum.
for configuration in trajectory.configuration:
    sum = sum + configuration

# Divide by the number of steps.
sum = sum / len(trajectory)

# Visualize the average.
view(universe, sum)