Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Spacial Score #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ dependencies:
- networkx

# Chemistry
- rdkit
- datamol >=0.10
- rdkit >=2023.09.3
- datamol >=0.12

# Optional
- lilly-medchem-rules
Expand Down
20 changes: 20 additions & 0 deletions medchem/complexity/_calc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math

import contextlib
from rdkit.Chem.rdmolops import GetMolFrags
from rdkit.Chem.rdmolops import FindPotentialStereo
from rdkit.Chem import FindMolChiralCenters
Expand Down Expand Up @@ -299,3 +300,22 @@ def TWC(mol: dm.Mol, log10: bool = True):
except ValueError:
return float("nan")
return twc


def SPS(mol: dm.Mol, normalize=True):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhu0619 do you have access to zinc15 ? I need to run SPS on all molecules.

"""Calculates the SpacialScore descriptor, as described in:
[1] Krzyzanowski, A.; Pahl, A.; Grigalunas, M.; Waldmann, H. Spacial Score─A Comprehensive Topological Indicator for Small-Molecule Complexity. J. Med. Chem. 2023. https://doi.org/10.1021/acs.jmedchem.3c00689.

Args:
normalize: whether to normalize the score by the number of heavy atoms (nSPS).
"""

score = None
with contextlib.suppress(ImportError):
mol = dm.to_mol(mol)
from rdkit.Chem import SpacialScore

score = SpacialScore.SPS(mol, normalize=normalize)
if score is None:
raise ValueError("SpacialScore is not available in your RDKit version, please update to 2023.09.1")
return score
4 changes: 3 additions & 1 deletion medchem/complexity/_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ._calc import BaroneCT
from ._calc import SMCM
from ._calc import TWC
from ._calc import SPS


class ComplexityFilter:
Expand All @@ -39,7 +40,8 @@ class ComplexityFilter:
"whitlock": WhitlockCT, # whitlock complexity index
"barone": BaroneCT, # barone complexity index
"smcm": SMCM, # synthetic and molecular complexity
"twc": TWC, # Total walk count complexity
"twc": TWC, # Total walk count complexity,
"spacialscore": SPS,
}

def __init__(
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dependencies = [
"pandas",
"networkx",
"datamol >=0.10",
"rdkit",
"rdkit >=2023.09.3",
]

[project.scripts]
Expand Down Expand Up @@ -87,17 +87,17 @@ omit = ["medchem/__init__.py", "medchem/_version.py"]
output = "coverage.xml"

[tool.ruff]
ignore = [
lint.ignore = [
"E501", # Never enforce `E501` (line length violations).
]
line-length = 110
line-length = 120
target-version = "py311"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"F401", # imported but unused
"E402", # Module level import not at top of file
]

[tool.ruff.pycodestyle]
[tool.ruff.lint.pycodestyle]
max-doc-length = 150
Loading