polymerist.smileslib.chemdbqueries

For querying chemical databases for information about molecules specified by SMILES string and other structures

Attributes

LOGGER

cirpy_error

pubchempy_error

Exceptions

InvalidPropertyError

Raised when attempting to query a property that a chemical database service cannot provide

NullPropertyResponse

Raised when a chemical database query doesn't fail BUT returns a NoneType where not allowed

ChemicalDataQueryFailed

Raised when a chemical data query is unfulfilled by a service

Classes

ChemDBServiceQueryStrategy

Implementation of queries from a particular chemical database

NIHCACTUSQueryStrategy

Implementation of chemical query requests to the NIH's CADD group

PubChemQueryStrategy

Implementation of chemical query requests to PubChem via the

Functions

get_chemical_property(→ Optional[Any])

Attempt to fetch a molecular property from a variety of chemical database services, either

Module Contents

polymerist.smileslib.chemdbqueries.LOGGER
exception polymerist.smileslib.chemdbqueries.InvalidPropertyError[source]

Bases: Exception

Raised when attempting to query a property that a chemical database service cannot provide

exception polymerist.smileslib.chemdbqueries.NullPropertyResponse[source]

Bases: Exception

Raised when a chemical database query doesn’t fail BUT returns a NoneType where not allowed

exception polymerist.smileslib.chemdbqueries.ChemicalDataQueryFailed[source]

Bases: Exception

Raised when a chemical data query is unfulfilled by a service

class polymerist.smileslib.chemdbqueries.ChemDBServiceQueryStrategy[source]

Bases: abc.ABC

Implementation of queries from a particular chemical database

classmethod dependencies() Iterable[str][source]

For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate)

classmethod is_online() bool[source]
Abstractmethod:

Check if the service being queried is online and can accept requests

classmethod queryable_properties() Container[str][source]
Abstractmethod:

List which chemical property names can be queried from the service

classmethod queryable_namespaces() Container[str][source]
Abstractmethod:

List which chemical identification types can be searched through by the service

validate_property(property_name: str) None[source]

Pre-check to ensure that a property is queryable from a service before attempting HTTP query

get_property(property_name: str, identifier: str, namespace: str | None, keep_first_only: bool = True, allow_null_return: bool = False, **kwargs) Any | None[source]

Fetch a property associated with a molecule from a chemical database query service

polymerist.smileslib.chemdbqueries.cirpy_error
class polymerist.smileslib.chemdbqueries.NIHCACTUSQueryStrategy[source]

Bases: ChemDBServiceQueryStrategy

Implementation of chemical query requests to the NIH’s CADD group Cheminformatics Tools and User Services (CACTUS) Chemical Identifier Resolver (CIR)

service_name: ClassVar[str] = 'NIH CACTUS CIR'
classmethod dependencies()[source]

For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate)

classmethod queryable_properties() set[str][source]

List which chemical property names can be queried from the service

classmethod is_online()[source]

Check if the service being queried is online and can accept requests

classmethod queryable_namespaces() set[str][source]

List which chemical identification types can be searched through by the service

polymerist.smileslib.chemdbqueries.pubchempy_error
class polymerist.smileslib.chemdbqueries.PubChemQueryStrategy[source]

Bases: ChemDBServiceQueryStrategy

Implementation of chemical query requests to PubChem via the PUG REST API (https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest)

service_name: ClassVar[str] = 'PubChem'
classmethod dependencies()[source]

For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate)

classmethod is_online()[source]

Check if the service being queried is online and can accept requests

classmethod queryable_properties() set[str][source]

List which chemical property names can be queried from the service

classmethod queryable_namespaces() set[str][source]

List which chemical identification types can be searched through by the service

polymerist.smileslib.chemdbqueries.get_chemical_property(property_name: str, identifier: str, namespace: str = 'smiles', keep_first_only: bool = True, allow_null_return: bool = False, fail_quietly: bool = False, services: Sequence[ChemDBServiceQueryStrategy] | None = None, **kwargs) Any | None[source]

Attempt to fetch a molecular property from a variety of chemical database services, either provided manually (in the order they should be checked) or ALL implemented service queries by default

Will return the first valid returned result or, if all services fail, raise Exception