molclusters¶
The package exports the names most code needs (see the overview).
MolClusters, the runner, is defined in molclusters.molclusters:
molclusters
¶
Provides the MolClusters class for analyzing molecular clusters in molecular dynamics simulations.
Classes:
- MolClusters: Runs the analyses the config enables (and any given ones) on the clusters of every frame of a trajectory.
The clusters themselves, and their ids, are tracked by tracker.ClusterTracker;
the analyses are in the analysis package.
Dependencies:
- MDAnalysis: For molecular dynamics trajectory and structure analysis.
- NumPy: For numerical computations.
- tqdm: For progress tracking during analysis.
MolClusters
¶
MolClusters(universe: Universe, config: MolClsConfig, analyses: Iterable[FrameAnalysis] = ())
A class for analyzing molecular clusters in molecular dynamics simulations.
It tracks the clusters frame by frame and runs the analyses on them: the
built-ins the config enables (cluster sizes, lineage, solute-solvent,
coordinates, nuclei; see analysis.builtins), then the ones given to it, then the JSON
report, which every other analysis can add to.
A built-in runs when the config options it needs are set, unless the
config's analyses turns it off.
Attributes:
| Name | Type | Description |
|---|---|---|
uni |
Universe
|
The MDAnalysis Universe object associated with the simulation. |
config |
MolClsConfig
|
The analysis configuration. |
tracker |
ClusterTracker | None
|
Follows the clusters frame by frame, keeping their ids stable; created by
|
analyses |
list[FrameAnalysis]
|
The analyses run on the clusters of every frame: the built-ins the config
enables, then the given ones, then the report (see |
output |
RunOutput
|
Where the last run wrote its files. |
Initialize the MolClusters object.
The residues must be numbered 1 to N in topology order; otherwise a
ValueError says so (see conntable.check_resids).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
Universe
|
The MDAnalysis Universe object associated with the simulation. |
required |
config
|
MolClsConfig
|
The analysis configuration. |
required |
analyses
|
Iterable[FrameAnalysis]
|
Analyses to run in addition to the ones the config enables, after them (but before the report) and in the order given. |
()
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If one of |
Source code in src/molclusters/molclusters.py
analysis
¶
analysis(kind: type[T]) -> T | None
Find the first of the analyses of type kind, for its results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
type[T]
|
The analysis class to look for (subclasses match too). |
required |
Returns:
| Type | Description |
|---|---|
T | None
|
The analysis, or None if there's none (e.g. the config doesn't enable that built-in, or turns it off). |
Source code in src/molclusters/molclusters.py
__check_resnames
¶
Warn about residue names in the config that the topology doesn't have.
A misspelled or missing name selects no atoms, so everything built on it would silently come out empty.
Source code in src/molclusters/molclusters.py
__check_previous_outputs
¶
__check_previous_outputs(directory: Path) -> None
Tell which results of an earlier run in the output directory get overwritten.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path
|
The directory this run writes to. |
required |
Source code in src/molclusters/molclusters.py
__check_leftover_outputs
¶
Warn about an earlier run's output files that this run didn't overwrite.
Families of files (e.g. one .gro file per cluster id) needn't have the same members from one run to the next, so some of the files in the output directory may still be an earlier run's.
Source code in src/molclusters/molclusters.py
__declared_outputs
¶
__declared_outputs() -> list[OutputFile]
List the files this run writes, in the order they're reported.
Returns:
| Type | Description |
|---|---|
list[OutputFile]
|
The analyses' outputs, in the order of the analyses. |
Source code in src/molclusters/molclusters.py
__log_rule_connections
¶
__log_rule_connections(n_frames: int) -> None
Log how many connections each rule found, warning about unused rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_frames
|
int
|
The number of frames analysed. |
required |
Source code in src/molclusters/molclusters.py
run
¶
Track the clusters over the whole trajectory and run the analyses on them.
Every run starts over from the first frame with a new tracker (cluster ids
start from 1 again), and the analyses start over in prepare, so running
again gives the same results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_dir
|
Path | str | None
|
The directory to write the results to, created if missing; the current directory when None. |
None
|