-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from misterbrandonwalker/sanitize_ligand
sanitize_ligand
- Loading branch information
Showing
15 changed files
with
461 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[bumpversion] | ||
current_version = 0.1.1-dev1 | ||
commit = False | ||
tag = False | ||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\d+))? | ||
serialize = | ||
{major}.{minor}.{patch}-{release}{dev} | ||
{major}.{minor}.{patch} | ||
|
||
[bumpversion:part:release] | ||
optional_value = _ | ||
first_value = dev | ||
values = | ||
dev | ||
_ | ||
|
||
[bumpversion:part:dev] | ||
|
||
[bumpversion:file:pyproject.toml] | ||
search = version = "{current_version}" | ||
replace = version = "{new_version}" | ||
|
||
[bumpversion:file:VERSION] | ||
|
||
[bumpversion:file:README.md] | ||
|
||
[bumpversion:file:plugin.json] | ||
|
||
[bumpversion:file:src/polus/mm/utils/__init__.py] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.venv | ||
out | ||
tests | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# CHANGELOG | ||
|
||
## 0.1.0 | ||
|
||
Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM condaforge/mambaforge | ||
|
||
# environment variables defined | ||
ENV EXEC_DIR="/opt/executables" | ||
|
||
RUN mkdir -p ${EXEC_DIR} | ||
COPY pyproject.toml ${EXEC_DIR} | ||
COPY VERSION ${EXEC_DIR} | ||
COPY README.md ${EXEC_DIR} | ||
COPY CHANGELOG.md ${EXEC_DIR} | ||
|
||
RUN conda install -c conda-forge rdkit --yes | ||
|
||
RUN pip install filepattern | ||
|
||
RUN conda init bash | ||
|
||
RUN mamba clean --all --yes | ||
|
||
ADD Dockerfile ${EXEC_DIR} | ||
|
||
COPY src ${EXEC_DIR}/src | ||
|
||
RUN pip3 install ${EXEC_DIR} --no-cache-dir | ||
# Default command. Additional arguments are provided through the command line | ||
ENTRYPOINT ["python3", "-m", "polus.mm.utils"] | ||
CMD ["--help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Sanitize Ligand (0.1.1-dev1) | ||
|
||
Handle molecules with rdkit errors gracefully. | ||
|
||
## Building | ||
|
||
To build the Docker image for the conversion plugin, run `./build-docker.sh`. | ||
of `plugin.json` into the pop-up window and submit. | ||
|
||
## Options | ||
|
||
This plugin takes 2 input arguments and 1 output argument: | ||
|
||
| Name | Description | I/O | Type | | ||
|------------------------|----------------------------------|--------|--------| | ||
| pattern | Filepattern to parse files | Input | string | ||
| indir | Input collection | Input | collection | ||
| outdir | Output collection | Output | collection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.1-dev1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
version=$(<VERSION) | ||
docker build . -t mm/sanitize-ligand-plugin:${version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"name": "Sanitize Ligand", | ||
"version": "0.1.1-dev1", | ||
"title": "Sanitize Ligand", | ||
"description": "Handle molecules with rdkit errors gracefully.", | ||
"author": "Brandon Walker ([email protected])", | ||
"institution": "National Center for Advancing Translational Sciences, National Institutes of Health", | ||
"repository": "https://github.com/labshare/polus-plugins", | ||
"website": "https://ncats.nih.gov/preclinical/core/informatics", | ||
"citation": "", | ||
"containerId": "polusai/sanitize-ligand-plugin:0.1.1-dev1", | ||
"baseCommand": [ | ||
"python3", | ||
"-m", | ||
"polus.plugins.sanitize_ligand" | ||
], | ||
"inputs": { | ||
"pattern": { | ||
"type": "string", | ||
"title": "Filepattern to parse files", | ||
"description": "Filepattern to parse sdf files for sanitizing.", | ||
"required": "True" | ||
}, | ||
"indir": { | ||
"type": "collection", | ||
"description": "Input collection.", | ||
"required": "True" | ||
} | ||
}, | ||
"outputs": { | ||
"outdir": { | ||
"type": "collection", | ||
"description": "Output collection." | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[tool.poetry] | ||
name = "mm-polus-sanitize-ligand" | ||
version = "0.1.1-dev1" | ||
description = "Handle molecules with rdkit errors gracefully." | ||
authors = ["Brandon Walker <[email protected]>"] | ||
readme = "README.md" | ||
packages = [{include = "polus", from = "src"}] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.8" | ||
typer = "^0.7.0" | ||
rdkit = "*" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
bump2version = "^1.0.1" | ||
pytest = "^7.4" | ||
pytest-sugar = "^0.9.6" | ||
pre-commit = "^3.2.1" | ||
black = "^23.3.0" | ||
mypy = "^1.1.1" | ||
ruff = "^0.0.270" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[tool.pytest.ini_options] | ||
pythonpath = [ | ||
"." | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
version=$(<VERSION) | ||
|
||
container_input_dir="/inddir" | ||
container_output_dir="/outdir" | ||
|
||
docker run -v $tool_mount_path_input:${container_input_dir} \ | ||
-v $tool_mount_path_output:${container_output_dir} \ | ||
mm/sanitize-ligand-plugin:${version} \ | ||
--pattern ${pattern} \ | ||
--indir ${container_input_dir} \ | ||
--outdir ${container_output_dir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""sanitize_ligand.""" | ||
|
||
__version__ = "0.1.1-dev1" | ||
|
||
from polus.mm.utils.sanitize_ligand import ( # pylint: disable=unused-import | ||
sanitize_ligand, | ||
) |
63 changes: 63 additions & 0 deletions
63
utils/sanitize-ligand-plugin/src/polus/mm/utils/__main__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
"""Package entrypoint for the sanitize_ligand package.""" | ||
|
||
# Base packages | ||
import logging | ||
from os import environ | ||
from pathlib import Path | ||
|
||
import filepattern as fp | ||
import typer | ||
from polus.mm.utils.sanitize_ligand import sanitize_ligand | ||
|
||
logging.basicConfig( | ||
format="%(asctime)s - %(name)-8s - %(levelname)-8s - %(message)s", | ||
datefmt="%d-%b-%y %H:%M:%S", | ||
) | ||
POLUS_LOG = getattr(logging, environ.get("POLUS_LOG", "INFO")) | ||
logger = logging.getLogger("polus.mm.utils.sanitize_ligand") | ||
logger.setLevel(POLUS_LOG) | ||
|
||
app = typer.Typer(help="Sanitize Ligand.") | ||
|
||
|
||
@app.command() | ||
def main( | ||
pattern: str = typer.Option( | ||
..., | ||
"--pattern", | ||
help="Input filepattern to be processed.", | ||
), | ||
in_dir: Path = typer.Option( | ||
..., | ||
"--indir", | ||
help="Input directory.", | ||
exists=True, | ||
writable=True, | ||
file_okay=False, | ||
resolve_path=True, | ||
), | ||
out_dir: Path = typer.Option( | ||
..., | ||
"--outdir", | ||
help="Output directory.", | ||
exists=True, | ||
writable=True, | ||
file_okay=False, | ||
resolve_path=True, | ||
), | ||
) -> None: | ||
"""Sanitize Ligand.""" | ||
logger.info(f"pattern: {pattern}") | ||
logger.info(f"indir: {in_dir}") | ||
logger.info(f"outdir: {out_dir}") | ||
ligand_file_paths = [] | ||
ligand_files = fp.FilePattern(in_dir, pattern) | ||
for input_small_mol_ligand in ligand_files(): | ||
ligand = input_small_mol_ligand[-1][0] | ||
ligand_file_paths.append(ligand) | ||
|
||
sanitize_ligand(ligand_file_paths, out_dir) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
Oops, something went wrong.