Esempio n. 1
0
def ufed_model():
    model = ufedmm.AlanineDipeptideModel()
    mass = 50*unit.dalton*(unit.nanometer/unit.radians)**2
    Ks = 1000*unit.kilojoules_per_mole/unit.radians**2
    Ts = 1500*unit.kelvin
    limit = 180*unit.degrees
    sigma = 18*unit.degrees
    height = 2.0*unit.kilojoules_per_mole
    frequency = 10
    phi = ufedmm.CollectiveVariable('phi', model.phi, -limit, limit, mass, Ks, Ts, sigma)
    psi = ufedmm.CollectiveVariable('psi', model.psi, -limit, limit, mass, Ks, Ts, sigma)
    return model, ufedmm.UnifiedFreeEnergyDynamics([phi, psi], 300*unit.kelvin, height, frequency)
Esempio n. 2
0
 def __init__(self,
              force_field='amber03',
              water=None,
              box_length=25 * unit.angstroms,
              constraints=openmm.app.HBonds,
              rigidWater=True):
     pdb = app.PDBFile(
         os.path.join(ufedmm.__path__[0], 'data', 'alanine-dipeptide.pdb'))
     if water is None:
         force_field = app.ForceField(f'{force_field}.xml')
         self.topology = pdb.topology
         self.positions = pdb.positions
         L = box_length.value_in_unit(unit.nanometers)
         vectors = [
             openmm.Vec3(L, 0, 0),
             openmm.Vec3(0, L, 0),
             openmm.Vec3(0, 0, L)
         ]
         self.topology.setPeriodicBoxVectors(vectors)
     else:
         force_field = app.ForceField(f'{force_field}.xml', f'{water}.xml')
         modeller = app.Modeller(pdb.topology, pdb.positions)
         modeller.addSolvent(force_field,
                             model=water,
                             boxSize=box_length * openmm.Vec3(1, 1, 1))
         self.topology = modeller.topology
         self.positions = modeller.positions
     self.system = force_field.createSystem(
         self.topology,
         nonbondedMethod=app.NoCutoff if water is None else app.PME,
         constraints=constraints,
         rigidWater=rigidWater,
         removeCMMotion=False,
     )
     atoms = [(a.name, a.residue.name) for a in self.topology.atoms()]
     phi_atoms = [('C', 'ACE'), ('N', 'ALA'), ('CA', 'ALA'), ('C', 'ALA')]
     self.phi = ufedmm.CollectiveVariable(
         'phi', openmm.CustomTorsionForce('theta'))
     self.phi.force.addTorsion(*[atoms.index(i) for i in phi_atoms], [])
     psi_atoms = [('N', 'ALA'), ('CA', 'ALA'), ('C', 'ALA'), ('N', 'NME')]
     self.psi = ufedmm.CollectiveVariable(
         'psi', openmm.CustomTorsionForce('theta'))
     self.psi.force.addTorsion(*[atoms.index(i) for i in psi_atoms], [])
Esempio n. 3
0
def dihedral_angle_cvs(prmtop_file, name, *atom_types):
    selected_dihedrals = set()
    for dihedral in pmd.amber.AmberParm(prmtop_file).dihedrals:
        atoms = [getattr(dihedral, f'atom{i+1}') for i in range(4)]
        if all(a.type == atype for a, atype in zip(atoms, atom_types)):
            selected_dihedrals.add(tuple(a.idx for a in atoms))
    n = len(selected_dihedrals)
    collective_variables = []
    for i, dihedral in enumerate(selected_dihedrals):
        force = openmm.CustomTorsionForce('theta')
        force.addTorsion(*dihedral, [])
        cv_name = name if n == 1 else f'{name}{i+1}'
        cv = ufedmm.CollectiveVariable(cv_name, force)
        collective_variables.append(cv)
        # print(cv_name, dihedral)
    return collective_variables
Esempio n. 4
0
seed = random.SystemRandom().randint(0, 2**
                                     31) if args.seed is None else args.seed
model = ufedmm.AlanineDipeptideModel(force_field=args.ff, water=args.water)
temp = 300 * unit.kelvin
gamma = 10 / unit.picoseconds
dt = 2 * unit.femtoseconds
nsteps = 1000000
mass = 30 * unit.dalton * (unit.nanometer / unit.radians)**2
Ks = 1000 * unit.kilojoules_per_mole / unit.radians**2
Ts = 1500 * unit.kelvin
limit = 180 * unit.degrees
sigma = 18 * unit.degrees
height = 2.0 * unit.kilojoules_per_mole
deposition_period = 200
phi = ufedmm.CollectiveVariable('phi', model.phi, -limit, limit, mass, Ks, Ts,
                                sigma)
psi = ufedmm.CollectiveVariable('psi', model.psi, -limit, limit, mass, Ks, Ts,
                                sigma)
ufed = ufedmm.UnifiedFreeEnergyDynamics([phi, psi], temp, height,
                                        deposition_period)
ufedmm.serialize(ufed, 'ufed_object.yml')
integrator = ufedmm.GeodesicBAOABIntegrator(temp, gamma, dt)
integrator.setRandomNumberSeed(seed)
platform = openmm.Platform.getPlatformByName(args.platform)
simulation = ufed.simulation(model.topology, model.system, integrator,
                             platform)
ufed.set_positions(simulation, model.positions)
ufed.set_random_velocities(simulation, seed)
output = ufedmm.MultipleFiles(stdout, 'output.csv')
reporter = ufedmm.StateDataReporter(output,
                                    100,
Esempio n. 5
0
Ts = 3000 * unit.kelvin
sigma = 0.05
height = 2.0 * unit.kilojoules_per_mole
deposition_period = 200

pdb = app.PDBFile('aaqaa3.pdb')
force_field = app.ForceField('charmm36.xml')
system = force_field.createSystem(
    pdb.topology,
    nonbondedMethod=app.NoCutoff,
    constraints=None,
    rigidWater=False,
    removeCMMotion=False,
)

hc_hb = ufedmm.CollectiveVariable(
    'hc_hb', cvlib.HelixHydrogenBondContent(pdb.topology, 0, 14))
hc_a = ufedmm.CollectiveVariable('hc_a',
                                 cvlib.HelixAngleContent(pdb.topology, 0, 14))
hc_d = ufedmm.CollectiveVariable(
    'hc_d', cvlib.HelixRamachandranContent(pdb.topology, 0, 14))

s_hc = ufedmm.DynamicalVariable('s_hc',
                                0.0,
                                1.0,
                                mass,
                                Ts, [hc_hb, hc_a, hc_d],
                                '0.5*Ks*(s_hc - (hc_hb + hc_a + hc_d)/3)^2',
                                Ks=Ks,
                                sigma=sigma,
                                periodic=False)