def __init__(self, trajectory, time, temperature):
        from MMTK.NormalModes import EnergeticModes
        self.raw_trajectory = trajectory
        self.trajectory = None
        self.time = time
        self.temperature = temperature
        self.cache = {}

        self._makeUniverse()
        self.modes = EnergeticModes(self.universe_calpha, temperature=None)
Example #2
0
 def calcModes(self):
     self.universe.setConfiguration(self.conf)
     natoms = self.universe.numberOfAtoms()
     nmodes = min(self.nmodes, 3*natoms)
     if nmodes > natoms:
         nmodes = 3*natoms
     if nmodes == 3*natoms:
         modes = EnergeticModes(self.universe, None)
         modes.cutoff = None
     else:
         p1, p2 = self.universe.boundingBox()
         cutoff_max = (p2-p1).length()
         cutoff = 0.5*cutoff_max
         nmodes_opt = nmodes
         nmodes = countBasisVectors(self.universe, cutoff)
         while nmodes > nmodes_opt:
             cutoff = cutoff + 0.1
             if cutoff > cutoff_max:
                 cutoff = cutoff_max
                 break
             nmodes = countBasisVectors(self.universe, cutoff)
         while nmodes < nmodes_opt:
             cutoff = cutoff - 0.1
             if cutoff < 0.1:
                 cutoff = 0.1
                 break
             nmodes = countBasisVectors(self.universe, cutoff)
         basis = FourierBasis(self.universe, cutoff)
         basis.may_modify = 1
         modes = EnergeticModes(self.universe, None,
                                subspace=basis, sparse=True)
         modes.cutoff = cutoff
     self.modes = modes
import numpy

# Make a universe for the first configuration
universe = InfiniteUniverse(CalphaForceField())
universe.protein = Protein('1SU4.pdb', model='calpha')
conf_1SU4 = universe.copyConfiguration()

# Apply the second configuration and do a rigid-body superposition fit
PDBConfiguration('1T5T.pdb').applyTo(universe.protein)
tr, rms = universe.findTransformation(conf_1SU4)
universe.applyTransformation(tr)
conf_1T5T = universe.copyConfiguration()

# Set first configuration and calculate normal modes
universe.setConfiguration(conf_1SU4)
modes = EnergeticModes(universe, 300.*Units.K)

# Calculate the normalized difference vector
diff = (conf_1T5T - conf_1SU4).scaledToNorm(1.)

# Calculate the squared overlaps for all modes
mode_numbers = numpy.arange(6, len(modes))
overlaps = [modes.rawMode(i).dotProduct(diff)**2
            for i in mode_numbers]

# First plot: show that the cumulative sum converges to 1. This means that
# the squared overlaps can be considered as a percentage that each mode
# contributes to the conformational change.
pylab.figure(1)
pylab.plot(mode_numbers+1, numpy.add.accumulate(overlaps))
pylab.xlabel('mode number')
Example #4
0
from MMTK.NormalModes import EnergeticModes
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.)
import numpy

# Make a universe for the first configuration
universe = InfiniteUniverse(CalphaForceField())
universe.protein = Protein('1SU4.pdb', model='calpha')
conf_1SU4 = universe.copyConfiguration()

# Apply the second configuration and do a rigid-body superposition fit
PDBConfiguration('1T5T.pdb').applyTo(universe.protein)
tr, rms = universe.findTransformation(conf_1SU4)
universe.applyTransformation(tr)
conf_1T5T = universe.copyConfiguration()

# Set first configuration and calculate normal modes
universe.setConfiguration(conf_1SU4)
modes = EnergeticModes(universe, 300. * Units.K)

# Calculate the normalized difference vector
diff = (conf_1T5T - conf_1SU4).scaledToNorm(1.)

# Calculate the squared overlaps for all modes
mode_numbers = numpy.arange(6, len(modes))
overlaps = [modes.rawMode(i).dotProduct(diff)**2 for i in mode_numbers]

# First plot: show that the cumulative sum converges to 1. This means that
# the squared overlaps can be considered as a percentage that each mode
# contributes to the conformational change.
pylab.figure(1)
pylab.plot(mode_numbers + 1, numpy.add.accumulate(overlaps))
pylab.xlabel('mode number')
pylab.ylabel('cumulative squared overlap')
Example #6
0
from MMTK.ForceFields import CalphaForceField
from MMTK.Field import AtomicVectorField
from MMTK.Database import PDBPath
from Scientific.Visualization import Chimera
import chimera

# Load the molecule into Chimera
filename = PDBPath("insulin.pdb")
chimera.runCommand("open pdb:%s" % filename)

# Create a simulation universe containing the protein
universe = InfiniteUniverse(CalphaForceField())
universe.addObject(Protein(filename, model='calpha'))

# Calculate normal modes
modes = EnergeticModes(universe)

# Create the vector field corresponding to the first non-zero mode
# using a grid spacing of 0.5 nm.
field = AtomicVectorField(universe, 0.5, modes[6])

# Create graphics objects for the vector fields.
# The arrows are yellow and their lengths are multiplied by 80.
# Only displacement vectors of lengths between 0. and 0.01 will be shown.
# (This restriction is not necessary for this example, but used for
#  illustration.)
graphics = field.graphicsObjects(color='yellow',
                                 scale=80.,
                                 range=(0., 0.01),
                                 graphics_module=Chimera)