-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rmsd tool draft * fixed name2pdb to catch error properly * tested and optimized name2pdb and rmsd tools * updated rmsd notebook results * updated test.yml * updated name2pdb test * separated ppi distance and rmsd tools (expanded) * fixed minor error in FixPDBFile tool * fixed multi-input tool for ppi distance * changed error handling for ppi distance tool * fixed rmsd tools * reorganized tools to prepare for multiagent merge * fixed make_llm * fixed makellm and added paths_registry.json to ignore list * fixed python_repl import * fixed langchain imports * updated gpt4 to gpt4 turbo
- Loading branch information
Showing
27 changed files
with
681 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,3 +138,4 @@ dmypy.json | |
|
||
# generated files for testing | ||
*registry.json | ||
*paths_registry.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ channels: | |
dependencies: | ||
- openmm >= 7.6 | ||
- pdbfixer >= 1.5 | ||
- mdanalysis | ||
- pip | ||
- pip: | ||
- flake8 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,3 @@ | ||
from .agent import MDAgent, make_tools | ||
from .tools import ( | ||
CheckDirectoryFiles, | ||
CleaningTools, | ||
PlanBVisualizationTool, | ||
Scholar2ResultLLM, | ||
SetUpAndRunTool, | ||
SimulationFunctions, | ||
SimulationOutputFigures, | ||
VisFunctions, | ||
VisualizationToolRender, | ||
get_pdb, | ||
) | ||
from .utils import PathRegistry | ||
from .agent import MDAgent | ||
|
||
__all__ = [ | ||
"MDAgent", | ||
"Scholar2ResultLLM", | ||
"Name2PDBTool", | ||
"SimulationFunctions", | ||
"make_tools", | ||
"VisFunctions", | ||
"CleaningTools", | ||
"MDAgent", | ||
"VisualizationToolRender", | ||
"CheckDirectoryFiles", | ||
"PlanBVisualizationTool", | ||
"SetUpAndRunTool", | ||
"PathRegistry", | ||
"SimulationOutputFigures", | ||
"get_pdb", | ||
] | ||
__all__ = ["MDAgent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from .agent import MDAgent | ||
from .tools import make_tools | ||
|
||
__all__ = ["MDAgent", "make_tools"] | ||
__all__ = ["MDAgent"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,3 @@ | ||
from .clean_tools import ( | ||
AddHydrogensCleaningTool, | ||
CleaningTools, | ||
RemoveWaterCleaningTool, | ||
SpecializedCleanTool, | ||
) | ||
from .git_issues_tool import SerpGitTool | ||
from .md_util_tools import Name2PDBTool, get_pdb | ||
from .pdb_tools import PackMolTool | ||
from .plot_tools import SimulationOutputFigures | ||
from .registry_tools import ListRegistryPaths, MapPath2Name | ||
from .search_tools import Scholar2ResultLLM | ||
from .setup_and_run import SetUpAndRunTool, SimulationFunctions | ||
from .vis_tools import ( | ||
CheckDirectoryFiles, | ||
PlanBVisualizationTool, | ||
VisFunctions, | ||
VisualizationToolRender, | ||
) | ||
from .maketools import make_all_tools | ||
|
||
__all__ = [ | ||
"Scholar2ResultLLM", | ||
"VisFunctions", | ||
"CleaningTools", | ||
"SimulationFunctions", | ||
"VisualizationToolRender", | ||
"CheckDirectoryFiles", | ||
"PlanBVisualizationTool", | ||
"get_pdb", | ||
"SpecializedCleanTool", | ||
"RemoveWaterCleaningTool", | ||
"AddHydrogensCleaningTool", | ||
"SetUpAndRunTool", | ||
"CheckDirectoryFiles", | ||
"PlanBVisualizationTool", | ||
"SimulationOutputFigures", | ||
"SerpGitTool", | ||
"PackMolTool", | ||
"ListRegistryPaths", | ||
"MapPath2Name", | ||
"Name2PDBTool", | ||
] | ||
__all__ = ["make_all_tools"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from .clean_tools import ( | ||
AddHydrogensCleaningTool, | ||
CleaningTools, | ||
RemoveWaterCleaningTool, | ||
SpecializedCleanTool, | ||
) | ||
from .git_issues_tool import SerpGitTool | ||
from .md_util_tools import Name2PDBTool, get_pdb | ||
from .pdb_tools import PackMolTool | ||
from .plot_tools import SimulationOutputFigures | ||
from .ppi_tools import PPIDistance | ||
from .registry_tools import ListRegistryPaths, MapPath2Name | ||
from .rmsd_tools import RMSDCalculator | ||
from .search_tools import Scholar2ResultLLM | ||
from .setup_and_run import InstructionSummary, SetUpAndRunTool, SimulationFunctions | ||
from .vis_tools import ( | ||
CheckDirectoryFiles, | ||
PlanBVisualizationTool, | ||
VisFunctions, | ||
VisualizationToolRender, | ||
) | ||
|
||
__all__ = [ | ||
"AddHydrogensCleaningTool", | ||
"CheckDirectoryFiles", | ||
"CleaningTools", | ||
"InstructionSummary", | ||
"ListRegistryPaths", | ||
"MapPath2Name", | ||
"Name2PDBTool", | ||
"PackMolTool", | ||
"PPIDistance", | ||
"PlanBVisualizationTool", | ||
"RMSDCalculator", | ||
"RemoveWaterCleaningTool", | ||
"Scholar2ResultLLM", | ||
"SerpGitTool", | ||
"SetUpAndRunTool", | ||
"SimulationFunctions", | ||
"SimulationOutputFigures", | ||
"SpecializedCleanTool", | ||
"VisFunctions", | ||
"VisualizationToolRender", | ||
"get_pdb", | ||
] |
File renamed without changes.
14 changes: 6 additions & 8 deletions
14
mdagent/tools/git_issues_tool.py → mdagent/tools/base_tools/git_issues_tool.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from typing import Optional, Type | ||
|
||
import MDAnalysis as mda | ||
import MDAnalysis.analysis.distances as mda_dist | ||
import numpy as np | ||
from langchain.tools import BaseTool | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
def ppi_distance(pdb_file, binding_site="protein"): | ||
""" | ||
Calculates minimum heavy-atom distance between peptide (assumed to be | ||
smallest chain) and protein. Returns average distance between these two. | ||
Can specify binding site if given (optional) | ||
Can work with any protein-protein interaction (PPI) | ||
""" | ||
# load and find smallest chain | ||
u = mda.Universe(pdb_file) | ||
peptide = None | ||
for chain in u.segments: | ||
if peptide is None or len(chain.residues) < len(peptide): | ||
peptide = chain.residues | ||
protein = u.select_atoms( | ||
f"({binding_site}) and not segid {peptide.segids[0]} and not name H*" | ||
) | ||
peptide = peptide.atoms.select_atoms("not name H*") | ||
all_d = [] | ||
for r in peptide.residues: | ||
distances = mda_dist.distance_array(r.atoms.positions, protein.positions) | ||
# get row, column of minimum distance | ||
i, j = np.unravel_index(distances.argmin(), distances.shape) | ||
all_d.append(distances[i, j]) | ||
avg_dist = np.mean(all_d) | ||
return avg_dist | ||
|
||
|
||
class PPIDistanceInputSchema(BaseModel): | ||
pdb_file: str = Field( | ||
description="file with .pdb extension containing protein-protein interaction" | ||
) | ||
binding_site: Optional[str] = Field( | ||
description="""a list of selected residues as the binding site | ||
of the protein using MDAnalysis selection syntax.""" | ||
) | ||
|
||
|
||
class PPIDistance(BaseTool): | ||
name: str = "ppi_distance" | ||
description: str = """Useful for calculating minimum heavy-atom distance | ||
between peptide and protein. First, make sure you have valid PDB file with | ||
any protein-protein interaction.""" | ||
args_schema: Type[BaseModel] = PPIDistanceInputSchema | ||
|
||
def _run(self, pdb_file: str, binding_site: str = "protein"): | ||
if not pdb_file.endswith(".pdb"): | ||
return "Error with input: PDB file must have .pdb extension" | ||
try: | ||
avg_dist = ppi_distance(pdb_file, binding_site=binding_site) | ||
except ValueError as e: | ||
return ( | ||
f"ValueError: {e}. \nMake sure to provide valid PBD " | ||
"file and binding site using MDAnalysis selection syntax." | ||
) | ||
except Exception as e: | ||
return f"Something went wrong. {type(e).__name__}: {e}" | ||
return f"{avg_dist}\n" | ||
|
||
def _arun(self, pdb_file: str, binding_site: str = "protein"): | ||
raise NotImplementedError("This tool does not support async") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.