Skip to content

Commit

Permalink
72 lack of solvents for packmol tool (#73)
Browse files Browse the repository at this point in the history
* Improve path_registry init to initialize with files already downloaded in the files/ directory

* Fixing packmol: 1. Moving the input validator inside the tool. 2. Packmol needs the pdb files in the same directory. files/pdb doesn't work; Corrected copy and pasting temporarily the pdb files from the path_registry and deleting after termination

* Solved unrelated bugs in cleaning tools, mainly from path_registry calls.

* Add new tool to make pdb files from small molecules names or smiles. Also include this functionality directly in packmol function with new parameter small_molecules. (#76)

---------

Co-authored-by: Sam Cox <[email protected]>
  • Loading branch information
Jgmedina95 and SamCox822 authored Feb 7, 2024
1 parent a56cfe8 commit eaa4f17
Show file tree
Hide file tree
Showing 10 changed files with 726 additions and 184 deletions.
10 changes: 8 additions & 2 deletions mdagent/tools/base_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
RemoveWaterCleaningTool,
SpecializedCleanTool,
)
from .preprocess_tools.pdb_tools import Name2PDBTool, PackMolTool, get_pdb
from .preprocess_tools.pdb_tools import (
PackMolTool,
ProteinName2PDBTool,
SmallMolPDB,
get_pdb,
)
from .simulation_tools.create_simulation import ModifyBaseSimulationScriptTool
from .simulation_tools.setup_and_run import (
InstructionSummary,
Expand All @@ -32,9 +37,10 @@
"InstructionSummary",
"ListRegistryPaths",
"MapPath2Name",
"Name2PDBTool",
"ProteinName2PDBTool",
"PackMolTool",
"PPIDistance",
"SmallMolPDB",
"VisualizeProtein",
"RMSDCalculator",
"RemoveWaterCleaningTool",
Expand Down
5 changes: 3 additions & 2 deletions mdagent/tools/base_tools/preprocess_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
RemoveWaterCleaningTool,
SpecializedCleanTool,
)
from .pdb_tools import Name2PDBTool, PackMolTool, get_pdb
from .pdb_tools import PackMolTool, ProteinName2PDBTool, SmallMolPDB, get_pdb

__all__ = [
"AddHydrogensCleaningTool",
"CleaningTools",
"Name2PDBTool",
"ProteinName2PDBTool",
"PackMolTool",
"RemoveWaterCleaningTool",
"SpecializedCleanTool",
"get_pdb",
"CleaningToolFunction",
"SmallMolPDB",
]
16 changes: 8 additions & 8 deletions mdagent/tools/base_tools/preprocess_tools/clean_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,17 @@ def _run(self, **input_args) -> str:
file_description = "Cleaned File: "
CleaningTools()
try:
pdbfile = self.path_registry.get_mapped_path(pdbfile_id)
if "/" in pdbfile:
pdbfile = pdbfile.split("/")[-1]

name = pdbfile.split("_")[0]
end = pdbfile.split(".")[1]
pdbfile_path = self.path_registry.get_mapped_path(pdbfile_id)
if "/" in pdbfile_path:
pdbfile = pdbfile_path.split("/")[-1]
else:
pdbfile = pdbfile_path
name, end = pdbfile.split(".")

except Exception as e:
print(f"error retrieving from path_registry, trying to read file {e}")
return "File not found in path registry. "
fixer = PDBFixer(filename=pdbfile)
fixer = PDBFixer(filename=pdbfile_path)
try:
fixer.findMissingResidues()
except Exception:
Expand Down Expand Up @@ -353,7 +353,7 @@ def _run(self, **input_args) -> str:
file_mode = "w" if add_hydrogens else "a"
file_name = self.path_registry.write_file_name(
type=FileType.PROTEIN,
protein_name=name,
protein_name=name.split("_")[0],
description="Clean",
file_format=end,
)
Expand Down
Loading

0 comments on commit eaa4f17

Please sign in to comment.