Skip to content

Commit

Permalink
ensure that rgy figs aren't overwriting each other
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCox822 committed Aug 6, 2024
1 parent 59b9f2c commit 108aacd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mdagent/tools/base_tools/analysis_tools/rgy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Optional

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -80,16 +81,25 @@ def plot_rad_gyration(self, pdb_id: str) -> str:
plot_id = self.path_registry.get_fileid(
file_name=plot_name, type=FileType.FIGURE
)
if plot_name.ends_with(".png"):
plot_name = plot_name.split(".png"[0])
plot_path = next(
f"{self.path_registry.ckpt_figures}/{plot_name}_{i}.png"
for i in range(1000)
if not os.path.exists(
f"{self.path_registry.ckpt_figures}/{plot_name}_{i}.png"
)
)

plt.plot(rg_per_frame)
plt.xlabel("Frame")
plt.ylabel("Radius of Gyration (nm)")
plt.title(f"{pdb_id} - Radius of Gyration Over Time")

plt.savefig(f"{self.path_registry.ckpt_figures}/{plot_name}")
plt.savefig(f"{plot_path}")
self.path_registry.map_path(
plot_id,
f"{self.path_registry.ckpt_figures}/{plot_name}",
plot_path,
description=f"Plot of radii of gyration over time for {self.pdb_id}",
)
plt.close()
Expand Down

0 comments on commit 108aacd

Please sign in to comment.