AnalysisCollection#

class maicos.core.AnalysisCollection(*analysis_instances: AnalysisBase)[source]#

Bases: _Runner

Running a collection of analysis classes on the same single trajectory.

Warning

AnalysisCollection is still experimental. You should not use it for anything important.

An analyses with AnalysisCollection can lead to a speedup compared to running the individual analyses, since the trajectory loop is performed only once. The class requires that each analysis is a child of AnalysisBase. Additionally, the trajectory of all analysis_instances must be the same. It is ensured that all analysis instances use the same original timestep and not an altered one from a previous analysis instance.

Parameters:

*analysis_instances (AnalysisBase) – Arbitrary number of analysis instances to be run on the same trajectory.

Raises:

Example

>>> import MDAnalysis as mda
>>> from maicos import DensityPlanar
>>> from maicos.core import AnalysisCollection
>>> from MDAnalysisTests.datafiles import TPR, XTC
>>> u = mda.Universe(TPR, XTC)

Select atoms

>>> ag_O = u.select_atoms("name O")
>>> ag_H = u.select_atoms("name H")

Create the individual analysis instances

>>> dplan_O = DensityPlanar(ag_O)
>>> dplan_H = DensityPlanar(ag_H)

Create a collection for common trajectory

>>> collection = AnalysisCollection(dplan_O, dplan_H)

Run the collected analysis

>>> _ = collection.run(start=0, stop=100, step=10)

Results are stored in the individual instances see AnalysisBase on how to access them. You can also save all results of the analysis within one call:

>>> collection.save()
run(start: int | None = None, stop: int | None = None, step: int | None = None, frames: int | None = None, verbose: bool | None = None, progressbar_kwargs: dict | None = None) Self[source]#

Iterate over the trajectory.

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

  • stop (int) – stop frame of analysis

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

  • frames (array_like) – 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.

  • verbose (bool) – Turn on verbosity

  • progressbar_kwargs (dict) – ProgressBar keywords with custom parameters regarding progress bar position, etc; see MDAnalysis.lib.log.ProgressBar for full list.

Returns:

self – analysis object

Return type:

object

save() None[source]#

Save results of all analysis_instances to disk.

The methods calls the save() method of all analysis_instances if available. If an instance has no save() method a warning for this instance is issued.