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
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | |
__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. |