Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

secondary structure analysis fix #153

Merged
merged 17 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
34 changes: 20 additions & 14 deletions mdagent/tools/base_tools/analysis_tools/secondary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ class ComputeDSSP(BaseTool):
residue at each time point."""
path_registry: PathRegistry = PathRegistry.get_instance()
simplified: bool = True
last_only: bool = True

def __init__(self, path_registry: PathRegistry, simplified: bool = True):
def __init__(
self, path_registry: PathRegistry, simplified: bool = True, last_only=True
):
super().__init__()
self.path_registry = path_registry
self.simplified = simplified
self.last_only = last_only

def _dssp_codes(self) -> list[str]:
"""
Expand All @@ -71,21 +75,21 @@ def _dssp_natural_language(self) -> dict[str, str]:
used. Otherwise, the full set of codes is used."""
if self.simplified:
return {
"H": "helix",
"E": "strand",
"C": "coil",
"NA": "not assigned, not a protein residue",
"H": "residues in helix",
"E": "residues in strand",
"C": "residues in coil",
"NA": "residues not assigned, not a protein residue",
}
return {
"H": "alpha helix",
"B": "beta bridge",
"E": "extended strand",
"G": "three helix",
"I": "five helix",
"T": "hydrogen bonded turn",
"S": "bend",
" ": "loop or irregular",
"NA": "not assigned, not a protein residue",
"H": "residues in alpha helix",
"B": "residues in beta bridge",
"E": "residues in extended strand",
"G": "residues in three helix",
"I": "residues in five helix",
"T": "residues in hydrogen bonded turn",
"S": "residues in bend",
" ": "residues in loop or irregular",
"NA": "residues not assigned, not a protein residue",
}

def _convert_dssp_counts(self, dssp_counts: dict) -> dict:
Expand Down Expand Up @@ -160,6 +164,8 @@ def _run(self, traj_file: str, top_file: Optional[str] = None) -> str:
)
if not traj:
raise Exception("Trajectory could not be loaded.")
if self.last_only and len(traj) > 1:
traj = traj[-1]
except Exception as e:
print("Error loading trajectory: ", e)
return str(e)
Expand Down
69 changes: 0 additions & 69 deletions notebooks/eval_demo/ckpt_eval/individual_eval_20240422-181241.json

This file was deleted.

69 changes: 0 additions & 69 deletions notebooks/eval_demo/ckpt_eval/individual_eval_20240422-181533.json

This file was deleted.

Loading
Loading