Skip to content

Commit

Permalink
Merge pull request #102 from datamol-org/pypi-bug
Browse files Browse the repository at this point in the history
dont import sasscorer by default
  • Loading branch information
hadim authored May 13, 2022
2 parents a4b7cc1 + 6ebf205 commit c4f21bd
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
uses: actions/checkout@v2

- name: Setup conda
uses: mamba-org/provision-with-micromamba@main
# see https://github.com/mamba-org/provision-with-micromamba/issues/54
uses: mamba-org/provision-with-micromamba@755a9542150cc9dedd1c1dd95b963460ec320939
with:
environment-file: false
cache-downloads: true
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ jobs:
uses: actions/checkout@v2

- name: Setup conda
uses: mamba-org/provision-with-micromamba@main
# see https://github.com/mamba-org/provision-with-micromamba/issues/54
uses: mamba-org/provision-with-micromamba@755a9542150cc9dedd1c1dd95b963460ec320939
with:
environment-file: false
cache-downloads: true
Expand Down
18 changes: 15 additions & 3 deletions datamol/descriptors/descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,32 @@
from rdkit.Chem import rdmolops
from rdkit.Chem import Crippen

sys.path.append(os.path.join(RDConfig.RDContribDir, "SA_Score"))
import sascorer # type:ignore

from .. import Mol
from ..convert import from_smarts


def _sasscorer(mol: Mol):

sys.path.append(os.path.join(RDConfig.RDContribDir, "SA_Score"))
try:
import sascorer # type:ignore
except ImportError:
raise ImportError(
"Could not import sascorer. If you installed rdkit-pypi with `pip`, please uninstall it and reinstall rdkit with `conda` or `mamba`."
)

return sascorer.calculateScore(mol)


_AROMATIC_QUERY = from_smarts("a")

mw = rdMolDescriptors.CalcExactMolWt
fsp3 = rdMolDescriptors.CalcFractionCSP3
tpsa = rdMolDescriptors.CalcTPSA
qed = Descriptors.qed
clogp = Descriptors.MolLogP # type: ignore
sas = sascorer.calculateScore
sas = _sasscorer
formal_charge = rdmolops.GetFormalCharge
refractivity = Crippen.MolMR

Expand Down
23 changes: 23 additions & 0 deletions news/rdkit-pypi.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* Don't import `sasscorer` by default but only during the call to `dm.descriptors.sas(mol)`

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>

0 comments on commit c4f21bd

Please sign in to comment.