You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/howto/compute-dihedrals.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ print(f"psi(17) after : {np.degrees(mol.getDihedral(psi17)):.1f}°")
34
34
| Method / argument | What it does |
35
35
|---|---|
36
36
|`mol.getDihedral(atom_quad)`| Returns the dihedral angle in **radians** for the four atom indices in `atom_quad`. Operates on the current `mol.frame`. |
37
-
|`mol.setDihedral(atom_quad, radians, bonds=None, guessBonds=False)`| Rotates the downstream half of the molecule around the central bond of the dihedral so the angle becomes `radians`. For a chain of modifications pass `bonds=mol._getBonds()` once to keep the bond table from being re-guessed on every call. |
37
+
|`mol.setDihedral(atom_quad, radians, bonds=None, guessBonds=False)`| Rotates the downstream half of the molecule around the central bond of the dihedral so the angle becomes `radians`. For a chain of modifications pass `bonds=mol.bonds` (or a pre-built bond array) once to keep the bond table from being re-built on every call. |
38
38
39
39
## Common variations
40
40
@@ -59,7 +59,7 @@ angles = np.array([
59
59
60
60
- Both `getDihedral` and `dihedralAngle` return angles in **radians**; convert with `np.degrees(angle)` if you want degrees.
61
61
-`mol.getDihedral` operates on the current `mol.frame` — set `mol.frame = i` first if you want a specific frame.
62
-
-`mol.setDihedral` rotates the downstream side of the dihedral in place; the upstream side is held fixed. If the topology is ambiguous (the rotation would split the molecule wrong), the call may fail — guard against this by passing an explicit `bonds=` array.
62
+
-`mol.setDihedral` rotates the downstream side of the dihedral in place; the upstream side is held fixed. If the topology is ambiguous (the rotation would split the molecule wrong), the call may fail — guard against this by passing an explicit `bonds=mol.bonds` array.
63
63
- For computing many dihedrals at once across a trajectory, prefer {py:class}`~moleculekit.projections.metricdihedral.MetricDihedral` from `moleculekit.projections.metricdihedral` — it batches the work efficiently.
|`toRDKitMol(sanitize=True)`|Convert the ligand selection to an RDKit Mol for feature detection. |
51
-
|`RDConfig.RDDataDir / "BaseFeatures.fdef"`| RDKit's standard donor/acceptor feature definition file. |
52
-
|`start_idx`|Offset of the first ligand atom in the parent `Molecule`; required when the ligand does not start at atom 0. |
53
-
|`hbonds_calculate(mol, donors, acceptors, sel2=...)`| Returns a list (one entry per frame) of H-bond arrays. |
41
+
|{py:class}`~moleculekit.smallmol.smallmol.SmallMol`|Lightweight RDKit-backed view of the ligand used by the helper to walk the bond graph. |
42
+
|`start_idx`| Offset of the first ligand atom in the parent `Molecule`; the helper adds it so the returned indices reference the parent. |
43
+
|`get_ligand_donors_acceptors(smol, start_idx=...)`|Returns `(donors, acceptors)`. `donors` is a `(N, 2)` array of `[heavy_atom_idx, hydrogen_idx]` pairs; `acceptors` is a 1D array of heavy-atom indices. |
44
+
|`hbonds_calculate(mol, donors, acceptors, sel2=...)`| Returns a list (one entry per frame) of H-bonds; each entry is a list of `(donor_heavy, donor_h, acceptor)` triples. |
54
45
55
46
## Common variations
56
47
57
48
```python
58
-
#Visualise H-bonds in VMD (requires VMD on PATH)
59
-
from moleculekit.interactions.interactions import view_hbonds
60
-
61
-
view_hbonds(mol, hbonds)
49
+
#Convert the per-frame list of triples into a single numpy array of donors,
print("donor heavy atoms, Hs, acceptors:\n", frame0)
62
53
```
63
54
64
55
```python
@@ -75,9 +66,9 @@ rings = get_protein_rings(mol)
75
66
76
67
## Gotchas
77
68
78
-
- Reasonable hydrogens must be present — run {py:func}`~moleculekit.tools.preparation.systemPrepare`before this step if the input lacks explicit H atoms.
79
-
-Feature detection uses RDKit through {py:meth}`~moleculekit.molecule.Molecule.toRDKitMol`; make sure RDKit is installed.
80
-
-`start_idx` is critical when the ligand atoms do not start at index 0 in the parent molecule.
69
+
- Reasonable hydrogens must be present — run {py:func}`~moleculekit.tools.preparation.systemPrepare`(or pass `addHs=True` to {py:meth}`~moleculekit.molecule.Molecule.templateResidueFromSmiles`) before this step.
70
+
- {py:func}`~moleculekit.interactions.interactions.get_ligand_donors_acceptors` returns donor *pairs*`[heavy, H]`, **not** lone heavy atoms. Building your own pairs as `(heavy, heavy)` silently produces wrong H-bond results because `hbonds_calculate` reads column 1 as the hydrogen index.
71
+
-`start_idx` is critical when the ligand atoms do not start at index 0 in the parent molecule — the helper offsets every returned index by `start_idx`.
81
72
- For non-periodic structures set `mol.box` to a zero array before calling `hbonds_calculate`.
- {py:func}`~moleculekit.util.molRMSD` computes raw (non-mass-weighted) RMSD; align the structures first if you want to remove rigid-body motion.
52
55
- RMSF is per-atom and depends on the choice of reference (mean structure); the result is sensitive to conformational heterogeneity.
53
56
- Both `mol` and `refmol` must have the same number of selected atoms.
54
-
- {py:class}`~moleculekit.projections.metricfluctuation.MetricFluctuation` returns an `(n_frames, n_atoms)` array — use `rmsf.mean(axis=0)` to get a per-atom fluctuation averaged over all frames.
57
+
- {py:class}`~moleculekit.projections.metricfluctuation.MetricFluctuation` returns **squared** per-atom displacement (`(n_frames, n_atoms)`, units Ų). For RMSF you must take `np.sqrt(sq_disp.mean(axis=0))` — `sq_disp.mean(axis=0)` alone is mean-squared-fluctuation, not RMSF.
- RCSB downloads respect the server rate limits; avoid hammering the API in tight loops.
56
65
- Set the `LOCAL_PDB_REPO` environment variable to a local PDB mirror directory to avoid repeated network downloads.
57
-
- OPM membership requires a known PDB ID or a successful BLAST sequence alignment; structures absent from OPM will raise or return `None`.
66
+
- OPM membership requires a known PDB ID or a successful BLAST sequence alignment; when nothing matches, {py:func}`~moleculekit.opm.align_to_opm` returns an **empty list** (not `None`).
67
+
- {py:func}`~moleculekit.opm.align_to_opm` returns a `list[dict]` — the aligned `Molecule` objects live under `hit["hsps"][j]["aligned_mol"]`, not at the top level.
58
68
- {py:func}`~moleculekit.opm.get_opm_pdb` with `keep=False` (default) strips the dummy membrane atoms that OPM adds; pass `keep=True` if you need them for visualization.
- All frames are loaded into memory at once; for very long trajectories use `frames=` to read a slice.
50
+
- All frames are loaded into memory at once; for very long trajectories use `skip` or `frames=` to read a subset.
45
51
- The atom count of the trajectory must exactly match the topology — a mismatch raises an error.
46
-
-`skip` and `frames` can be combined: `frames` selects the subset to consider, then `skip` further subsamples within that subset.
52
+
-`frames=` is **per file**: when reading a single trajectory it must be a length-1 list whose single element is either an int or a list of ints (e.g. `frames=[[0, 10, 20]]`). For uniform subsampling prefer `skip=`.
53
+
-`skip` strides the final merged coordinate array; it applies independently of `frames` and is the simplest way to subsample a long trajectory.
47
54
- When `append=False` (default) a second `mol.read(traj)` call replaces the existing coordinates rather than extending them.
0 commit comments