polymerist.smileslib.chemdbqueries ================================== .. py:module:: polymerist.smileslib.chemdbqueries .. autoapi-nested-parse:: For querying chemical databases for information about molecules specified by SMILES string and other structures Attributes ---------- .. autoapisummary:: polymerist.smileslib.chemdbqueries.LOGGER polymerist.smileslib.chemdbqueries.cirpy_error polymerist.smileslib.chemdbqueries.pubchempy_error Exceptions ---------- .. autoapisummary:: polymerist.smileslib.chemdbqueries.InvalidPropertyError polymerist.smileslib.chemdbqueries.NullPropertyResponse polymerist.smileslib.chemdbqueries.ChemicalDataQueryFailed Classes ------- .. autoapisummary:: polymerist.smileslib.chemdbqueries.ChemDBServiceQueryStrategy polymerist.smileslib.chemdbqueries.NIHCACTUSQueryStrategy polymerist.smileslib.chemdbqueries.PubChemQueryStrategy Functions --------- .. autoapisummary:: polymerist.smileslib.chemdbqueries.get_chemical_property Module Contents --------------- .. py:data:: LOGGER .. py:exception:: InvalidPropertyError Bases: :py:obj:`Exception` Raised when attempting to query a property that a chemical database service cannot provide .. py:exception:: NullPropertyResponse Bases: :py:obj:`Exception` Raised when a chemical database query doesn't fail BUT returns a NoneType where not allowed .. py:exception:: ChemicalDataQueryFailed Bases: :py:obj:`Exception` Raised when a chemical data query is unfulfilled by a service .. py:class:: ChemDBServiceQueryStrategy Bases: :py:obj:`abc.ABC` Implementation of queries from a particular chemical database .. py:method:: dependencies() -> Iterable[str] :classmethod: For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate) .. py:method:: is_online() -> bool :classmethod: :abstractmethod: Check if the service being queried is online and can accept requests .. py:method:: queryable_properties() -> Container[str] :classmethod: :abstractmethod: List which chemical property names can be queried from the service .. py:method:: queryable_namespaces() -> Container[str] :classmethod: :abstractmethod: List which chemical identification types can be searched through by the service .. py:method:: validate_property(property_name: str) -> None Pre-check to ensure that a property is queryable from a service before attempting HTTP query .. py:method:: get_property(property_name: str, identifier: str, namespace: Optional[str], keep_first_only: bool = True, allow_null_return: bool = False, **kwargs) -> Optional[Any] Fetch a property associated with a molecule from a chemical database query service .. py:data:: cirpy_error .. py:class:: NIHCACTUSQueryStrategy Bases: :py:obj:`ChemDBServiceQueryStrategy` Implementation of chemical query requests to the NIH's CADD group Cheminformatics Tools and User Services (CACTUS) Chemical Identifier Resolver (CIR) .. py:attribute:: service_name :type: ClassVar[str] :value: 'NIH CACTUS CIR' .. py:method:: dependencies() :classmethod: For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate) .. py:method:: queryable_properties() -> set[str] :classmethod: List which chemical property names can be queried from the service .. py:method:: is_online() :classmethod: Check if the service being queried is online and can accept requests .. py:method:: queryable_namespaces() -> set[str] :classmethod: List which chemical identification types can be searched through by the service .. py:data:: pubchempy_error .. py:class:: PubChemQueryStrategy Bases: :py:obj:`ChemDBServiceQueryStrategy` Implementation of chemical query requests to PubChem via the PUG REST API (https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest) .. py:attribute:: service_name :type: ClassVar[str] :value: 'PubChem' .. py:method:: dependencies() :classmethod: For internals, allows dynamic checking for package dependencies (useful for automating unit test boilerplate) .. py:method:: is_online() :classmethod: Check if the service being queried is online and can accept requests .. py:method:: queryable_properties() -> set[str] :classmethod: List which chemical property names can be queried from the service .. py:method:: queryable_namespaces() -> set[str] :classmethod: List which chemical identification types can be searched through by the service .. py:function:: 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: Optional[Sequence[ChemDBServiceQueryStrategy]] = None, **kwargs) -> Optional[Any] 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