API Documentation

class helanal.helanal.HELANAL(universe, select='name CA', ref_axis=[0, 0, 1], verbose=False, flatten_single_helix=True, split_residue_sequences=True)[source]

Bases: AnalysisBase

Perform HELANAL helix analysis on your trajectory.

Parameters:
  • universe (Universe or AtomGroup) – The Universe or AtomGroup to apply the analysis to.

  • select (str or iterable of str, optional) – The selection string to create an atom selection that the HELANAL analysis is applied to. Note that HELANAL is designed to work on the alpha-carbon atoms of protein residues. If you pass in multiple selections, the selections will be analysed separately.

  • ref_axis (array-like of length 3, optional) – The reference axis used to calculate the tilt of the vector of best fit, and the local screw angles.

  • flatten_single_helix (bool, optional) – Whether to flatten results if only one selection is passed.

  • split_residue_sequences (bool, optional) – Whether to split the residue sequence into individual helices. This keyword only applies if a residue gap is present in the AtomGroup generated by a select string. If False, the residues will be analysed as a single helix. If True, each group of consecutive residues will be treated as a separate helix.

  • verbose (bool, optional) – Turn on more logging and debugging.

Variables:
  • results.local_twists (array or list of arrays) – The local twist angle from atom i+1 to i+2. Each array has shape (n_frames, n_residues-3)

  • results.local_nres_per_turn (array or list of arrays) – Number of residues per turn, based on local_twist. Each array has shape (n_frames, n_residues-3)

  • results.local_axes (array or list of arrays) – The length-wise helix axis of the local window. Each array has shape (n_frames, n_residues-3, 3)

  • results.local_heights (array or list of arrays) – The rise of each local helix. Each array has shape (n_frames, n_residues-3)

  • results.local_helix_directions (array or list of arrays) – The unit vector from each local origin to atom i+1. Each array has shape (n_frames, n_residues-2, 3)

  • results.local_origins (array or list of arrays) – The projected origin for each helix. Each array has shape (n_frames, n_residues-2, 3)

  • results.local_screw_angles (array or list of arrays) – The local screw angle for each helix. Each array has shape (n_frames, n_residues-2)

  • results.local_bends (array or list of arrays) – The angles between local helix axes, 3 windows apart. Each array has shape (n_frames, n_residues-6)

  • results.all_bends (array or list of arrays) – The angles between local helix axes. Each array has shape (n_frames, n_residues-3, n_residues-3)

  • results.global_axis (array or list of arrays) – The length-wise axis for the overall helix. This points at the first helix window in the helix, so it runs opposite to the direction of the residue numbers. Each array has shape (n_frames, 3)

  • results.global_tilts (array or list of arrays) – The angle between the global axis and the reference axis. Each array has shape (n_frames,)

  • results.summary (dict or list of dicts) – Summary of stats for each property: the mean, the sample standard deviation, and the mean absolute deviation.

classmethod get_supported_backends()

Tuple with backends supported by the core library for a given class. User can pass either one of these values as backend=... to run() method, or a custom object that has apply method (see documentation for run()):

  • ‘serial’: no parallelization

  • ‘multiprocessing’: parallelization using multiprocessing.Pool

  • ‘dask’: parallelization using dask.delayed.compute(). Requires installation of mdanalysis[dask]

If you want to add your own backend to an existing class, pass a backends.BackendBase subclass (see its documentation to learn how to implement it properly), and specify unsupported_backend=True.

Returns:

names of built-in backends that can be used in run(backend=...)()

Return type:

tuple

Added in version 2.8.0.

property parallelizable

Boolean mark showing that a given class can be parallelizable with split-apply-combine procedure. Namely, if we can safely distribute _single_frame() to multiple workers and then combine them with a proper _conclude() call. If set to False, no backends except for serial are supported.

Note

If you want to check parallelizability of the whole class, without explicitly creating an instance of the class, see _analysis_algorithm_is_parallelizable. Note that you setting it to other value will break things if the algorithm behind the analysis is not trivially parallelizable.

Returns:

if a given AnalysisBase subclass instance is parallelizable with split-apply-combine, or not

Return type:

bool

Added in version 2.8.0.

run(start: int = None, stop: int = None, step: int = None, frames: Iterable = None, verbose: bool = None, n_workers: int = None, n_parts: int = None, backend: str | BackendBase = None, *, unsupported_backend: bool = False, progressbar_kwargs=None)

