Skip to content

Commit

Permalink
load SALT_SOLVENT_PATH using datamol_data_file_path fxn
Browse files Browse the repository at this point in the history
  • Loading branch information
kkovary committed Sep 18, 2023
1 parent 7c08855 commit d03316a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions datamol/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import sys
import io
import functools

try:
import importlib.resources as importlib_resources
Expand All @@ -26,6 +27,15 @@
from ..convert import from_df
from ..convert import render_mol_df

@functools.lru_cache()
def datamol_data_file_path(filename: str, dm_module: str = "datamol.data") -> str:
if sys.version_info < (3, 9, 0):
with importlib_resources.path("datamol.data", filename) as p:
data_path = p
else:
data_path = importlib_resources.files(dm_module).joinpath(filename)

return str(data_path)

def open_datamol_data_file(
filename: str,
Expand Down
3 changes: 1 addition & 2 deletions datamol/mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
AROMATIC_BOND = Chem.rdchem.BondType.AROMATIC
DATIVE_BOND = Chem.rdchem.BondType.DATIVE
UNSPECIFIED_BOND = Chem.rdchem.BondType.UNSPECIFIED
with datamol.data.open_datamol_data_file("salts_solvents.smi") as file_obj:
SALT_SOLVENT_PATH = file_obj.name
SALT_SOLVENT_PATH = datamol.data.datamol_data_file_path("salts_solvents.smi")
SALT_SOLVENT_REMOVER = SaltRemover(defnFilename=SALT_SOLVENT_PATH)


Expand Down

0 comments on commit d03316a

Please sign in to comment.