chemistry_tools.cas

Functions for working with CAS registry numbers.

Functions:

cas_int_to_string(cas_no)

Converts an integer CAS registry number to a hyphenated string.

cas_string_to_int(cas_no)

Converts a hyphenated string CAS registry number to an integer.

check_cas_number(cas_no)

Checks the CAS registry number to ensure the check digit is valid with respect to the rest of the number.

cas_int_to_string(cas_no)[source]

Converts an integer CAS registry number to a hyphenated string.

Parameters

cas_no (int)

Return type

str

cas_string_to_int(cas_no)[source]

Converts a hyphenated string CAS registry number to an integer.

Parameters

cas_no

Raises

ValueError – If the CAS registry number is invalid.

check_cas_number(cas_no)[source]

Checks the CAS registry number to ensure the check digit is valid with respect to the rest of the number.

If the CAS registry number is valid 0 is returned. If there is a problem the difference between the computed check digit and that given as part of the CAS registry number is returned.

Parameters

cas_no (int)

Return type

int