|
16 | 16 |
|
17 | 17 |
|
18 | 18 | def make_Universe(top: pathlib.Path, trj: nc.Dataset, state: int) -> mda.Universe: |
19 | | - """Makes a Universe and applies some transformations |
| 19 | + """ |
| 20 | + Construct an MDAnalysis Universe from a MultiState NetCDF trajectory |
| 21 | + and apply standard analysis transformations. |
| 22 | +
|
| 23 | + The Universe is created using the custom ``FEReader`` to extract a |
| 24 | + single state from a multistate simulation. |
| 25 | +
|
| 26 | + Parameters |
| 27 | + ---------- |
| 28 | + top : pathlib.Path or Topology |
| 29 | + Path to a topology file (e.g. PDB) or an already-loaded MDAnalysis |
| 30 | + topology object. |
| 31 | + trj : nc.Dataset |
| 32 | + Open NetCDF dataset produced by |
| 33 | + ``openmmtools.multistate.MultiStateReporter``. |
| 34 | + state : int |
| 35 | + Thermodynamic state index to extract from the multistate trajectory. |
| 36 | +
|
| 37 | + Returns |
| 38 | + ------- |
| 39 | + MDAnalysis.Universe |
| 40 | + A Universe with trajectory transformations applied. |
20 | 41 |
|
| 42 | + Notes |
| 43 | + ----- |
21 | 44 | Identifies two AtomGroups: |
22 | 45 | - protein, defined as having standard amino acid names, then filtered |
23 | 46 | down to CA |
24 | 47 | - ligand, defined as resname UNK |
25 | 48 |
|
26 | | - Then applies some transformations. |
| 49 | + Depending on whether a protein is present, a sequence of trajectory |
| 50 | + transformations is applied: |
27 | 51 |
|
28 | 52 | If a protein is present: |
29 | | - - prevents the protein from jumping between periodic images |
30 | | - - moves the ligand to the image closest to the protein |
31 | | - - aligns the entire system to minimise the protein RMSD |
32 | | -
|
33 | | - If only a ligand: |
34 | | - - prevents the ligand from jumping between periodic images |
| 53 | + - Unwraps protein and ligand atom to be made whole |
| 54 | + - Shifts protein chains and the ligand to the image closest to the first |
| 55 | + protein chain (:class:`ClosestImageShift`) |
| 56 | + - Aligns the entire system to minimise the protein RMSD (:class:`Aligner`) |
| 57 | +
|
| 58 | + If only a ligand is present: |
| 59 | + - Prevents the ligand from jumping between periodic images |
| 60 | + - Aligns the ligand to minimize its RMSD |
35 | 61 | """ |
36 | 62 | u = mda.Universe( |
37 | 63 | top, |
@@ -76,23 +102,39 @@ def make_Universe(top: pathlib.Path, trj: nc.Dataset, state: int) -> mda.Univers |
76 | 102 | def gather_rms_data( |
77 | 103 | pdb_topology: pathlib.Path, dataset: pathlib.Path, skip: Optional[int] = None |
78 | 104 | ) -> dict[str, list[float]]: |
79 | | - """Generate structural analysis of RBFE simulation |
| 105 | + """ |
| 106 | + Compute structural RMSD-based metrics for a multistate BFE simulation. |
80 | 107 |
|
81 | 108 | Parameters |
82 | 109 | ---------- |
83 | 110 | pdb_topology : pathlib.Path |
84 | | - path to pdb topology |
| 111 | + Path to the PDB file defining system topology. |
85 | 112 | dataset : pathlib.Path |
86 | | - path to nc trajectory |
| 113 | + Path to the NetCDF trajectory file produced by a multistate simulation. |
87 | 114 | skip : int, optional |
88 | | - step at which to progress through the trajectory. by default, selects a |
89 | | - step that produces roughly 500 frames of analysis per replicate |
90 | | -
|
91 | | - Produces, for each lambda state: |
92 | | - - 1D protein RMSD timeseries 'protein_RMSD' |
93 | | - - ligand RMSD timeseries |
94 | | - - ligand COM motion 'ligand_wander' |
95 | | - - 2D protein RMSD plot |
| 115 | + Frame stride for analysis. If ``None``, a stride is chosen such that |
| 116 | + approximately 500 frames are analyzed per state. |
| 117 | +
|
| 118 | + Returns |
| 119 | + ------- |
| 120 | + dict[str, list] |
| 121 | + Dictionary containing per-state analysis results with keys: |
| 122 | + ``protein_RMSD``, ``ligand_RMSD``, ``ligand_wander``, |
| 123 | + ``protein_2D_RMSD``, and ``time(ps)``. |
| 124 | +
|
| 125 | + Notes |
| 126 | + ----- |
| 127 | + For each thermodynamic state (lambda), this function: |
| 128 | + - Loads the trajectory using ``FEReader`` |
| 129 | + - Applies standard PBC-handling and alignment transformations |
| 130 | + - Computes protein and ligand structural metrics over time |
| 131 | +
|
| 132 | + The following analyses are produced per state: |
| 133 | + - 1D protein CA RMSD time series |
| 134 | + - 1D ligand RMSD time series |
| 135 | + - Ligand center-of-mass displacement from its initial position |
| 136 | + (``ligand_wander``) |
| 137 | + - Flattened 2D protein RMSD matrix (pairwise RMSD between frames) |
96 | 138 | """ |
97 | 139 | output = { |
98 | 140 | "protein_RMSD": [], |
@@ -187,19 +229,25 @@ def gather_rms_data( |
187 | 229 |
|
188 | 230 |
|
189 | 231 | def twoD_RMSD(positions, w: Optional[npt.NDArray]) -> list[float]: |
190 | | - """2 dimensions RMSD |
| 232 | + """ |
| 233 | + Compute a flattened 2D RMSD matrix from a trajectory. |
| 234 | +
|
| 235 | + For all unique frame pairs ``(i, j)`` with ``i < j``, this function |
| 236 | + computes the RMSD between atomic coordinates after optimal alignment. |
191 | 237 |
|
192 | 238 | Parameters |
193 | 239 | ---------- |
194 | 240 | positions : np.ndarray |
195 | | - the protein positions for the entire trajectory |
| 241 | + Atomic coordinates for all frames in the trajectory. |
196 | 242 | w : np.ndarray, optional |
197 | | - weights array |
| 243 | + Per-atom weights to use in the RMSD calculation. If ``None``, |
| 244 | + all atoms are weighted equally. |
198 | 245 |
|
199 | 246 | Returns |
200 | 247 | ------- |
201 | | - rmsd_matrix : list |
202 | | - a flattened version of the 2d |
| 248 | + list of float |
| 249 | + Flattened list of RMSD values corresponding to all frame pairs |
| 250 | + ``(i, j)`` with ``i < j``. |
203 | 251 | """ |
204 | 252 | nframes, _, _ = positions.shape |
205 | 253 |
|
|
0 commit comments