Substances
albert.collections.substance.SubstanceCollection
Bases: BaseCollection
SubstanceCollection is a collection class for managing Substance entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
An instance of the Albert session used for API interactions. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base URL for making API requests related to substances. |
Methods:
| Name | Description |
|---|---|
get_by_ids |
Retrieves a list of substances by their CAS IDs and optional region. |
get_by_id |
Retrieves a single substance by its CAS ID and optional region, or None if not found. |
Source code in src/albert/collections/substance.py
get_by_ids
get_by_ids(
*,
cas_ids: list[str],
region: str = "US",
catch_errors: bool | None = None,
) -> list[SubstanceInfo]
Get substances by their CAS IDs.
If catch_errors is set to False, the number of substances returned
may be less than the number of CAS IDs provided if any of the CAS IDs result in an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cas_ids
|
list[str]
|
A list of CAS IDs to retrieve substances for. |
required |
region
|
str
|
The region to filter the subastance by, by default "US" |
'US'
|
catch_errors
|
bool
|
Whether to catch errors for unknown CAS, by default True. |
None
|
Returns:
| Type | Description |
|---|---|
list[SubstanceInfo]
|
A list of substances with the given CAS IDs. |
Source code in src/albert/collections/substance.py
get_by_id
get_by_id(
*,
cas_id: str,
region: str = "US",
catch_errors: bool | None = None,
) -> SubstanceInfo | None
Get a substance by its CAS ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cas_id
|
str
|
The CAS ID of the substance to retrieve. |
required |
region
|
str
|
The region to filter the substance by, by default "US". |
'US'
|
catch_errors
|
bool
|
Whether to suppress errors for unknown CAS IDs, by default None. |
None
|
Returns:
| Type | Description |
|---|---|
SubstanceInfo | None
|
The retrieved substance, or None if the CAS ID is not found. |