-
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
f8a4d5c
commit 076f9ad
Showing
25 changed files
with
274 additions
and
201 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,25 @@ | ||
# 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 | ||
|
||
COPY src ${EXEC_DIR}/src | ||
|
||
ADD Dockerfile . | ||
|
||
RUN pip3 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,4 @@ | ||
#!/bin/bash | ||
|
||
version=$(<VERSION) | ||
docker build . -t polusai/sanitize-ligand-tool:${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,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 |
7 changes: 4 additions & 3 deletions
7
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,16 @@ | ||
[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" | ||
rdkit = "2024.3.3" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
bump2version = "^1.0.1" | ||
|
73 changes: 73 additions & 0 deletions
73
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,73 @@ | ||
#!/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:926e501300fa5b940c250347cf346cdcacf21944469ed82c3788a58e0957c18d | ||
|
||
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; | ||
|
||
} | ||
|
||
stderr: | ||
type: File | ||
outputBinding: | ||
glob: stderr | ||
|
||
stdout: | ||
type: File | ||
outputBinding: | ||
glob: stdout | ||
|
||
stderr: stderr | ||
|
||
stdout: stdout | ||
|
||
$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
35 changes: 35 additions & 0 deletions
35
utils/docking/diffdock/sanitize-ligand-tool/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,35 @@ | ||
"""Package entrypoint for the sanitize_ligand package.""" | ||
|
||
# Base packages | ||
import logging | ||
from os import environ | ||
|
||
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( | ||
input_small_mol_ligand: str = typer.Option( | ||
..., | ||
"--input_small_mol_ligand", | ||
help="Input input_small_mol_ligand to be processed.", | ||
), | ||
) -> None: | ||
"""Sanitize Ligand.""" | ||
logger.info(f"input_small_mol_ligand: {input_small_mol_ligand}") | ||
sanitize_ligand(input_small_mol_ligand) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
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
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.
Oops, something went wrong.