ChemInformant.models module#
Pydantic models for representing chemical compound data retrieved from PubChem, and custom exceptions.
- exception NotFoundError(identifier)[source]#
Bases:
Exception
Custom exception for when a compound identifier cannot be found.
- exception AmbiguousIdentifierError(identifier, cids)[source]#
Bases:
Exception
Custom exception for when a name maps to multiple CIDs.
- class CompoundData(**data)[source]#
Bases:
BaseModel
Represents structured information for a chemical compound.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- Parameters:
- model_config: ClassVar[ConfigDict] = {'computed_fields': ['pubchem_url'], 'extra': 'ignore', 'frozen': False, 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_copy(*, update=None, deep=False)[source]#
- !!! abstract “Usage Documentation”
[model_copy](../concepts/serialization.md#model_copy)
Returns a copy of the model.
- !!! note
The underlying instance’s [__dict__][object.__dict__] attribute is copied. This might have unexpected side effects if you store anything in it, on top of the model fields (e.g. the value of [cached properties][functools.cached_property]).
- Parameters:
- Return type:
- Returns:
New model instance.