Skip to content

Commit

Permalink
Added dependency prechecks for cirpy and pubchempy packages to smiles…
Browse files Browse the repository at this point in the history
…lib.chemdbqueries
  • Loading branch information
timbernat committed Jan 3, 2025
1 parent 3d143bd commit a9b9a95
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion polymerist/smileslib/chemdbqueries.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,29 @@
import logging
LOGGER = logging.getLogger(__name__)

from typing import Optional

from ..genutils.importutils.dependencies import modules_installed, MissingPrerequisitePackage
if not modules_installed('cirpy'):
raise MissingPrerequisitePackage(
importing_package_name=__spec__.name,
use_case='Querying the NIH CACTUS Chemical Identifier Resolver (CIR)',
install_link='https://cirpy.readthedocs.io/en/latest/guide/install.html',
dependency_name='cirpy',
dependency_name_formal='CIRpy',
)
import cirpy

from ..genutils.importutils.dependencies import modules_installed, MissingPrerequisitePackage
if not modules_installed('pubchempy'):
raise MissingPrerequisitePackage(
importing_package_name=__spec__.name,
use_case='Querying the PubChem Compound database',
install_link='https://pubchempy.readthedocs.io/en/latest/guide/install.html',
dependency_name='pubchempy',
dependency_name_formal='PubChemPy',
)
import pubchempy as pcp
from typing import Optional


def get_property_from_smiles(smiles : str, prop_name : str='iupac_name') -> Optional[str]: # TODO: abstract each query method via Strategy pattern
Expand Down

0 comments on commit a9b9a95

Please sign in to comment.