Skip to content

Commit

Permalink
[bugfix] mcdock args
Browse files Browse the repository at this point in the history
  • Loading branch information
Hong-Rui Lin committed Apr 16, 2024
1 parent ac8fbce commit 5b98771
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
23 changes: 18 additions & 5 deletions unidock_tools/src/unidock_tools/application/mcdock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Union, Tuple
from typing import List, Tuple, Union, Optional
from pathlib import Path
import os
import time
Expand All @@ -10,7 +10,6 @@

from unidock_tools.utils import time_logger, randstr, make_tmp_dir, MolGroup
from unidock_tools.modules.confgen import generate_conf
#from unidock_tools.modules.protein_prep import pdb2pdbqt
from unidock_tools.modules.protein_prep import receptor_preprocessor
from unidock_tools.modules.ligand_prep import TopologyBuilder
from unidock_tools.modules.docking import run_unidock
Expand Down Expand Up @@ -62,6 +61,11 @@ def __init__(self,
size_x: float = 22.5,
size_y: float = 22.5,
size_z: float = 22.5,
kept_ligand_resname_list: Optional[List[str]] = None,
prepared_hydrogen: bool = True,
preserve_original_resname: bool = True,
covalent_residue_atom_info_list: Optional[List[Tuple[str, str]]] = None,
generate_ad4_grids: bool = False,
gen_conf: bool = True,
max_nconf: int = 1000,
min_rmsd: float = 0.5,
Expand All @@ -85,9 +89,18 @@ def __init__(self,
self.workdir = workdir
self.workdir.mkdir(parents=True, exist_ok=True)
if receptor.suffix == ".pdb":
receptor_pdbqt_file_name, ad4_maps_prefix = receptor_preprocessor(str(receptor), working_dir_name=str(workdir))
receptor_pdbqt_file_name, protein_grid_prefix = receptor_preprocessor(str(receptor),
kept_ligand_resname_list=kept_ligand_resname_list,
prepared_hydrogen=prepared_hydrogen,
preserve_original_resname=preserve_original_resname,
target_center=(center_x, center_y, center_z),
box_size=(size_x, size_y, size_z),
covalent_residue_atom_info_list=covalent_residue_atom_info_list,
generate_ad4_grids=generate_ad4_grids,
working_dir_name=str(workdir))

self.receptor = receptor_pdbqt_file_name
self.ad4_maps_prefix = ad4_maps_prefix
self.ad4_map_prefix = protein_grid_prefix
else:
logging.error("receptor file must be PDB format!!")
exit(1)
Expand Down Expand Up @@ -197,7 +210,7 @@ def run_unidock(self,
receptor=self.receptor, ligands=ligand_list, output_dir=output_dir,
center_x=self.center_x, center_y=self.center_y, center_z=self.center_z,
size_x=self.size_x, size_y=self.size_y, size_z=self.size_z,
scoring=scoring_function, ad4_maps_prefix=self.ad4_maps_prefix, num_modes=num_modes,
scoring=scoring_function, ad4_map_prefix=self.ad4_map_prefix, num_modes=num_modes,
search_mode=search_mode, exhaustiveness=exhaustiveness, max_step=max_step,
seed=seed, refine_step=refine_step, energy_range=energy_range,
score_only=score_only, local_only=local_only,
Expand Down
25 changes: 10 additions & 15 deletions unidock_tools/src/unidock_tools/application/unidock_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,18 @@ def __init__(self,
logging.error('receptor file must be in PDB format!')
exit(1)
else:
receptor_pdbqt_file_name = receptor_preprocessor(str(receptor),
kept_ligand_resname_list=kept_ligand_resname_list,
prepared_hydrogen=prepared_hydrogen,
preserve_original_resname=preserve_original_resname,
target_center=(center_x, center_y, center_z),
box_size=(size_x, size_y, size_z),
covalent_residue_atom_info_list=covalent_residue_atom_info_list,
generate_ad4_grids=generate_ad4_grids,
working_dir_name=str(workdir))
receptor_pdbqt_file_name, protein_grid_prefix = receptor_preprocessor(str(receptor),
kept_ligand_resname_list=kept_ligand_resname_list,
prepared_hydrogen=prepared_hydrogen,
preserve_original_resname=preserve_original_resname,
target_center=(center_x, center_y, center_z),
box_size=(size_x, size_y, size_z),
covalent_residue_atom_info_list=covalent_residue_atom_info_list,
generate_ad4_grids=generate_ad4_grids,
working_dir_name=str(workdir))

self.receptor = receptor_pdbqt_file_name

if generate_ad4_grids:
receptor_file_dir_name = os.path.dirname(self.receptor)
self.ad4_map_prefix = os.path.join(receptor_file_dir_name, 'protein')
else:
self.ad4_map_prefix = ''
self.ad4_map_prefix = protein_grid_prefix

self.mols = sum([read_ligand(ligand) for ligand in ligands], [])
self.mols = [PropertyMol(mol) for mol in self.mols]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def receptor_preprocessor(
)
runner.run()
protein_pdbqt_file_name = runner.protein_pdbqt_file_name
ad4_maps_prefix = runner.protein_grid_prefix
return protein_pdbqt_file_name, ad4_maps_prefix
protein_grid_prefix = runner.protein_grid_prefix
return protein_pdbqt_file_name, protein_grid_prefix


if __name__ == "__main__":
Expand Down Expand Up @@ -154,7 +154,7 @@ def parse_covalent_residue_atom_info(covalent_residue_atom_info_str: str) -> Lis

args = parser.parse_args()

protein_pdbqt_file_name, ad4_maps_prefix = receptor_preprocessor(
protein_pdbqt_file_name, protein_grid_prefix = receptor_preprocessor(
protein_pdb_file_name=args.protein_pdb,
kept_ligand_resname_list=args.kept_ligand_resname_list,
prepared_hydrogen=args.prepared_hydrogen,
Expand Down
2 changes: 1 addition & 1 deletion unidock_tools/tests/ut/proprep/test_receptor_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_receptor_preprocessor(pdb_file):
from unidock_tools.modules.protein_prep import receptor_preprocessor
# Create a temporary working directory
with tempfile.TemporaryDirectory() as temp_dir:
protein_pdbqt_file_name, ad4_maps_prefix = receptor_preprocessor(pdb_file, prepared_hydrogen=True, working_dir_name=temp_dir)
protein_pdbqt_file_name, protein_grid_prefix = receptor_preprocessor(pdb_file, prepared_hydrogen=True, working_dir_name=temp_dir)
# Assert that the generated PDBQT file exists
assert os.path.exists(protein_pdbqt_file_name)

Expand Down

0 comments on commit 5b98771

Please sign in to comment.