Exemplo n.º 1
0
    def __init__(self, pdb, k=1000*kilojoules_per_mole/nanometer**2):
        self.atom1, self.atom2, self._r0 = self.end_to_end_CA_distance(
            pdb.topology, pdb.getPositions(asNumpy=True))
        self.k = k.in_units_of(kilojoules_per_mole/nanometer**2)

        self.force = CustomBondForce("0.5*pullingforce_k*(r-pullingforce_r0)^2")
        self.force.addGlobalParameter('pullingforce_k', self.k)
        self.force.addGlobalParameter('pullingforce_r0', self._r0)
        self.force.addBond(self.atom1, self.atom2, [])
Exemplo n.º 2
0
class PullingForceWrapper(object):
    def __init__(self, pdb, k=1000*kilojoules_per_mole/nanometer**2):
        self.atom1, self.atom2, self._r0 = self.end_to_end_CA_distance(
            pdb.topology, pdb.getPositions(asNumpy=True))
        self.k = k.in_units_of(kilojoules_per_mole/nanometer**2)

        self.force = CustomBondForce("0.5*pullingforce_k*(r-pullingforce_r0)^2")
        self.force.addGlobalParameter('pullingforce_k', self.k)
        self.force.addGlobalParameter('pullingforce_r0', self._r0)
        self.force.addBond(self.atom1, self.atom2, [])


    def end_to_end_CA_distance(self, topology, positions):
        residues = list(topology.residues())
        # get the index of the first and last alpha carbons
        i1 = [a.index for a in residues[0].atoms() if a.name == 'CA'][0]
        i2 = [a.index for a in residues[-1].atoms() if a.name == 'CA'][0]

        # get the current distanc be between the two alpha carbons
        return i1, i2, sqrt(sum((positions[i1] - positions[i2])**2))
    
    def get_r0(self):
        return self._r0
    
    def set_r0(self, value, context):
        value = value.in_units_of(nanometer)
        self._r0 = value
        context.setParameter('pullingforce_r0', value)
        
    def add_to_system(self, system):
        system.addForce(self.force)
Exemplo n.º 3
0
# Load the AMBER files
print("Creating OpenMM system from AMBER input files...")
prmtop = AmberPrmtopFile(amber_prmtop_file)
inpcrd = AmberInpcrdFile(amber_inpcrd_file)

system = prmtop.createSystem(
    nonbondedMethod=nonbonded_method,
    constraints=constraints,
    temperature=temperature,
    removeCMMotion=remove_cm_motion,
    hydrogenMass=hydrogen_mass,
)

# Add virtual bond between RBD (CA of VAL172 ) and ACE2 (CA of GLN514)
force = CustomBondForce('0')
force.addBond(2636, 8116, [])
system.addForce(force)

# Add a barostat to the system
system.addForce(MonteCarloBarostat(pressure, temperature))

# Make and serialize integrator - Langevin dynamics
print("Serializing integrator to %s" % integrator_xml_filename)
integrator = openmmtools.integrators.LangevinIntegrator(
    temperature,
    collision_rate,  # Friction coefficient
    timestep,
    constraint_tolerance=1e-5)
with open(output_prefix + integrator_xml_filename, "w") as outfile:
    xml = mm.XmlSerializer.serialize(integrator)