From 5b98771741d563a2c2fdd828f963b2a9ce7316e4 Mon Sep 17 00:00:00 2001 From: Hong-Rui Lin Date: Tue, 16 Apr 2024 21:41:12 +0800 Subject: [PATCH] [bugfix] mcdock args --- .../src/unidock_tools/application/mcdock.py | 23 +++++++++++++---- .../application/unidock_pipeline.py | 25 ++++++++----------- .../receptor_preprocessor_runner.py | 6 ++--- .../ut/proprep/test_receptor_processor.py | 2 +- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/unidock_tools/src/unidock_tools/application/mcdock.py b/unidock_tools/src/unidock_tools/application/mcdock.py index 10d1f53..8f7d960 100644 --- a/unidock_tools/src/unidock_tools/application/mcdock.py +++ b/unidock_tools/src/unidock_tools/application/mcdock.py @@ -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 @@ -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 @@ -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, @@ -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) @@ -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, diff --git a/unidock_tools/src/unidock_tools/application/unidock_pipeline.py b/unidock_tools/src/unidock_tools/application/unidock_pipeline.py index b35a51f..2a8267f 100644 --- a/unidock_tools/src/unidock_tools/application/unidock_pipeline.py +++ b/unidock_tools/src/unidock_tools/application/unidock_pipeline.py @@ -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] diff --git a/unidock_tools/src/unidock_tools/modules/protein_prep/receptor_preprocessor_runner.py b/unidock_tools/src/unidock_tools/modules/protein_prep/receptor_preprocessor_runner.py index b7746b2..dbb848c 100644 --- a/unidock_tools/src/unidock_tools/modules/protein_prep/receptor_preprocessor_runner.py +++ b/unidock_tools/src/unidock_tools/modules/protein_prep/receptor_preprocessor_runner.py @@ -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__": @@ -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, diff --git a/unidock_tools/tests/ut/proprep/test_receptor_processor.py b/unidock_tools/tests/ut/proprep/test_receptor_processor.py index efb40da..515da14 100644 --- a/unidock_tools/tests/ut/proprep/test_receptor_processor.py +++ b/unidock_tools/tests/ut/proprep/test_receptor_processor.py @@ -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)