0% found this document useful (0 votes)
7 views3 pages

CIRpy: Python Chemical Identifier Guide

Uploaded by

figagagef
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

CIRpy: Python Chemical Identifier Guide

Uploaded by

figagagef
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Using the CIRpy Library

A Student Guide to Chemical Identifier Resolution in Python

1. What Is CIRpy?

CIRpy is a Python library that lets you convert between different chemical identifiers using the NIH
Chemical Identifier Resolver (CIR).

It can translate:

• Chemical names

• SMILES strings

• InChI / InChIKey

• Molecular formulas

Example:

“caffeine” → SMILES or InChI

2. What You Need Before Starting

• Python 3.x

• Internet connection (CIRpy uses an online resolver)

• Basic Python knowledge

3. Installing CIRpy

Open a terminal or command prompt and run:

pip install cirpy

If that doesn’t work, try:

python -m pip install cirpy

4. Importing CIRpy in Python

import cirpy

If no error appears, the library is installed correctly.

5. Basic Usage

Resolving a Chemical Name


[Link]("caffeine", "smiles")

Output example:

CN1C=NC2=C1C(=O)N(C(=O)N2C)C

6. Common Identifier Types

You can request many different formats:

Identifier Type Keyword

SMILES "smiles"

InChI "inchi"

InChIKey "inchikey"

Molecular Formula "formula"

IUPAC Name "iupac_name"

7. More Examples

Get an InChIKey

[Link]("glucose", "inchikey")

Convert SMILES → Name

[Link]("C(C1C(C(C(C(O1)O)O)O)O)O", "iupac_name")

8. Handling Multiple Results

Some chemicals return more than one result.

[Link]("aspirin", "smiles", get3d=False)

To get all possible results:

[Link]("aspirin", "smiles", get3d=False, resolvers=None)

9. Error Handling (Important)

Always check for None in case the compound isn’t found.

result = [Link]("unknowncompound123", "smiles")

if result is None:
print("Compound not found.")

else:

print(result)

10. Common Problems & Fixes

No result returned

• Check spelling

• Try a different identifier type

• Use a simpler name

Internet error

• CIRpy requires an active internet connection

• Firewalls may block school networks

11. When to Use CIRpy

Good for:

• Homework & research

• Chemistry data conversion

• Quick identifier lookups

Not ideal for:

• Offline work

• Large-scale batch processing

• High-security environments

12. Learning More

• NIH Chemical Identifier Resolver (CIR)

• Python chemistry libraries: RDKit, Open Babel

• PubChem & NIST chemistry databases

13. Summary

CIRpy is a simple and powerful tool for converting chemical identifiers in Python.
With just one line of code, you can translate names, SMILES, InChI, and more.

You might also like