nu-dependent self-avoiding walk
Usage examples and full code reference for
NuDepSAW. For the underlying theory, see
nu-dependent self-avoiding walk.
Quick start
from afrc.polymer_models.nudep_saw import NuDepSAW
model = NuDepSAW('MASNDYTQQATQSYGAYPTQPGQGYSQQSSQPYG')
# the scaling exponent nu is supplied per call (default nu = 0.5)
model.get_mean_end_to_end_distance(nu=0.5)
model.get_root_mean_squared_end_to_end_distance(nu=0.5)
model.get_mean_radius_of_gyration(nu=0.5)
# full end-to-end distribution (distances, probabilities)
r, p = model.get_end_to_end_distribution(nu=0.5)
# draw a size-matched sample
samples = model.sample_end_to_end_distribution(n=1000, nu=0.5)
Sweep the scaling exponent from collapsed (nu ~ 1/3) to fully expanded (nu ~ 0.588):
for nu in (0.40, 0.50, 0.59):
print(nu, model.get_mean_end_to_end_distance(nu=nu))
See also the demo/demo_NuDepSAW.ipynb notebook for a worked, plotted example.
Code reference
- class afrc.polymer_models.nudep_saw.NuDepSAW(seq, p_of_r_resolution=0.05)
This class generates an object that returns polymer statistics consistent with a nu-dependent self-avoiding random walk (SAW). As developed by Zheng et al 2020
- __init__(seq, p_of_r_resolution=0.05)
Method to create nu-dependent SAW (self-avoiding walk) object. Seq should be a valid upper-case amino acid sequence and p_of_r_resolution defines the resolution (in angstroms) to be used for distributions.
By default p_of_r_resolution is taken from the config.py file in the afrc package which defines the resolution at 0.05 A.
- Parameters:
seq (str) – Amino acid sequence (used only to calculate number of residues)
p_of_r_resolution (float) – Bin width for bulding probability distributions. In Angstroms.
- Return type:
Generates an NuDepSAW object
- get_end_to_end_distribution(nu=0.5, prefactor=5.5)
Defines the end-to-end distribution based
This is a composition independent model for which the end-to-end distance depends solely on the number of amino acids. Both nu and the prefactor can be varied
- Parameters:
nu (float) – Flory scaling exponent. Should fall between 0.33 and 0.6
prefactor (float) – Prefactor is a number that tunes the SAW dimensions. Default is 5.5 A.
- Returns:
A 2-pair tuple of numpy arrays where the first is the distance (in Angstroms) and the second array is the probability of that distance.
- Return type:
tuple of arrays
- get_mean_end_to_end_distance(nu=0.5, prefactor=5.5)
Returns the mean end-to-end distance (\(R_e\)) for the nu-dependent SAW model.
The mean is computed by integrating over the \(P(r)\) vs. \(r\) distribution (i.e. \(\sum r \cdot P(r)\)), consistent with the convention used by the other models in this package.
- Parameters:
nu (float) – Flory scaling exponent. Should fall between 0.33 and 0.6.
prefactor (float) – Prefactor that tunes the SAW dimensions. Default is 5.5 A.
- Returns:
Value equal to the mean end-to-end distance.
- Return type:
float
- get_mean_radius_of_gyration(nu=0.5, prefactor=5.5)
Returns the mean radius of gyration (\(R_g\)) for the nu-dependent SAW model.
\(R_g\) is obtained from the mean-squared end-to-end distance via the analytical ratio \(\langle R_g^2 \rangle / \langle R_e^2 \rangle\) expressed in terms of the gamma exponent and the scaling exponent \(\nu\).
- Parameters:
nu (float) – Flory scaling exponent. Should fall between 0.33 and 0.6.
prefactor (float) – Prefactor that tunes the SAW dimensions. Default is 5.5 A.
- Returns:
Value equal to the mean radius of gyration.
- Return type:
float
- get_root_mean_squared_end_to_end_distance(nu=0.5, prefactor=5.5)
Returns the root-mean-square end-to-end distance (\(\sqrt{\langle R_e^2 \rangle}\)) for the nu-dependent SAW model.
The value is computed by taking the square root after integrating over \(P(r)\) vs. \(r^2\).
- Parameters:
nu (float) – Flory scaling exponent. Should fall between 0.33 and 0.6.
prefactor (float) – Prefactor that tunes the SAW dimensions. Default is 5.5 A.
- Returns:
Value equal to the root-mean-square end-to-end distance.
- Return type:
float
- sample_end_to_end_distribution(n=1000, nu=0.5, prefactor=5.5)
Subsamples from the end-to-end distance distribution to generate an uncorrelated ‘trajectory’ of points. Useful for creating a sized-match sample to compare with simulation data.
- Parameters:
n (int) – Number of random values to sample (default = 1000)
nu (float) – Flory scaling exponent. Should fall between 0.33 and 0.6
prefactor (float) – Prefactor is a number that tunes the SAW dimensions. Default is 5.5 A.
- Returns:
Returns an n-length array with n independent values (floats)
- Return type:
np.ndarray