Пример #1
0
    def __init__(self, prmtopFname,
                 inpcrdFname):  # prmtopFname, inpcrdFname ):

        self.prmtop = AmberPrmtopFile(prmtopFname)
        self.inpcrd = AmberInpcrdFile(inpcrdFname)
        # number of atoms
        self.natoms = self.prmtop.topology._numAtoms

        # todo: set up ff and simulation object
        self.system = self.prmtop.createSystem(
            nonbondedMethod=openmmff.NoCutoff)  # no cutoff
        self.integrator = VerletIntegrator(0.001 * picosecond)
        self.simulation = Simulation(self.prmtop.topology, self.system,
                                     self.integrator)

        # Another way of setting up potential using just pdb file ( no prmtop )
        # pdb = PDBFile('coords.pdb')
        # forcefield = ForceField('amber99sb.xml', 'tip3p.xml')
        # system = forcefield.createSystem(pdb.topology, nonbondedMethod=ff.NoCutoff)
        # integrator = VerletIntegrator(0.001*picoseconds)
        # simulation = Simulation(pdb.topology, system, integrator)
        # simulation.context.setPositions(pdb.positions)

        # remove units
        self.localCoords = self.inpcrd.positions / angstrom
        self.kJtokCal = kilocalories_per_mole / kilojoules_per_mole
Пример #2
0
    def __init__(self, prmtopFname, inpcrdFname):  # prmtopFname, inpcrdFname ):
        # reads coords.inpcrd , coords.prmtop , min.in and data 
        # - fnames hard coded (todo)
        super(GMINAmberPotential, self).__init__(GMIN)
        # self.potentialLocal = gminpot.GMINPotential(GMIN)
        GMIN.initialize()

        self.prmtop = AmberPrmtopFile(prmtopFname)
        self.inpcrd = AmberInpcrdFile(inpcrdFname)
        # number of atoms
        self.natoms = self.prmtop.topology._numAtoms
        self.localCoords = self.inpcrd.positions / angstrom
Пример #3
0
    def __init__(self, ff_type=None, system_file=None, **kwargs):
        """Two pathways can be used starting from FF-specific files
        or OpenMM XML system. Additional kwargs are variously used
        depending on the forcefield / pathway that was chosen.

        supported ff_type
        -----------------
        amber :: give a prmtop and an inpcrd
        openmm :: give an XML file for the system

        supported kwargs
        ----------------
        topology :: system-specific or not depending on FF
        coordinates :: source of coordinates for initial state
        """

        assert (ff_type is None) or (system_file is None)

        # This dict will store the API calls
        # along with atom groups and force
        # parameters needed to generate all
        # the given restraints
        self._restraints = dict()
        self._topology = None

        topofile = kwargs.get("topology", None)
        coordfile = kwargs.get("coordinates", None)

        if ff_type is not None:
            if ff_type.lower() == "amber":
                prmtop = AmberPrmtopFile(topofile)
                inpcrd = AmberInpcrdFile(coordfile)
                self.system = prmtop.createSystem(
                    nonbondedMethod=NoCutoff
                )  #CutoffNonPeriodic - according to Ada, this would be good bc its what amber does - preliminary tests show that this hurts small/medium proteins
                self._topology = Topology.from_openmm(prmtop.topology)
                self._positions = inpcrd

        elif system_file is not None:
            self.load_xml(system_file)
            if topofile:
                if topofile.endswith(".pdb"):
                    # this line is a bit silly but Topology class
                    # doesn't seem to directly load PDB so keeps
                    # the imports clean
                    self._topology = Topology.from_openmm(
                        PDBFile(topofile).topology)

        else:
            # Inspect and set ff_type
            # TODO ff_type as instance attribute
            pass
Пример #4
0
"""
from __future__ import print_function
# OpenMM
from simtk.openmm.app import AmberPrmtopFile, AmberInpcrdFile, Simulation
from simtk.openmm.app import pdbfile as openmmpdb
from simtk.openmm import *
from simtk.unit import picosecond
import simtk.openmm.app.forcefield as openmmff
#from sys import stdout

# ----- OpenMM

# setup using inpcrd and prmtop
prmtop = AmberPrmtopFile('coords.prmtop')
inpcrd = AmberInpcrdFile('coords.inpcrd')
system1 = prmtop.createSystem(nonbondedMethod=openmmff.NoCutoff)
integrator1 = VerletIntegrator(0.001 * picosecond)
simulation1 = Simulation(prmtop.topology, system1, integrator1)
simulation1.context.setPositions(inpcrd.positions)
# get energy
ener1 = simulation1.context.getState(getEnergy=True).getPotentialEnergy()

# setup using pdb and built-in amber ff
pdb = openmmpdb.PDBFile('coords.pdb')
forcefield = openmmff.ForceField('amber99sb.xml', 'tip3p.xml')
system2 = forcefield.createSystem(pdb.topology,
                                  nonbondedMethod=openmmff.NoCutoff)
integrator2 = VerletIntegrator(0.001 * picosecond)
simulation2 = Simulation(pdb.topology, system2, integrator2)
simulation2.context.setPositions(pdb.positions)
Пример #5
0
    all_milestones = [me.milestones[which]]

for milestone in all_milestones:
    if milestone.md:
        #if not milestone.openmm.prmtop_filename:
        #  print "prmtop file not found for milestone %d. Skipping..." % milestone.index
        #  continue
        if not milestone.openmm.prmtop_filename:
            prmtop_path = os.path.join(me.project.rootdir, milestone.directory,
                                       'md', 'building', 'holo.parm7')
            inpcrd_path = os.path.join(me.project.rootdir, milestone.directory,
                                       'md', 'building', 'holo.rst7')
            if os.path.exists(prmtop_path) and os.path.exists(inpcrd_path):
                milestone.openmm.prmtop_filename = prmtop_path
                milestone.openmm.inpcrd_filename = inpcrd_path
                inpcrd = AmberInpcrdFile(inpcrd_path)
                milestone.box_vectors = inpcrd.boxVectors
                print "box_vectors:", milestone.box_vectors
            else:
                print "prmtop or inpcrd file not found for milestone %d. Skipping..." % milestone.index
                continue

        print "launching constant energy forward stage for milestone:", which
        box_vectors = milestone.box_vectors
        milestone.atom_selection_1 = rec_selection
        milestone.atom_selection_2 = lig_selection
        fwd_rev_path = os.path.join(me.project.rootdir, milestone.directory,
                                    'md', 'fwd_rev')

        traj_base = "forward"
        transition_dict_total = {}
Пример #6
0
 def from_amber(cls, path):
     return AmberInpcrdFile(path).boxVectors
Пример #7
0
 def from_amber(cls, path):
     return AmberInpcrdFile(path).positions