Skip to content

Commit

Permalink
Merge: Mordred dependency update (#163)
Browse files Browse the repository at this point in the history
The `mordred` package is no longer developed and maintained which can
cause install problems on some architectures and will only keep
producing problems in the future.

However, there is a community maintained drop-in replacement called
`mordredcommunity` available via pip.

This PR exchanges these two packages.
  • Loading branch information
Scienfitz authored Mar 7, 2024
2 parents 66e14fa + 4874cd5 commit 2a03ed1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- [WIP] `torch` is loaded lazily
- Full lookup backtesting example now tests different substance encodings
- Replaced unmaintained `mordred` dependency by `mordredcommunity`

## [0.8.0] - 2024-02-29
### Changed
Expand Down
9 changes: 7 additions & 2 deletions baybe/utils/chemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"""chemistry dependencies. Please run "pip install 'baybe[chem]'"."""
)

from baybe.utils.numerical import DTypeFloatNumpy

_mordred_calculator = Calculator(descriptors)


Expand Down Expand Up @@ -86,10 +88,13 @@ def _smiles_to_mordred_features(smiles: str) -> np.ndarray:
"""
try:
return np.asarray(
_mordred_calculator(Chem.MolFromSmiles(smiles)).fill_missing()
_mordred_calculator(Chem.MolFromSmiles(smiles)).fill_missing(),
dtype=DTypeFloatNumpy,
)
except Exception:
return np.full(len(_mordred_calculator.descriptors), np.NaN)
return np.full(
len(_mordred_calculator.descriptors), np.NaN, dtype=DTypeFloatNumpy
)


def smiles_to_mordred_features(
Expand Down
3 changes: 2 additions & 1 deletion docs/userguide/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ SubstanceParameter(
```

The ``encoding`` option defines what kind of descriptors are calculated:
* ``MORDRED``: 2D descriptors from the [Mordred package](https://mordred-descriptor.github.io/documentation/master/)
* ``MORDRED``: 2D descriptors from the [Mordred package](https://mordred-descriptor.github.io/documentation/master/).
Since the original package is now unmaintained, baybe requires the community replacement [mordredcommunity](https://github.com/JacksonBurns/mordred-community)
* ``RDKIT``: 2D descriptors from the [RDKit package](https://www.rdkit.org/)
* ``MORGAN_FP``: Morgan fingerprints calculated with RDKit (1024 bits, radius 4)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Issues = "https://github.com/emdgroup/baybe/issues/"
[project.optional-dependencies]
chem = [
"rdkit>=2022.3.4",
"mordred>=1.2.0",
"mordredcommunity>=1.2.0",
]

onnx = [
Expand Down

0 comments on commit 2a03ed1

Please sign in to comment.