[MMTK] Writing universe out to a file

vanitha at cs.wisc.edu vanitha at cs.wisc.edu
Wed Dec 7 12:07:39 CET 2005


I have a piece of code that minimizes the configuration of a protein. At
the end of the minimization phase I invoke
universe.writeToFile('somename.pdb') to write my minimized configuration
to a PDB. I see no errors but I don't see my file in the current directory
either. Is it possible that this is saved in a different folder?

Here is my minimization function:

from MMTK import *
from MMTK.ForceFields import Amber94ForceField
from MMTK.ParticleProperties import ParticleVector

def Minimize( universe, maxIter, tolerance):
        # The current configuration of the universe is the initial guess

        energy, gradient = universe.energyAndGradients()
        print "Energy = ", energy
        print "Gradient Norm = ", gradient.norm()

        iter = 0

        while iter < maxIter:
                # Choose the value of alfa using a Backtracking Line Search
                initialAlfa = 1
                alfa = initialAlfa
                direction = -gradient
                universeCopy = copy(universe)
                alfa = backtrackingLineSearch( universeCopy, initialAlfa,
maxIter)

                #print "alfa = ", alfa

                # Update the configuration
                universe.addToConfiguration(alfa*direction)

                # Get the energy and gradients of the current configuration
                energy, gradient = universe.energyAndGradients()
                print "Energy = ", energy
                print "Gradient Norm = ", gradient.norm()
                print "Iteration = ", iter

                # Termination Criteria
                if gradient.norm() <= tolerance:
                        universe.writeToFile('1bp2_min_s.pdb')
                        break
                if iter >= maxIter:
                        universe.writeToFile('1bp2_min_s.pdb')
                        break

                # Update the iteration counter
                iter = iter + 1

Here is the code that invokes it:

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.ParticleProperties import ParticleVector
import SteepestDescent
from MMTK.ForceFields import Amber94ForceField

universe = InfiniteUniverse(Amber94ForceField())
universe.Protein = Protein('1bp2.pdb')
SteepestDescent.Minimize(universe, 1000, 0.0001)


Thanks,

- Vanitha








More information about the mmtk mailing list