Analysis Classes¶
Classes for groove width and torsion angle analysis.
mdna.analysis.GrooveAnalysis
¶
Compute minor and major groove widths from a DNA trajectory.
Extracts phosphorus-atom positions from the two DNA strands, fits cubic splines through them, and measures inter-strand distances to derive groove widths for every frame.
Attributes:
| Name | Type | Description |
|---|---|---|
minor_widths |
ndarray
|
Minor-groove widths, shape |
major_widths |
ndarray
|
Major-groove widths, shape |
sequence |
list[str]
|
Sense-strand sequence letters. |
base_pairs |
list[str]
|
Base-pair labels (e.g. |
Example
Source code in mdna/analysis.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | |
__init__(raw_traj, points=None, parallel=joblib_available)
¶
Initialize groove analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_traj
|
Trajectory
|
Trajectory containing at least two DNA chains. |
required |
points
|
int
|
Number of spline interpolation points.
Defaults to |
None
|
parallel
|
bool
|
Use joblib for parallel computation when available. |
joblib_available
|
Source code in mdna/analysis.py
compute_groove_widths()
¶
Compute groove widths for all frames (parallel or sequential).
Populates :attr:minor_widths and :attr:major_widths.
Source code in mdna/analysis.py
describe()
¶
find_first_local_minimum(arr)
staticmethod
¶
Return the first local minimum in arr, or NaN if none exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
ndarray
|
1-D array of values. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
minimum |
float
|
First local minimum value. |
Source code in mdna/analysis.py
fit_cubic_spline()
¶
Fit cubic splines through phosphorus positions and compute inter-strand distances.
Populates :attr:pairs, :attr:distances, and :attr:distance_matrices.
Source code in mdna/analysis.py
fit_curves(traj, points)
¶
Interpolate atom positions with a cubic spline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
Trajectory
|
Single-strand phosphorus trajectory. |
required |
points
|
int
|
Number of interpolation points. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
coordinates |
ndarray
|
Interpolated coordinates. |
Source code in mdna/analysis.py
get_anti_diagonal_slices(matrix)
staticmethod
¶
Extract all anti-diagonal slices from a square matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix
|
ndarray
|
Square distance matrix. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
slices |
list[ndarray]
|
Anti-diagonal slices. |
Source code in mdna/analysis.py
get_minor_major_widths(distance_matrix)
¶
Compute minor and major groove widths from one distance matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance_matrix
|
ndarray
|
Inter-strand distance matrix for a single frame. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
widths |
tuple[list[float], list[float]]
|
|
Source code in mdna/analysis.py
get_phosphors_only_traj(raw_traj)
¶
Extract phosphorus-only sub-trajectories for each strand.
Populates :attr:DNA_traj, :attr:phos_traj, :attr:strand_A,
and :attr:strand_B.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_traj
|
Trajectory
|
Full trajectory. |
required |
Source code in mdna/analysis.py
plot_groove_widths(minor=True, major=True, std=True, color='k', c_minor=None, lw=0.5, c_major=None, ax=None, base_labels=True, ls='-')
¶
Plot minor and/or major groove widths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
minor
|
bool
|
Plot minor groove widths. |
True
|
major
|
bool
|
Plot major groove widths. |
True
|
std
|
bool
|
Show standard-deviation shading. |
True
|
color
|
str
|
Fallback colour when c_minor/c_major are not set. |
'k'
|
c_minor
|
str
|
Minor-groove colour. |
None
|
c_major
|
str
|
Major-groove colour. |
None
|
lw
|
float
|
Line width. |
0.5
|
ax
|
Axes
|
Target axes. A new figure
is created if |
None
|
base_labels
|
bool
|
Label the x-axis with base-pair identifiers. |
True
|
ls
|
str
|
Line style. |
'-'
|
Returns:
| Name | Type | Description |
|---|---|---|
result |
tuple | None
|
|
Source code in mdna/analysis.py
plot_width(ax, groove, color=None, std=True, ls='-', lw=0.5)
¶
Plot mean groove width with optional standard-deviation shading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
Target axes. |
required |
groove
|
ndarray
|
Groove-width array, shape |
required |
color
|
str
|
Line colour. |
None
|
std
|
bool
|
If True, shade the ±1σ region. |
True
|
ls
|
str
|
Line style. |
'-'
|
lw
|
float
|
Line width. |
0.5
|
Source code in mdna/analysis.py
split_array(array)
staticmethod
¶
Split an anti-diagonal slice into minor and major halves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
ndarray
|
Anti-diagonal slice. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
halves |
tuple[ndarray, ndarray]
|
|
Source code in mdna/analysis.py
mdna.analysis.TorsionAnalysis
¶
Compute backbone torsion angles and BI/BII conformational states.
Calculates the epsilon and zeta dihedral angles of the DNA backbone and classifies each base step as BI or BII based on the sign of epsilon − zeta.
Attributes:
| Name | Type | Description |
|---|---|---|
epsilon |
ndarray
|
Epsilon torsion angles, shape |
zeta |
ndarray
|
Zeta torsion angles, shape |
B_state |
ndarray
|
Fraction of BII per base step. |
Source code in mdna/analysis.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 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 | |
__init__(traj, degrees=True, chain=0)
¶
Initialize torsion analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
Trajectory
|
DNA-containing trajectory. |
required |
degrees
|
bool
|
Report angles in degrees (default) or radians. |
True
|
chain
|
int
|
Chain index to analyse (0 = sense, 1 = anti-sense). |
0
|
Source code in mdna/analysis.py
compute_BI_BII(degrees=True)
¶
Compute epsilon and zeta backbone torsion angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degrees
|
bool
|
Return angles in degrees. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
angles |
tuple[ndarray, ndarray]
|
|
Source code in mdna/analysis.py
convert_torsion_indices_to_atom_indices(torsion_indices)
¶
Convert atom objects to integer indices for MDTraj.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
torsion_indices
|
list[list]
|
Torsion atom-object groups. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
atom_indices |
list[list[int]]
|
Integer atom indices. |
Source code in mdna/analysis.py
get_B_state(diff)
¶
Classify each base step as BI (0) or BII (1) from epsilon−zeta.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diff
|
ndarray
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
state |
ndarray
|
BII fraction per base step. |
Source code in mdna/analysis.py
get_backbone_indices(chainid, ref_atoms)
¶
Collect backbone atom objects matching ref_atoms from a chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chainid
|
int
|
Chain index. |
required |
ref_atoms
|
list[str]
|
Atom names to select (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
indices |
list
|
Atom objects. |
Source code in mdna/analysis.py
get_torsion_indices(chainid, ref_atoms)
¶
Get torsion-angle atom groups for a chain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
chainid
|
int
|
Chain index. |
required |
ref_atoms
|
list[str]
|
Atom-name pattern. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
torsions |
list[list]
|
Torsion atom groups. |
Source code in mdna/analysis.py
get_torsions(indices, ref_atoms)
¶
Group sequential atoms into torsion-angle quartets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
list
|
Ordered backbone atom objects. |
required |
ref_atoms
|
list[str]
|
Reference atom-name pattern for one torsion. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
torsions |
list[list]
|
Each element is a four-atom group defining one torsion. |
Source code in mdna/analysis.py
load_trajectory_and_slice_dna(traj)
¶
Slice a trajectory to keep only canonical DNA residues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
traj
|
Trajectory
|
Input trajectory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dna |
Trajectory
|
Sub-trajectory containing DG, DC, DA, and DT residues. |