CAS_FROM_ANY

This function resolves a user-provided chemical identifier (such as a common name, InChI, InChIKey, PubChem-formatted ID, SMILES, CAS alias, or selected elemental identifiers) to a canonical CAS Registry Number string.

It performs a validated identifier search and returns the normalized CAS form used by downstream engineering property functions.

Excel Usage

=CAS_FROM_ANY(ID, autoload, cache)
  • ID (str, required): Chemical identifier to resolve (name, CAS, InChI, InChIKey, PubChem format, or SMILES).
  • autoload (bool, optional, default: false): Whether to load additional databanks when no immediate match is found (-).
  • cache (bool, optional, default: true): Whether to cache search results for faster repeated lookups (-).

Returns (str): Canonical CAS number string for the resolved chemical identifier.

Example 1: Resolve water name to CAS

Inputs:

ID
water

Excel formula:

=CAS_FROM_ANY("water")

Expected output:

"7732-18-5"

Example 2: Resolve ethanol from InChI string

Inputs:

ID
InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3

Excel formula:

=CAS_FROM_ANY("InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3")

Expected output:

"64-17-5"

Example 3: Resolve ethanol from PubChem identifier

Inputs:

ID
pubchem=702

Excel formula:

=CAS_FROM_ANY("pubchem=702")

Expected output:

"64-17-5"

Example 4: Resolve decane from SMILES string

Inputs:

ID
CCCCCCCCCC

Excel formula:

=CAS_FROM_ANY("CCCCCCCCCC")

Expected output:

"124-18-5"

Python Code

Show Code
from chemicals.identifiers import CAS_from_any as chemicals_cas_from_any

def cas_from_any(ID, autoload=False, cache=True):
    """
    Resolve a chemical identifier to its standardized CAS number.

    See: https://chemicals.readthedocs.io/chemicals.identifiers.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        ID (str): Chemical identifier to resolve (name, CAS, InChI, InChIKey, PubChem format, or SMILES).
        autoload (bool, optional): Whether to load additional databanks when no immediate match is found (-). Default is False.
        cache (bool, optional): Whether to cache search results for faster repeated lookups (-). Default is True.

    Returns:
        str: Canonical CAS number string for the resolved chemical identifier.
    """
    try:
        return chemicals_cas_from_any(ID=ID, autoload=autoload, cache=cache)
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Chemical identifier to resolve (name, CAS, InChI, InChIKey, PubChem format, or SMILES).
Whether to load additional databanks when no immediate match is found (-).
Whether to cache search results for faster repeated lookups (-).