Skip to content

Commit 341267f

Browse files
authored
Merge pull request #145 from talagayev/fix_last_frame
Fix last frame modified
2 parents f576084 + b1f7fcd commit 341267f

File tree

5 files changed

+61
-17
lines changed

5 files changed

+61
-17
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Bug report
3+
about: Create a report to tell about a bug or problem you encountered
4+
5+
---
6+
7+
## Bug Behavior ##
8+
9+
<!-- A description of what happens. (Code to reproduce the behavior can be added below). Please check that your bug is consistently reproducable -->
10+
11+
## Additional Information ##
12+
13+
- Which OpenMMDL version are you using? (version displayed in `conda list` of your environment as `openmmdl`)
14+
- Which version of Python (`python -V`)?
15+
- Which operating system do you use?
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea or feature for OpenMMDL
4+
5+
---
6+
7+
## Describe the feature you would like to have ##
8+
<!-- A description of the feature you want to have. For example, I'd like to be able to do [...].
9+
You can also add code snippets how it can look like. -->
10+
11+
12+
## Additional context ##
13+
<!-- Add any other context, links of repositories that can be used for the feature
14+
or screenshots about the feature request here. -->

.github/pull_request_template.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!--
2+
Insert issue number that this PR fixes (if any) just after 'Fixes #'.
3+
If this PR does not fix an existing issue, consider opening one or remove 'Fixes #' from the PR description.
4+
-->
5+
Fixes #
6+
7+
Changes made:
8+
<!-- Describe the changes that this PR makes. -->
9+
-
10+
11+
## PR Checklist
12+
<!-- Please use the following checklist to ensure the PR is ready to be reviewed/merged. -->
13+
- [ ] Issue raised/referenced?
14+
- [ ] Tests updated/added?
15+
- [ ] Documentation updated/added?
16+
- [ ] `CHANGELOG` file updated?
17+
- [ ] Is your name in `AUTHORS`?

openmmdl/openmmdl_analysis/interaction_gathering.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
class InteractionAnalyzer:
1515
def __init__(
16-
self, pdb_md, dataframe, num_processes, lig_name, special_ligand, peptide
16+
self, pdb_md, dataframe, num_processes, lig_name, special_ligand, peptide, md_len
1717
):
1818
self.pdb_md = pdb_md
1919
self.dataframe = dataframe
2020
self.num_processes = num_processes
2121
self.lig_name = lig_name
2222
self.special = special_ligand
2323
self.peptide = peptide
24+
self.md_len = md_len
2425
self.ineraction_list = self.process_trajectory()
2526

2627
def characterize_complex(
@@ -386,15 +387,14 @@ def fill_missing_frames(self, df):
386387
pandas dataframe: DataFrame with placeholder values in the frames with no interactions.
387388
"""
388389

389-
md_len = len(self.pdb_md.trajectory) - 1
390390
# Create a set containing all unique values in the 'FRAME' column
391391
existing_frames = set(df["FRAME"])
392392

393393
# Create a list to store new rows for missing numbers
394394
missing_rows = []
395395

396396
# Iterate through numbers from 0 to md_len
397-
for frame_number in range(1, md_len):
397+
for frame_number in range(1, self.md_len):
398398
if frame_number not in existing_frames:
399399
# Create a new row with 'FRAME' set to the missing number and other columns set to "skip"
400400
missing_row = {"FRAME": frame_number}
@@ -428,17 +428,16 @@ def process_trajectory(self):
428428
if self.dataframe is None:
429429
print("\033[1mProcessing protein-ligand trajectory\033[0m")
430430
print(f"\033[1mUsing {self.num_processes} CPUs\033[0m")
431-
total_frames = len(self.pdb_md.trajectory) - 1
432431

433432
with Pool(processes=self.num_processes) as pool:
434433
frame_args = [
435434
(i, self.pdb_md, self.lig_name, self.special, self.peptide)
436-
for i in range(1, total_frames + 1)
435+
for i in range(1, self.md_len)
437436
]
438437

439438
# Initialize the progress bar with the total number of frames
440439
pbar = tqdm(
441-
total=total_frames,
440+
total=self.md_len - 1,
442441
ascii=True,
443442
desc="\033[1mAnalyzing frames\033[0m",
444443
)

openmmdl/openmmdl_analysis/openmmdlanalysis.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,6 @@ def main():
268268
if not pdb_md:
269269
pdb_md = mda.Universe(topology, trajectory)
270270

271-
if frames != None:
272-
print(f"\033[1mWriting out the first {frames} out for the analysis\033[0m")
273-
ag = pdb_md.select_atoms("all")
274-
with DCDWriter(f"{frames}.dcd", ag.n_atoms) as w:
275-
for ts in pdb_md.trajectory[: int(frames) + 1]:
276-
w.write(ag)
277-
pdb_md = mda.Universe(topology, f"{frames}.dcd")
278-
279271
trajsaver = TrajectorySaver(pdb_md, ligand, special_ligand, receptor_nucleic)
280272

281273
# TODO maybe put this part into a function possibly in visualization_functions.py TrajectorySaver
@@ -382,8 +374,17 @@ def main():
382374
if peptide != None:
383375
config.PEPTIDES = [peptide]
384376

377+
md_len = args.frames
378+
if md_len is None:
379+
md_len = len(pdb_md.trajectory)
380+
print(type(md_len))
381+
print(f"\033[1mThe whole trajectory consisting of {len(pdb_md.trajectory) - 1} frames will be analyzed\033[0m")
382+
else:
383+
md_len = int(md_len) + 1
384+
print(f"\033[1mThe trajectory until frame {md_len - 1} will be analyzed\033[0m")
385+
385386
interaction_analysis = InteractionAnalyzer(
386-
pdb_md, dataframe, cpu_count, ligand, special_ligand, peptide
387+
pdb_md, dataframe, cpu_count, ligand, special_ligand, peptide, md_len
387388
)
388389
interaction_list = interaction_analysis.ineraction_list
389390
interaction_list.to_csv("missing_frames_filled.csv")
@@ -823,8 +824,6 @@ def main():
823824
topology, "representative_waters.pdb", water_eps
824825
)
825826

826-
if frames != None:
827-
os.remove(f"{frames}.dcd")
828827

829828
if __name__ == "__main__":
830829
main()

0 commit comments

Comments
 (0)