Skip to content

Commit afcb1d4

Browse files
authored
Merge pull request #140 from talagayev/add_last_frame
Add last frame
2 parents 5233c5a + 6df8500 commit afcb1d4

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The rules for this file:
2222
talagayev, NDoering99
2323

2424
### Added
25-
- Changed to the use of `RDKitConverter` for Ligand recognition without `-l` flag in `OpenMMDL Analysis` (2025-04-10)
25+
- Addition of option to select final frame in OpenMMDL Analysis (2025-04-23, Issue #136, PR #140)
2626
- Addition of `MDontallo` Visualization (2025-04-11)
2727
- Addition of `SMIRNOFF` small molecule force field (2025-04-10, Issue #76)
2828
- Addition of `PyMOL` support for visualization (2025-04-10)
@@ -37,6 +37,8 @@ talagayev, NDoering99
3737

3838
### Changed
3939
- The class `TrajectorySaver` was moved to `trajectory_saving.py` (2025-04-24, Issue #141, PR #142)
40+
- Changed to the use of `RDKitConverter` for Ligand recognition
41+
without `-l` flag in `OpenMMDL Analysis` (2025-04-10)
4042

4143
### Deprecated
4244
<!-- Soon-to-be removed features -->

docs/openmmdl_analysis.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Optional:
3232
-l = Ligand in SDF format
3333
-b = binding mode threshold. Is used to remove interactions under the defined procentual occurence from the binding mode generation. The default is 40% (accepted values: 0-100)
3434
-df = Dataframe (use if the interactions were already calculated, default name would be "interactions_gathered.csv")
35+
-f = final frame of the analysis (if you want to analyze only a certain part of the trajectory). The default will be the full simulation trajectory analysis.
3536
-m = minimal transition threshold. Is used for the display of the binding mode transitions in the Markov state chains network figure. The default value is 1
3637
-c = CPU count, specify how many CPUs should be used, default is half of the CPU count.
3738
-p = Generate .pml files for pharmacophore visualization. The default is False (accepted values: True/False)

openmmdl/openmmdl_analysis/openmmdlanalysis.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from rdkit.Chem.Draw import rdMolDraw2D
2828
from plip.basic import config
2929
from MDAnalysis.analysis import rms
30+
from MDAnalysis.coordinates.DCD import DCDWriter
3031
from tqdm import tqdm
3132

3233

@@ -102,6 +103,12 @@ def main():
102103
help='Dataframe (use if the interactions were already calculated, default name would be "df_all.csv")',
103104
default=None,
104105
)
106+
parser.add_argument(
107+
"-f",
108+
dest="frames",
109+
help="final frame of the analysis (if you want to analyze only a certain part of the trajectory)",
110+
default=None,
111+
)
105112
parser.add_argument(
106113
"-m",
107114
dest="min_transition",
@@ -162,14 +169,12 @@ def main():
162169
help="Calculate the representative frame for each binding mode. Defaults to False",
163170
default=False,
164171
)
165-
166172
parser.add_argument(
167173
"--watereps",
168174
dest="water_eps",
169175
help="Set the Eps for clustering, this defines how big clusters can be spatially in Angstrom",
170176
default=1.0,
171177
)
172-
173178
parser.add_argument(
174179
"--figure",
175180
dest="figure_type",
@@ -268,6 +273,14 @@ def main():
268273
if not pdb_md:
269274
pdb_md = mda.Universe(topology, trajectory)
270275

276+
if frames != None:
277+
print(f"\033[1mWriting out the first {frames} out for the analysis\033[0m")
278+
ag = pdb_md.select_atoms("all")
279+
with DCDWriter(f"{frames}.dcd", ag.n_atoms) as w:
280+
for ts in pdb_md.trajectory[: int(frames) + 1]:
281+
w.write(ag)
282+
pdb_md = mda.Universe(topology, f"{frames}.dcd")
283+
271284
trajsaver = TrajectorySaver(pdb_md, ligand, special_ligand, receptor_nucleic)
272285

273286
# TODO maybe put this part into a function possibly in visualization_functions.py TrajectorySaver
@@ -815,6 +828,8 @@ def main():
815828
topology, "representative_waters.pdb", water_eps
816829
)
817830

831+
if frames != None:
832+
os.remove(f"{frames}.dcd")
818833

819834
if __name__ == "__main__":
820835
main()

0 commit comments

Comments
 (0)