thermo.identifiers module

thermo.identifiers.checkCAS(CASRN)[source]

Checks if a CAS number is valid. Crashes if not.

Parameters:

CASRN : string

A three-piece, dash-separated set of numbers

Returns:

result : bool

Boolean value if CASRN was valid. If parsing fails, return False also.

Notes

Check method is according to Chemical Abstract Society. However, no lookup to their service is performed; therefore, this function cannot detect false positives.

Function also does not support additional separators, apart from ‘-‘.

Examples

>>> checkCAS('7732-18-5')
True
>>> checkCAS('77332-18-5')
False
thermo.identifiers.CAS_from_any(ID)[source]

Looks up the CAS number of a chemical by searching and testing for the string being any of the following types of chemical identifiers:

  • Name, in IUPAC form or common form or a synonym registered in PubChem
  • InChI name, prefixed by ‘InChI=1S/’ or ‘InChI=1/’
  • InChI key, prefixed by ‘InChIKey=’
  • PubChem CID, prefixed by ‘PubChem=’
  • SMILES (prefix with ‘SMILES=’ to ensure smiles parsing; ex. ‘C’ will return Carbon as it is an element whereas the SMILES interpretation for ‘C’ is methane)
  • CAS number (obsolete numbers may point to the current number)

If the input is an ID representing an element, the following additional inputs may be specified as well:

  • Atomic symbol (ex ‘Na’)
  • Atomic number (as a string)
Parameters:

ID : str

One of the name formats described above

Returns:

CASRN : string

A three-piece, dash-separated set of numbers

Notes

An exception is raised if the name cannot be identified. The PubChem database includes a wide variety of other synonyms, but these may not be present for all chemcials.

Examples

>>> CAS_from_any('water')
'7732-18-5'
>>> CAS_from_any('InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3')
'64-17-5'
>>> CAS_from_any('CCCCCCCCCC')
'124-18-5'
>>> CAS_from_any('InChIKey=LFQSCWFLJHTTHZ-UHFFFAOYSA-N')
'64-17-5'
>>> CAS_from_any('pubchem=702')
'64-17-5'
>>> CAS_from_any('O') # only elements can be specified by symbol
'7782-44-7'
thermo.identifiers.PubChem(CASRN)[source]

Given a CASRN in the database, obtain the PubChem database number of the compound.

Parameters:

CASRN : string

Valid CAS number in PubChem database [-]

Returns:

pubchem : int

PubChem database id, as an integer [-]

Notes

CASRN must be an indexing key in the pubchem database.

References

[R882883]Pubchem.

Examples

>>> PubChem('7732-18-5')
962
thermo.identifiers.MW(CASRN)[source]

Given a CASRN in the database, obtain the Molecular weight of the compound, if it is in the database.

Parameters:

CASRN : string

Valid CAS number in PubChem database

Returns:

MolecularWeight : float

Notes

CASRN must be an indexing key in the pubchem database. No MW Calculation is performed; nor are any historical isotopic corrections applied.

References

[R883884]Pubchem.

Examples

>>> MW('7732-18-5')
18.01528
thermo.identifiers.formula(CASRN)[source]
>>> formula('7732-18-5')
'H2O'
thermo.identifiers.smiles(CASRN)[source]
>>> smiles('7732-18-5')
'O'
thermo.identifiers.InChI(CASRN)[source]
>>> InChI('7732-18-5')
'H2O/h1H2'
thermo.identifiers.InChI_Key(CASRN)[source]
>>> InChI_Key('7732-18-5')
'XLYOFNOQVPJJNP-UHFFFAOYSA-N'
thermo.identifiers.IUPAC_name(CASRN)[source]
>>> IUPAC_name('7732-18-5')
'oxidane'
thermo.identifiers.name(CASRN)[source]
>>> name('7732-18-5')
'water'
thermo.identifiers.synonyms(CASRN)[source]
>>> synonyms('98-00-0')
['furan-2-ylmethanol', 'furfuryl alcohol', '2-furanmethanol', '2-furancarbinol', '2-furylmethanol', '2-furylcarbinol', '98-00-0', '2-furanylmethanol', 'furfuranol', 'furan-2-ylmethanol', '2-furfuryl alcohol', '5-hydroxymethylfuran', 'furfural alcohol', 'alpha-furylcarbinol', '2-hydroxymethylfuran', 'furfuralcohol', 'furylcarbinol', 'furyl alcohol', '2-(hydroxymethyl)furan', 'furan-2-yl-methanol', 'furfurylalcohol', 'furfurylcarb', 'methanol, (2-furyl)-', '2-furfurylalkohol', 'furan-2-methanol', '2-furane-methanol', '2-furanmethanol, homopolymer', '(2-furyl)methanol', '2-hydroxymethylfurane', 'furylcarbinol (van)', '2-furylmethan-1-ol', '25212-86-6', '93793-62-5', 'furanmethanol', 'polyfurfuryl alcohol', 'pffa', 'poly(furfurylalcohol)', 'poly-furfuryl alcohol', '(fur-2-yl)methanol', '.alpha.-furylcarbinol', '2-hydroxymethyl-furan', 'poly(furfuryl alcohol)', '.alpha.-furfuryl alcohol', 'agn-pc-04y237', 'h159', 'omega-hydroxypoly(furan-2,5-diylmethylene)', '(2-furyl)-methanol (furfurylalcohol)', '40795-25-3', '88161-36-8']
thermo.identifiers.mixture_from_any(ID)[source]

Looks up a string which may represent a mixture in the database of thermo to determine the key by which the composition of that mixture can be obtained in the dictionary _MixtureDict.

Parameters:

ID : str

A string or 1-element list containing the name which may represent a mixture.

Returns:

key : str

Key for access to the data on the mixture in _MixtureDict.

Notes

White space, ‘-‘, and upper case letters are removed in the search.

Examples

>>> mixture_from_any('R512A')
'R512A'
>>> mixture_from_any([u'air'])
'Air'