From 183dbd8c537009603e9b8eeb90db833fc7607a67 Mon Sep 17 00:00:00 2001 From: zhangplpl Date: Mon, 8 Apr 2024 17:27:04 +0800 Subject: [PATCH] changed test_proprep.py and for mcdock.py del pdb2pdbqt add receptor_processor --- .../src/unidock_tools/application/mcdock.py | 9 ++++++--- .../tests/applications/test_proprep.py | 19 +++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/unidock_tools/src/unidock_tools/application/mcdock.py b/unidock_tools/src/unidock_tools/application/mcdock.py index b3b933e..7d96194 100644 --- a/unidock_tools/src/unidock_tools/application/mcdock.py +++ b/unidock_tools/src/unidock_tools/application/mcdock.py @@ -10,7 +10,8 @@ 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 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 from .unidock_pipeline import Base, UniDock @@ -84,8 +85,10 @@ def __init__(self, self.workdir = workdir self.workdir.mkdir(parents=True, exist_ok=True) if receptor.suffix == ".pdb": - pdb2pdbqt(receptor, workdir.joinpath(receptor.stem + ".pdbqt")) - receptor = workdir.joinpath(receptor.stem + ".pdbqt") + #pdb2pdbqt(receptor, workdir.joinpath(receptor.stem + ".pdbqt")) + #receptor = workdir.joinpath(receptor.stem + ".pdbqt") + receptor_pdbqt_file_name = receptor_preprocessor(receptor, working_dir_name=workdir) + self.receptor = receptor_pdbqt_file_name if receptor.suffix != ".pdbqt": logging.error("receptor file must be pdb/pdbqt format") exit(1) diff --git a/unidock_tools/tests/applications/test_proprep.py b/unidock_tools/tests/applications/test_proprep.py index 0a8f35b..5d2e20e 100644 --- a/unidock_tools/tests/applications/test_proprep.py +++ b/unidock_tools/tests/applications/test_proprep.py @@ -1,20 +1,19 @@ import os -import shutil import tempfile import subprocess import pytest -#from unidocktools.new_proteinprep import receptor_preprocessor @pytest.fixture def pdb_file(): - temp_dir = tempfile.mkdtemp() - pdb_file = os.path.join(temp_dir, "protein.pdb") - yield pdb_file - shutil.rmtree(temp_dir) + return os.path.join(os.path.dirname(os.path.dirname(__file__)), "inputs", "protein.pdb") def test_receptor_processor_app(pdb_file): protein_pdbqt_file_name = "protein.pdbqt" - cmd = f"unidocktools proteinprep -r {pdb_file} -o {protein_pdbqt_file_name}" - subprocess.run(cmd, shell=True) - assert os.path.isfile(protein_pdbqt_file_name), "PDBQT file was not generated" - os.remove(protein_pdbqt_file_name) \ No newline at end of file + with tempfile.TemporaryDirectory() as work_dir: + cmd = f"unidocktools proteinprep -r {pdb_file} -o {protein_pdbqt_file_name} -H -w {work_dir}" + subprocess.run(cmd, shell=True, cwd=work_dir) + assert os.path.isfile(os.path.join(work_dir, protein_pdbqt_file_name)), "PDBQT file was not generated" + + +if __name__ == "__main__": + pytest.main([__file__]) \ No newline at end of file