Sampling Functions
This module defines functions for generating alternate conformations along normal modes.
- prody.dynamics.sampling.deformAtoms(atoms, mode, rmsd=None, replace=False, scale=None)[source]
Generate a new coordinate set for atoms along the mode. atoms must be a
AtomGroupinstance. New coordinate set will be appended to atoms. If rmsd is provided, mode will be scaled to generate a coordinate set with given RMSD distance to the active coordinate set.
- prody.dynamics.sampling.sampleModes(modes, atoms=None, n_confs=1000, rmsd=1.0)[source]
Returns an ensemble of randomly sampled conformations along given modes. If atoms are provided, sampling will be around its active coordinate set. Otherwise, sampling is around the 0 coordinate set.
- Parameters:
modes (
Mode,ModeSet,PCA,ANMorNMA) – modes along which sampling will be performedatoms (
Atomic) – atoms whose active coordinate set will be used as the initial conformationn_confs – number of conformations to generate, default is 1000
rmsd (float) – average RMSD that the conformations will have with respect to the initial conformation, default is 1.0 Å
- Returns:
For given normal modes \([u_1 u_2 ... u_m]\) and their eigenvalues \([\lambda_1 \lambda_2 ... \lambda_m]\), a new conformation is sampled using the relation:
\[R_k = R_0 + s \sum_{i=1}^{m} r_i^k \lambda^{-0.5}_i u_i\]\(R_0\) is the active coordinate set of atoms. \([r_1^k r_2^k ... r_m^k]\) are normally distributed random numbers generated for conformation \(k\) using
numpy.random.randn().RMSD of the new conformation from \(R_0\) can be calculated as
\[RMSD^k = \sqrt{ \left[ s \sum_{i=1}^{m} r_i^k \lambda^{-0.5}_i u_i \right] ^{2} / N } = \frac{s}{ \sqrt{N}} \sqrt{ \sum_{i=1}^{m} (r_i^k)^2 \lambda^{-1}_i }\]Average \(RMSD\) of the generated conformations from the initial conformation is:
\[\left< RMSD^k \right> = \frac{s}{ \sqrt{N}} \left< \sqrt{ \sum_{i=1}^{m} (r_i^k)^2 \lambda^{-1}_i } \right>\]From this relation \(s\) scaling factor obtained using the relation
\[s = \left< RMSD^k \right> \sqrt{N} {\left< \sqrt{ \sum_{i=1}^{m} (r_i)^2 \lambda^{-1}_i} \right>}^{-1}\]Note that random numbers are generated before conformations are sampled, hence exact value of \(s\) is known from this relation to ensure that the generated ensemble will have user given average rmsd value.
Note that if modes are from a
PCA, variances are used instead of inverse eigenvalues, i.e. \(\sigma_i \sim \lambda^{-1}_i\).See also
showEllipsoid().
- prody.dynamics.sampling.traverseMode(mode, atoms, n_steps=10, rmsd=1.5, **kwargs)[source]
Generates a trajectory along a given mode, which can be used to animate fluctuations in an external program.
- Parameters:
mode (
Mode) – mode along which a trajectory will be generatedatoms (
Atomic) – atoms whose active coordinate set will be used as the initial conformationn_steps (int) – number of steps to take along each direction, for example, for
n_steps=10, 20 conformations will be generated along mode with structure atoms in between, default is 10.rmsd (float) – maximum RMSD that the conformations will have with respect to the initial conformation, default is 1.5 Å
pos (bool) – whether to include steps in the positive mode direction, default is True
neg (bool) – whether to include steps in the negative mode direction, default is True
reverse (bool) – whether to reverse the direction default is False
- Returns:
For given normal mode \(u_i\), its eigenvalue \(\lambda_i\), number of steps \(n\), and maximum \(RMSD\) conformations \([R_{-n} R_{-n+1} ... R_{-1} R_0 R_1 ... R_n]\) are generated.
\(R_0\) is the active coordinate set of atoms. \(R_k = R_0 + sk\lambda_iu_i\), where \(s\) is found using \(s = ((N (\frac{RMSD}{n})^2) / \lambda_i^{-1}) ^{0.5}\), where \(N\) is the number of atoms.