HelixHBondContent¶
- class cvpack.HelixHBondContent(residues, pbc=False, thresholdDistance=0.33 nm, halfExponent=3, normalize=False, name='helix_hbond_content')[source]¶
The alpha-helix hydrogen-bond content of a sequence of n residues:
\[\alpha_{\rm HB}({\bf r}) = \sum_{i=5}^n B_m\left( \frac{\| {\bf r}^{\rm H}_i - {\bf r}^{\rm O}_{i-4} \|}{d_{\rm HB}} \right)\]where \({\bf r}^{\rm H}_k\) and \({\bf r}^{\rm O}_k\) are the positions of the hydrogen and oxygen atoms bonded, respectively, to the backbone nitrogen and carbon atoms of residue \(k\). In addition, \(d_{\rm HB}\) is the threshold distance for a hydrogen bond and \(B_m(x)\) is a smooth step function given by
\[B_m(x) = \frac{1}{1 + x^{2m}}\]where \(m\) is an integer parameter that controls its steepness.
Optionally, this collective variable can be normalized to the range \([0, 1]\).
Note
The residues must be a contiguous sequence from a single chain, ordered from the N- to the C-terminus. Proline residues, which have no amide hydrogen, are skipped as donors, and the normalization uses the number of remaining donor-acceptor pairs.
- Parameters:
residues (t.Sequence[mmapp.topology.Residue]) – The residues in the sequence.
pbc (bool) – Whether to use periodic boundary conditions.
thresholdDistance (ScalarQuantity) – The threshold distance for a hydrogen bond.
halfExponent (int) – The parameter \(m\) of the step function.
normalize (bool) – Whether to normalize the collective variable to the range \([0, 1]\).
name (str) – The name of the collective variable.
Example
>>> import cvpack >>> import openmm >>> from openmm import app, unit >>> from openmmtools import testsystems >>> model = testsystems.LysozymeImplicit() >>> residues = list(model.topology.residues())[59:80] >>> print(*[r.name for r in residues]) LYS ASP GLU ... ILE LEU ARG >>> helix_content = cvpack.HelixHBondContent(residues) >>> helix_content.addToSystem(model.system) >>> platform = openmm.Platform.getPlatformByName('Reference') >>> integrator = openmm.VerletIntegrator(0) >>> context = openmm.Context(model.system, integrator, platform) >>> context.setPositions(model.positions) >>> helix_content.getValue(context) 15.880... dimensionless
Methods
- addToSystem(system, setUnusedForceGroup=True)¶
Add this collective variable to an openmm.System.
- getEffectiveMass(context, allowReinitialization=False)¶
Compute the effective mass of this collective variable at a given openmm.Context.
The effective mass of a collective variable \(q({\bf r})\) is defined as [1]:
\[m_\mathrm{eff}({\bf r}) = \left( \sum_{i=1}^N \frac{1}{m_i} \left\| \frac{dq}{d{\bf r}_i} \right\|^2 \right)^{-1}\]If this collective variable shares the force group with other forces, then evaluating its effective mass requires reinitializing the openmm.Context twice at each call. This is inefficient and should be avoided. To allow this behavior, the
allowReinitializationparameter must be set to True.Note
By adding this collective variable to the system using the
addToSystem()method, the force group of this collective variable is set to an available force group in the system by default.- Parameters:
- Returns:
The effective mass of this collective variable at the given context.
- Return type:
Example
In this example, we compute the effective masses of the backbone dihedral angles and the radius of gyration of an alanine dipeptide molecule in water:
>>> import cvpack >>> import openmm >>> from openmmtools import testsystems >>> model = testsystems.AlanineDipeptideExplicit() >>> top = model.mdtraj_topology >>> backbone_atoms = top.select("not water and name N CA C") >>> phi = cvpack.Torsion(*backbone_atoms[0:4]) >>> psi = cvpack.Torsion(*backbone_atoms[1:5]) >>> radius_of_gyration = cvpack.RadiusOfGyration( ... top.select("not water") ... ) >>> for cv in [phi, psi, radius_of_gyration]: ... cv.addToSystem(model.system) >>> context = openmm.Context( ... model.system, openmm.VerletIntegrator(0) ... ) >>> context.setPositions(model.positions) >>> phi.getEffectiveMass(context) 0.04795... nm**2 Da/(rad**2) >>> psi.getEffectiveMass(context) 0.05119... nm**2 Da/(rad**2) >>> radius_of_gyration.getEffectiveMass(context) 30.946... Da
- getMassUnit()¶
Get the unit of measurement of the effective mass of this collective variable.
- Return type:
- getPeriodicBounds()¶
Get the periodic bounds of this collective variable.
- Returns:
The periodic bounds of this collective variable or None if it is not periodic
- Return type:
Union[Quantity, None]
- getValue(context, allowReinitialization=False)¶
Evaluate this collective variable at a given openmm.Context.
If this collective variable shares the force group with other forces, then its evaluation requires reinitializing the openmm.Context twice at each call. This is inefficient and should be avoided. To allow this behavior, the
allowReinitializationparameter must be set to True.Note
By adding this collective variable to the system using the
addToSystem()method, the force group of this collective variable is set to an available force group in the system by default.- Parameters:
- Returns:
The value of this collective variable at the given context.
- Return type:
Example
In this example, we compute the values of the backbone dihedral angles and the radius of gyration of an alanine dipeptide molecule in water:
>>> import cvpack >>> import openmm >>> from openmmtools import testsystems >>> model = testsystems.AlanineDipeptideExplicit() >>> top = model.mdtraj_topology >>> backbone_atoms = top.select("not water and name N CA C") >>> phi = cvpack.Torsion(*backbone_atoms[0:4]) >>> psi = cvpack.Torsion(*backbone_atoms[1:5]) >>> radius_of_gyration = cvpack.RadiusOfGyration( ... top.select("not water") ... ) >>> for cv in [phi, psi, radius_of_gyration]: ... cv.addToSystem(model.system) >>> context = openmm.Context( ... model.system, openmm.VerletIntegrator(0) ... ) >>> context.setPositions(model.positions) >>> phi.getValue(context) -3.1415... rad >>> psi.getValue(context) 3.1415... rad >>> radius_of_gyration.getValue(context) 0.29514... nm