Skip to content

Commit

Permalink
added plot and traj rgy tools
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCox822 committed Feb 24, 2024
1 parent cc0875f commit 7fd4c3a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
8 changes: 7 additions & 1 deletion mdagent/tools/base_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from .analysis_tools.analysis_props import RadiusofGyrationAverage
from .analysis_tools.plot_tools import SimulationOutputFigures
from .analysis_tools.ppi_tools import PPIDistance
from .analysis_tools.rgy import (
RadiusofGyrationAverage,
RadiusofGyrationPerFrame,
RadiusofGyrationPlot,
)
from .analysis_tools.rmsd_tools import RMSDCalculator
from .analysis_tools.vis_tools import (
CheckDirectoryFiles,
Expand Down Expand Up @@ -46,6 +50,8 @@
"RMSDCalculator",
"RemoveWaterCleaningTool",
"RadiusofGyrationAverage",
"RadiusofGyrationPerFrame",
"RadiusofGyrationPlot",
"Scholar2ResultLLM",
"SerpGitTool",
"SetUpAndRunTool",
Expand Down
4 changes: 3 additions & 1 deletion mdagent/tools/base_tools/analysis_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from .analysis_props import RadiusofGyrationAverage
from .plot_tools import SimulationOutputFigures
from .ppi_tools import PPIDistance
from .rgy import RadiusofGyrationAverage, RadiusofGyrationPerFrame, RadiusofGyrationPlot
from .rmsd_tools import RMSDCalculator
from .vis_tools import CheckDirectoryFiles, VisFunctions, VisualizeProtein

__all__ = [
"PPIDistance",
"RMSDCalculator",
"RadiusofGyrationPerFrame",
"RadiusofGyrationPlot",
"SimulationOutputFigures",
"CheckDirectoryFiles",
"VisualizeProtein",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,57 @@ def _run(self, pdb_id: str) -> str:
async def _arun(self, query: str) -> str:
"""Use the tool asynchronously."""
raise NotImplementedError("custom_search does not support async")


class RadiusofGyrationPerFrame(BaseTool):
name = "RadiusofGyrationPerFrame"
description = """This tool calculates the radius of gyration
at each frame of a given trajectory file. Give this tool the
protein ID (PDB ID) only. The tool will automatically find the necessary files.
The tool will save the radii of gyration to a csv file and
map it to the registry."""

path_registry: Optional[PathRegistry]

def __init__(self, path_registry):
super().__init__()
self.path_registry = path_registry

def _run(self, pdb_id: str) -> str:
"""use the tool."""
try:
RGY = RadiusofGyration(self.path_registry)
return RGY.rad_gyration_per_frame(pdb_id)
except ValueError as e:
return str(e)

async def _arun(self, query: str) -> str:
"""Use the tool asynchronously."""
raise NotImplementedError("custom_search does not support async")


class RadiusofGyrationPlot(BaseTool):
name = "RadiusofGyrationPlot"
description = """This tool calculates the radius of gyration
at each frame of a given trajectory file and plots it.
Give this tool the protein ID (PDB ID) only.
The tool will automatically find the necessary files.
The tool will save the plot to a png file and map it to the registry."""

path_registry: Optional[PathRegistry]

def __init__(self, path_registry):
super().__init__()
self.path_registry = path_registry

def _run(self, pdb_id: str) -> str:
"""use the tool."""
try:
RGY = RadiusofGyration(self.path_registry)
return RGY.plot_rad_gyration(pdb_id)
except ValueError as e:
return str(e)

async def _arun(self, query: str) -> str:
"""Use the tool asynchronously."""
raise NotImplementedError("custom_search does not support async")
4 changes: 4 additions & 0 deletions mdagent/tools/maketools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
PPIDistance,
ProteinName2PDBTool,
RadiusofGyrationAverage,
RadiusofGyrationPerFrame,
RadiusofGyrationPlot,
RMSDCalculator,
Scholar2ResultLLM,
SetUpandRunFunction,
Expand Down Expand Up @@ -87,6 +89,8 @@ def make_all_tools(
SmallMolPDB(path_registry=path_instance),
VisualizeProtein(path_registry=path_instance),
RadiusofGyrationAverage(path_registry=path_instance),
RadiusofGyrationPerFrame(path_registry=path_instance),
RadiusofGyrationPlot(path_registry=path_instance),
PPIDistance(),
RMSDCalculator(),
SetUpandRunFunction(path_registry=path_instance),
Expand Down

0 comments on commit 7fd4c3a

Please sign in to comment.