Perform the calculation

Parameters:
  • start (int, optional) – start frame of analysis

  • stop (int, optional) – stop frame of analysis

  • step (int, optional) – number of frames to skip between each analysed frame

  • frames (array_like, optional) – array of integers or booleans to slice trajectory; frames can only be used instead of start, stop, and step. Setting both frames and at least one of start, stop, step to a non-default value will raise a ValueError.

    Added in version 2.2.0.

  • verbose (bool, optional) – Turn on verbosity

  • progressbar_kwargs (dict, optional) – ProgressBar keywords with custom parameters regarding progress bar position, etc; see MDAnalysis.lib.log.ProgressBar for full list. Available only for backend='serial'

  • backend (Union[str, BackendBase], optional) – By default, performs calculations in a serial fashion. Otherwise, user can choose a backend: str is matched to a builtin backend (one of serial, multiprocessing and dask), or a MDAnalysis.analysis.results.BackendBase subclass.

    Added in version 2.8.0.

  • n_workers (int) – positive integer with number of workers (processes, in case of built-in backends) to split the work between

    Added in version 2.8.0.

  • n_parts (int, optional) – number of parts to split computations across. Can be more than number of workers.

    Added in version 2.8.0.

  • unsupported_backend (bool, optional) – if you want to run your custom backend on a parallelizable class that has not been tested by developers, by default False

    Added in version 2.8.0.

Changed in version 2.2.0: Added ability to analyze arbitrary frames by passing a list of frame indices in the frames keyword argument.

Changed in version 2.5.0: Add progressbar_kwargs parameter, allowing to modify description, position etc of tqdm progressbars

Changed in version 2.8.0: Introduced backend, n_workers, n_parts and unsupported_backend keywords, and refactored the method logic to support parallelizable execution.

universe_from_origins()[source]

Create MDAnalysis Universe from the local origins.

Return type:

Universe or list of Universes

helanal.helanal.helix_analysis(positions, ref_axis=[0, 0, 1])[source]

Calculate helix properties from atomic coordinates.

Each property is calculated from a sliding window of 4 atoms, from i to i+3. Any property whose name begins with ‘local’ is a property of a sliding window.

Parameters:
  • positions (numpy.ndarray of shape (N, 3)) – Atomic coordinates.

  • ref_axis (array-like of length 3, optional) – The reference axis used to calculate the tilt of the vector of best fit, and the local screw angles.

Returns:

local_twistsarray, shape (N-3,)

local twist angle from atom i+1 to i+2

local_nres_per_turnarray, shape (N-3,)

number of residues per turn, based on local_twist

local_axesarray, shape (N-3, 3)

the length-wise helix axis of the local window

local_bendsarray, shape (N-6,)

the angles between local helix angles, 3 windows apart

local_heightsarray, shape (N-3,)

the rise of each local helix

local_helix_directionsarray, shape (N-2, 3)

the unit vector from each local origin to atom i+1

local_originsarray, shape (N-2, 3)

the projected origin for each helix

all_bendsarray, shape (N-3, N-3)

angles between each local axis

global_axisarray, shape (3,)

vector of best fit through origins, pointing at the first origin.

local_screw_anglesarray, shape (N-2,)

cylindrical azimuth angle to plane of global_axis and ref_axis

Return type:

dict with the following keys

helanal.helanal.local_screw_angles(global_axis, ref_axis, helix_directions)[source]

Cylindrical azimuth angles between the local direction vectors, as projected onto the cross-section of the helix, from (-pi, pi]. The origin (angle=0) is set to the plane of global_axis and ref_axis.

Parameters:
  • global_axis (numpy.ndarray of shape (3,)) – Vector of best fit. Screw angles are calculated perpendicular to this axis.

  • ref_axis (numpy.ndarray of shape (3,)) – Reference length-wise axis. One of the reference vectors is orthogonal to this axis.

  • helix_directions (numpy.ndarray of shape (N, 3)) – array of vectors representing the local direction of each helix window.

Returns:

Array of screw angles.

Return type:

numpy.ndarray of shape (N,)

helanal.helanal.vector_of_best_fit(coordinates)[source]

Fit vector through the centered coordinates, pointing to the first coordinate (i.e. upside-down).

Parameters:

coordinates (numpy.ndarray of shape (N, 3))

Returns:

Vector of best fit.

Return type:

numpy.ndarray of shape (3,)