Chemical structure converter

From aipoch/medical-research-skills · View interactive version

Chemical structure converter is an AI agent skill from the GitHub repository aipoch/medical-research-skills. Convert between IUPAC names, SMILES strings, molecular formulas, and common names for chemical compounds. Supports SMILES validation, batch processing, structure standardization, and cheminformatics database preparation for drug discovery workflows.

How to use this skill

Skill file

Source: https://github.com/aipoch/medical-research-skills

Chemical Structure Converter

Interconvert between different chemical structure representations including IUPAC names, SMILES strings, molecular formulas, and common names. Essential for cheminformatics workflows, database standardization, and compound registration in drug discovery and chemical research.

Key Capabilities:


Input Validation

This skill accepts: compound names (common or IUPAC), SMILES strings, or InChI identifiers. Batch input via CSV or plain text list is also supported.

If the request does not involve converting or validating chemical structure identifiers — for example, asking to predict biological activity, perform docking, or interpret spectra — do not proceed. Instead respond:

"Chemical Structure Converter is designed to interconvert chemical identifiers (names, SMILES, formulas). Please provide a compound name or SMILES string. For other cheminformatics tasks, use a more appropriate tool."


Quick Check

python -m py_compile scripts/main.py
python scripts/main.py --help

Workflow

  1. Confirm the input identifier type (name, SMILES, IUPAC) and desired output format.
  2. Validate that the request matches the documented scope; stop if the task requires unsupported assumptions.
  3. Run the script or apply the documented conversion path with only the inputs available.
  4. Return a structured result separating assumptions, deliverables, risks, and unresolved items.
  5. If execution fails or inputs are incomplete, switch to the fallback path and state exactly what blocked full completion.

Fallback: If no identifier is provided, respond: "No chemical identifier provided. Please supply a compound name (--name), SMILES string (--smiles), or IUPAC name (--iupac). Cannot convert without an input identifier."


Core Capabilities

1. Multi-Format Conversion

from scripts.main import ChemicalStructureConverter
converter = ChemicalStructureConverter()
data = converter.name_to_identifiers("aspirin")
# → IUPAC: 2-acetoxybenzoic acid, SMILES: CC(=O)Oc1ccccc1C(=O)O, Formula: C9H8O4, MW: 180.16

| From → To | Use Case |

|-----------|----------|

| Name → SMILES | Literature to database |

| SMILES → IUPAC | Machine to human readable |

| IUPAC → SMILES | Chemical registration |

| SMILES → Formula | Quick MW calculation |

2. SMILES Validation

is_valid, message = converter.validate_smiles("CC(=O)Oc1ccccc1C(=O)O")
# → True, "Valid SMILES syntax"

| Check | Example Error |

|-------|---------------|

| Parentheses | C(=O — missing closing |

| Ring closures | C1CC — ring not closed |

| Atom validity | @ — invalid character |

3. Batch Processing

for compound in compound_list:
    data = converter.name_to_identifiers(compound)
    if not data:
        print(f"Warning: '{compound}' not found in database")

CLI Usage

# Convert by compound name
python scripts/main.py --name aspirin

# Convert SMILES to IUPAC
python scripts/main.py --smiles "CC(=O)Oc1ccccc1C(=O)O"

# Validate SMILES
python scripts/main.py --smiles "CCO" --validate

# List all compounds
python scripts/main.py --list

Parameters

| Parameter | Type | Required | Description |

|-----------|------|----------|-------------|

| --name, -n | string | No | Compound name |

| --smiles, -s | string | No | SMILES string |

| --iupac, -i | string | No | IUPAC name |

| --validate | flag | No | Validate SMILES syntax |

| --list, -l | flag | No | List available compounds |


Output Requirements

Every final response must make these explicit:


Error Handling


Common Pitfalls


SMILES Quick Reference


References

Known Limitation: Local database contains common compounds only. Integrate PubChem API for production use.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.