-
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.
- Loading branch information
1 parent
23fb84d
commit 7951706
Showing
23 changed files
with
204 additions
and
113 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...s/sanitize-ligand-plugin/.bumpversion.cfg → ...ock/sanitize-ligand-tool/.bumpversion.cfg
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
File renamed without changes.
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 @@ | ||
*.sdf filter=lfs diff=lfs merge=lfs -text |
File renamed without changes.
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 @@ | ||
# docker build -f Dockerfile -t polusai/sanitize-ligand-tool . | ||
FROM condaforge/mambaforge | ||
|
||
ENV EXEC_DIR="/opt/executables" | ||
ENV POLUS_LOG="INFO" | ||
RUN mkdir -p ${EXEC_DIR} | ||
|
||
|
||
# Work directory defined in the base container | ||
# WORKDIR ${EXEC_DIR} | ||
|
||
COPY pyproject.toml ${EXEC_DIR} | ||
COPY VERSION ${EXEC_DIR} | ||
COPY README.md ${EXEC_DIR} | ||
COPY CHANGELOG.md ${EXEC_DIR} | ||
|
||
# Install needed packages here | ||
# errors installing rdkit from poetry so using conda | ||
COPY environment.yml ${EXEC_DIR} | ||
RUN mamba env create -f ${EXEC_DIR}/environment.yml | ||
RUN echo "source activate project_env" > ~/.bashrc | ||
ENV PATH /opt/conda/envs/env/bin:$PATH | ||
|
||
COPY src ${EXEC_DIR}/src | ||
|
||
ADD Dockerfile . | ||
|
||
RUN conda run -n project_env pip install ${EXEC_DIR} --no-cache-dir | ||
|
||
CMD ["--help"] |
2 changes: 1 addition & 1 deletion
2
utils/sanitize-ligand-plugin/README.md → ...g/diffdock/sanitize-ligand-tool/README.md
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sanitize Ligand (0.1.1-dev1) | ||
# Sanitize Ligand (0.1.0) | ||
|
||
Handle molecules with rdkit errors gracefully. | ||
|
||
|
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.0 |
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,9 @@ | ||
name: project_env | ||
channels: | ||
- conda-forge | ||
dependencies: | ||
- python==3.10 | ||
- rdkit==2024.03.1 | ||
- pytest==8.1.1 | ||
- cwltool==3.1.20240404144621 | ||
- cwl-utils==0.33 |
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 @@ | ||
specVersion: "0.1.0" | ||
name: sanitize_ligand | ||
version: 0.1.0 | ||
container: sanitize-ligand-tool | ||
entrypoint: | ||
title: sanitize_ligand | ||
description: Sanitize input ligand | ||
author: Brandon Walker, Nazanin Donyapour | ||
contact: [email protected], [email protected] | ||
repository: | ||
documentation: | ||
citation: | ||
|
||
inputs: | ||
- name: input_small_mol_ligand | ||
required: true | ||
description: | ||
type: File | ||
format: | ||
uri: edam:format_3814 | ||
outputs: | ||
- name: output_ligand | ||
required: true | ||
description: | ||
type: File | ||
format: | ||
uri: edam:format_3814 | ||
- name: valid_ligand | ||
required: true | ||
description: | ||
type: boolean | ||
ui: | ||
- key: inputs.input_small_mol_ligand | ||
title: "input_small_mol_ligand: " | ||
description: "" | ||
type: File |
6 changes: 3 additions & 3 deletions
6
utils/sanitize-ligand-plugin/pyproject.toml → ...fdock/sanitize-ligand-tool/pyproject.toml
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[tool.poetry] | ||
name = "mm-polus-sanitize-ligand" | ||
version = "0.1.1-dev1" | ||
version = "0.1.0" | ||
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" | ||
python = ">=3.9,<3.12" | ||
typer = "^0.7.0" | ||
rdkit = "*" | ||
sophios = "0.1.1" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
bump2version = "^1.0.1" | ||
|
59 changes: 59 additions & 0 deletions
59
utils/docking/diffdock/sanitize-ligand-tool/sanitize_ligand_0@[email protected]
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,59 @@ | ||
#!/usr/bin/env cwl-runner | ||
cwlVersion: v1.0 | ||
|
||
class: CommandLineTool | ||
|
||
label: Sanitize input ligand | ||
|
||
doc: |- | ||
Sanitize input ligand | ||
|
||
baseCommand: ["python", "-m", "polus.mm.utils.sanitize_ligand"] | ||
|
||
hints: | ||
DockerRequirement: | ||
dockerPull: polusai/sanitize-ligand-tool@sha256:7a98c3698a560d75efd84251464a0f1b722972c5a20a828f58c211419281cd79 | ||
|
||
requirements: | ||
InlineJavascriptRequirement: {} | ||
InitialWorkDirRequirement: # conditionally overwrite the input ligand, otherwise cwltool will symlink to the original | ||
listing: | ||
- $(inputs.input_small_mol_ligand) | ||
|
||
inputs: | ||
|
||
input_small_mol_ligand: | ||
type: File | ||
format: | ||
- edam:format_3814 | ||
inputBinding: | ||
prefix: --input_small_mol_ligand | ||
|
||
outputs: | ||
|
||
output_ligand: | ||
type: File | ||
format: edam:format_3814 | ||
outputBinding: | ||
glob: "*.sdf" | ||
|
||
valid_ligand: | ||
type: boolean | ||
outputBinding: | ||
glob: valid.txt | ||
loadContents: true | ||
outputEval: | | ||
${ | ||
// Read the contents of the file | ||
const lines = self[0].contents.split("\n"); | ||
// Read boolean value from the first line | ||
const valid = lines[0].trim() === "True"; | ||
return valid; | ||
|
||
} | ||
|
||
$namespaces: | ||
edam: https://edamontology.org/ | ||
|
||
$schemas: | ||
- https://raw.githubusercontent.com/edamontology/edamontology/master/EDAM_dev.owl |
2 changes: 1 addition & 1 deletion
2
...and-plugin/src/polus/mm/utils/__init__.py → ...igand-tool/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
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions
3
utils/docking/diffdock/sanitize-ligand-tool/tests/4xk9_ligand.sdf
Git LFS file not shown
File renamed without changes.
59 changes: 59 additions & 0 deletions
59
utils/docking/diffdock/sanitize-ligand-tool/tests/test_sanitize.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,59 @@ | ||
"""Test the sanitize_ligand plugin.""" | ||
from pathlib import Path | ||
|
||
import pytest | ||
from polus.mm.utils.sanitize_ligand import attempt_fix_ligand | ||
from rdkit import Chem | ||
from sophios.api.pythonapi import Step | ||
from sophios.api.pythonapi import Workflow | ||
|
||
|
||
@pytest.mark.catch_error() | ||
def test_kekulization_error_catch() -> None: | ||
"""Test catching Kekulization error. | ||
Can't kekulize mol. Unkekulized atoms: 6 7 8 9 10. | ||
""" | ||
mol = Chem.MolFromSmiles("c1ccc(cc1)-c1nnc(n1)-c1ccccc1") | ||
valid_ligand, rdkit_mol = attempt_fix_ligand(mol) | ||
assert not valid_ligand | ||
|
||
|
||
@pytest.mark.fix_ligand() | ||
def test_fix_explicit_valence_error() -> None: | ||
"""Test fixing explicit valence error. | ||
Explicit valence for atom # 1 C, 5, is greater than permitted | ||
""" | ||
mol = Chem.MolFromSmiles("c1c(ccc2NC(CN=c(c21)(C)C)=O)O", sanitize=False) | ||
valid_ligand, rdkit_mol = attempt_fix_ligand(mol) | ||
assert valid_ligand | ||
|
||
|
||
def test_sanitize_ligand_cwl() -> None: | ||
"""Test the sanitize_ligand CWL.""" | ||
cwl_file_str = "sanitize_ligand_0@[email protected]" | ||
cwl_file = Path(__file__).resolve().parent.parent / Path(cwl_file_str) | ||
|
||
input_ligand_path = Path(__file__).resolve().parent / Path("4xk9_ligand.sdf") | ||
|
||
sanitize_ligand = Step(clt_path=cwl_file) | ||
sanitize_ligand.input_small_mol_ligand = input_ligand_path | ||
|
||
steps = [sanitize_ligand] | ||
filename = "sanitize_ligand" | ||
viz = Workflow(steps, filename) | ||
|
||
viz.run() | ||
|
||
outdir = Path("outdir") | ||
output_files = list(outdir.rglob("*.sdf")) | ||
|
||
assert output_files, "No output SDF files were generated." | ||
|
||
# Check if the input SDF filename is part of the output | ||
input_filename = input_ligand_path.name | ||
output_filenames = [f.name for f in output_files] | ||
assert any( | ||
input_filename in of for of in output_filenames | ||
), f"The input SDF file '{input_filename}' was not found in the output." |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.