Skip to content

Commit

Permalink
fix:tool app add default args
Browse files Browse the repository at this point in the history
  • Loading branch information
dp-yuanyn committed Mar 6, 2024
1 parent 76bed36 commit 5d7c60a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 15 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci_test_tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
pip install flake8
- name: Run flake8 formating
working-directory: ./unidock_tools
run: |
flake8 unidock_tools/unidock_tools --exit-zero
flake8 src --exit-zero
pyright:
continue-on-error: true
Expand All @@ -48,7 +49,7 @@ jobs:
id: pyright_check
working-directory: ./unidock_tools
run: |
pyright
pyright src
tests:
if: ${{ always() }}
Expand Down Expand Up @@ -84,10 +85,12 @@ jobs:
pip install .
- name: run unit-test
working-directory: ./unidock_tools
run: |
pip install pytest pytest-cov
pytest unidock_tools/tests/ut -vv --cov --cov-report term
pytest tests/ut -vv --cov --cov-report term
- name: run application e2e test
working-directory: ./unidock_tools
run: |
pytest unidock_tools/tests/applications -vv --cov --cov-report term
pytest tests/applications -vv --cov --cov-report term
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ unidock/example/screening_test/unidock_root
unidock/example/screening_test/test_dock
unidock_tools/dist
unidock_tools/dist/*
unidock_tools/unidock_tools.egg-info
unidock_tools/unidock_tools.egg-info/*
*.egg-info
48 changes: 42 additions & 6 deletions unidock_tools/src/unidock_tools/application/mcdock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@
from .unidock_pipeline import UniDock


DEFAULT_ARGS = {
"receptor": None,
"ligands": None,
"ligand_index": None,
"gen_conf": False,
"max_num_confs_per_ligand": 200,
"min_rmsd": 0.3,
"center_x": None,
"center_y": None,
"center_z": None,
"size_x": 22.5,
"size_y": 22.5,
"size_z": 22.5,
"workdir": "mcdock_workdir",
"savedir": "mcdock_results",
"batch_size": 1200,
"scoring_function_rigid_docking": "vina",
"search_mode_rigid_docking": "",
"exhaustiveness_rigid_docking": 128,
"max_step_rigid_docking": 20,
"num_modes_rigid_docking": 3,
"refine_step_rigid_docking": 3,
"topn_rigid_docking": 100,
"scoring_function_local_refine": "vina",
"search_mode_local_refine": "",
"exhaustiveness_local_refine": 512,
"max_step_local_refine": 40,
"num_modes_local_refine": 1,
"refine_step_local_refine": 3,
"topn_local_refine": 1,
"seed": 181129,
"debug": False,
}


class MultiConfDock(UniDock):
def __init__(self,
receptor: Path,
Expand Down Expand Up @@ -69,6 +104,7 @@ def generate_conformation(self,


def main(args: dict):
args = {**DEFAULT_ARGS, **args}
if args["debug"]:
logging.getLogger().setLevel("DEBUG")

Expand Down Expand Up @@ -154,7 +190,7 @@ def get_parser() -> argparse.ArgumentParser:
help="Receptor file in pdbqt format.")
parser.add_argument("-l", "--ligands", type=lambda s: s.split(','), default=None,
help="Ligand file in sdf format. Specify multiple files separated by commas.")
parser.add_argument("-i", "--ligand_index", type=str, default="",
parser.add_argument("-i", "--ligand_index", type=str, default=None,
help="A text file containing the path of ligand files in sdf format.")

parser.add_argument("-g", "--gen_conf", action="store_true",
Expand All @@ -181,8 +217,8 @@ def get_parser() -> argparse.ArgumentParser:
help="Working directory. Default: 'MultiConfDock'.")
parser.add_argument("-sd", "--savedir", type=str, default="mcdock_results",
help="Save directory. Default: 'MultiConfDock-Result'.")
parser.add_argument("-bs", "--batch_size", type=int, default=20,
help="Batch size for docking. Default: 20.")
parser.add_argument("-bs", "--batch_size", type=int, default=1200,
help="Batch size for docking. Default: 1200.")

parser.add_argument("-sf_rd", "--scoring_function_rigid_docking",
type=str, default="vina",
Expand All @@ -200,7 +236,7 @@ def get_parser() -> argparse.ArgumentParser:
type=int, default=3,
help="Number of modes used in rigid docking. Default: 3.")
parser.add_argument("-rs_rd", "--refine_step_rigid_docking",
type=int, default=5,
type=int, default=3,
help="Refine step used in rigid docking. Default: 3.")
parser.add_argument("-topn_rd", "--topn_rigid_docking",
type=int, default=100,
Expand All @@ -222,8 +258,8 @@ def get_parser() -> argparse.ArgumentParser:
type=int, default=1,
help="Number of modes used in local refine. Default: 1.")
parser.add_argument("-rs_lr", "--refine_step_local_refine",
type=int, default=5,
help="Refine step used in local refine. Default: 5.")
type=int, default=3,
help="Refine step used in local refine. Default: 3.")
parser.add_argument("-topn_lr", "--topn_local_refine",
type=int, default=1,
help="Top N results used in local refine. Default: 1.")
Expand Down
35 changes: 32 additions & 3 deletions unidock_tools/src/unidock_tools/application/unidock_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,34 @@
from .base import Base


DEFAULT_ARGS = {
"receptor": None,
"ligands": None,
"ligand_index": None,
"center_x": None,
"center_y": None,
"center_z": None,
"size_x": 22.5,
"size_y": 22.5,
"size_z": 22.5,
"workdir": "docking_workdir",
"savedir": "docking_results",
"batch_size": 1200,
"scoring_function": "vina",
"search_mode": "",
"exhaustiveness": 128,
"max_step": 20,
"num_modes": 3,
"refine_step": 3,
"energy_range": 3.0,
"topn": 100,
"score_only": False,
"local_only": False,
"seed": 181129,
"debug": False,
}


class UniDock(Base):
def __init__(self,
receptor: Path,
Expand Down Expand Up @@ -177,17 +205,18 @@ def save_results(self, save_dir: Union[str, os.PathLike] = ""):


def main(args: dict):
args = {**DEFAULT_ARGS, **args}
workdir = Path(args["workdir"]).resolve()
savedir = Path(args["savedir"]).resolve()

ligands = []
if args["ligands"]:
if args.get("ligands"):
for lig in args["ligands"]:
if not Path(lig).exists():
logging.error(f"Cannot find {lig}")
continue
ligands.append(Path(lig).resolve())
if args["ligand_index"]:
if args.get("ligand_index"):
with open(args["ligand_index"], "r") as f:
index_content = f.read()
index_lines1 = [Path(line.strip()).resolve() for line in index_content.split("\n")
Expand Down Expand Up @@ -243,7 +272,7 @@ def get_parser() -> argparse.ArgumentParser:
help="Receptor file in pdbqt format.")
parser.add_argument("-l", "--ligands", type=lambda s: s.split(','), default=None,
help="Ligand file in sdf format. Specify multiple files separated by commas.")
parser.add_argument("-i", "--ligand_index", type=str, default="",
parser.add_argument("-i", "--ligand_index", type=str, default=None,
help="A text file containing the path of ligand files in sdf format.")

parser.add_argument("-cx", "--center_x", type=float, required=True,
Expand Down

0 comments on commit 5d7c60a

Please sign in to comment.