molclusters.conntable¶
conntable
¶
Defines the ConnectionTable class, which manages molecular connectivity tables for analyzing molecular clusters. It uses NetworkX for graph-based operations and MDAnalysis for molecular dynamics trajectory analysis.
Classes:
- ConnectionTable: Represents a connectivity table for molecular clusters, allowing operations
such as retrieving connections, subgraphs, and constructing connectivity graphs.
Functions:
- check_resids: Checks that the residues are numbered 1 to N, as MolClusters needs.
Dependencies:
- MDAnalysis: For molecular dynamics trajectory and structure analysis.
- NetworkX: For graph-based operations on molecular connectivity.
- NumPy: For numerical computations.
- HydrogenBondAnalysis: For analyzing hydrogen bonds between molecules.
ConnectionTable
¶
ConnectionTable(universe: Universe, cluster_args: SymmetricDict[str, Rule], selections: dict[str, AtomGroup], backend: DistanceBackend = 'serial')
Represents a connectivity table for molecular clusters.
This class manages molecular connectivity data using NetworkX graphs and provides methods for retrieving connections, constructing subgraphs, and updating connectivity tables.
Attributes:
| Name | Type | Description |
|---|---|---|
uni |
Universe
|
The MDAnalysis Universe object associated with the molecular system. |
clst_args |
SymmetricDict[str, Rule]
|
The clustering arguments specifying connectivity rules. |
sels |
dict[str, AtomGroup]
|
The atom groups for each residue type. |
conntab |
MultiGraph
|
The connectivity graph representing molecular connections. |
cms |
dict[str, ndarray]
|
The center of mass for each residue type. |
hbs |
SymmetricDict[str, HydrogenBondAnalysis]
|
The hydrogen bond analysis objects for residue pairs. |
backend |
DistanceBackend
|
The MDAnalysis acceleration backend used for "cm" rule distance calculations.
MDAnalysis silently ignores this for its "nsgrid" method, which it
auto-selects whenever the cutoff is much smaller than the box (the common
case for realistic systems), so switching this doesn't always change timing.
Even when it is used, "OpenMP" is a no-op on builds where MDAnalysis's
|
rule_connections |
Counter[tuple[str, str]]
|
The connections each rule (keyed as in |
Initialize the ConnectionTable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
Universe
|
The MDAnalysis Universe object associated with the molecular system. |
required |
cluster_args
|
dict[str, dict[str, tuple[str, float]]]
|
The clustering arguments specifying connectivity rules. |
required |
selections
|
dict[str, AtomGroup]
|
The atom groups for each residue type. |
required |
backend
|
DistanceBackend
|
The MDAnalysis acceleration backend for "cm" rule distance calculations
(see the class docstring's |
'serial'
|
Source code in src/molclusters/conntable.py
__get_mass_centers
¶
Calculate the whole center of mass of each molecule, per residue type.
__start_hbonds
¶
Initialize hydrogen bond analysis for residue pairs.
Source code in src/molclusters/conntable.py
__cm_connections
¶
Find the molecules connected by a center-of-mass ("cm") rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resi
|
str
|
The rule's first residue name. |
required |
resj
|
str
|
The rule's second residue name. |
required |
box
|
ndarray
|
The simulation box dimensions, used for periodic boundary conditions. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, dict[str, ndarray]]
|
An |
Source code in src/molclusters/conntable.py
__hb_connections
¶
Find the molecules connected by a hydrogen bond ("hb") rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resi
|
str
|
The rule's first residue name. |
required |
resj
|
str
|
The rule's second residue name. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, dict[str, ndarray]]
|
An |
Source code in src/molclusters/conntable.py
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | |
__construct_table
¶
Construct the connectivity table as a graph.
Source code in src/molclusters/conntable.py
update
¶
__getitem__
¶
Get the attributes of a connection or molecule in the connectivity table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
(tuple[int, int], int)
|
The molecule or connection to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
(float, list[int])
|
The attributes of the connection or molecule. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the key is invalid or not found in the connectivity table. |
Source code in src/molclusters/conntable.py
__contains__
¶
__iter__
¶
connections_from
¶
connection_tree_from
¶
Get the connection tree from a molecule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mol
|
int
|
The molecule to retrieve the connection tree from. |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[int, int]]
|
A list of connections in the tree. |
Source code in src/molclusters/conntable.py
mols_connected_to
¶
mols_connected_tree_to
¶
Get the molecules in the connection tree of a given molecule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mol
|
int
|
The molecule to retrieve the connection tree for. |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
A list of molecules in the connection tree. |
Source code in src/molclusters/conntable.py
__subgraphs
¶
Generate subgraphs of the connectivity table.
Yields:
| Type | Description |
|---|---|
Graph
|
A subgraph of the connectivity table. |
Source code in src/molclusters/conntable.py
subconntables
¶
subconntables() -> Generator[_SubConnTable, None, None]
Generate sub-connectivity tables from the connectivity table.
Yields:
| Type | Description |
|---|---|
_SubConnTable
|
A sub-connectivity table. |
Source code in src/molclusters/conntable.py
check_resids
¶
Check that the residues are numbered 1, 2, ..., N in topology order.
MolClusters identifies molecules by resid (in the connection graphs, the
clusters and the outputs) and finds their residues back by position, as
resid - 1. Any other numbering (an offset, gaps, repeats) would silently
put molecules in the wrong clusters and compute their properties on the
wrong atoms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
Universe
|
The Universe to check. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If a residue's resid isn't its position in the topology plus one. |