Skip to content
Back to skills

Molecular Format Conversion

ASecurity

Convert between molecular formats including SMILES, InChI, InChIKey,

  • 170 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 11, 2026
toolspythonapidatabase

Works with

  • cli
  • api
  • mcp

Security analysis

A100/100

Scanned September 11, 2026

npx -y skills add InternScience/DrClaw --skill molecular-format-conversion --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Molecular Format Conversion?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Molecular Format Conversion
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/internscience-molecular-format-conversion-drclaw/badge)](https://www.skillsdirectory.com/skills/internscience-molecular-format-conversion-drclaw)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: molecular-format-conversion
description: Convert between molecular formats including SMILES, InChI, InChIKey,
  and SELFIES for cheminformatics applications.
license: MIT license
metadata:
  skill-author: PJLab
i18n:
  zh:
    description: 分子格式转换:SMILES、I。
---

# Molecular Format Conversion

## Usage

### 1. MCP Server Definition

Use the same `ChemicalToolsClient` class as defined in the molecular-properties-calculation skill.

### 2. Molecular Format Conversion Workflow

This workflow converts molecules between different chemical formats (SMILES, InChI, SELFIES) for database searching, machine learning, and cheminformatics applications.

**Workflow Steps:**

1. **SMILES to InChI** - Convert SMILES to International Chemical Identifier
2. **InChI to SMILES** - Convert InChI back to SMILES
3. **SMILES to SELFIES** - Convert to string-based molecular representation

**Implementation:**

```python
## Initialize client
HEADERS = {"SCP-HUB-API-KEY": "<your-api-key>"}

client = ChemicalToolsClient(
    "https://scp.intern-ai.org.cn/api/v1/mcp/31/SciToolAgent-Chem",
    HEADERS
)

if not await client.connect():
    print("connection failed")
    exit()

print("=== Molecular Format Conversion ===\n")

## Test molecules
smiles = "CCO"  # Ethanol
inchi = "InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3"

## Step 1: SMILES to InChI
print("Step 1: SMILES to InChI")
result = await client.client.call_tool(
    "SMILESToInChI",
    arguments={"smiles": smiles}
)
result_data = client.parse_result(result)
print(f"SMILES: {smiles}")
print(f"{result_data}\n")

## Step 2: InChI to SMILES
print("Step 2: InChI to SMILES")
result = await client.client.call_tool(
    "InChIToSMILES",
    arguments={"inchi": inchi}
)
result_data = client.parse_result(result)
print(f"InChI: {inchi}")
print(f"{result_data}\n")

## Step 3: SMILES to SELFIES
print("Step 3: SMILES to SELFIES")
result = await client.client.call_tool(
    "SMILEStoSELFIES",
    arguments={"smiles": smiles}
)
result_data = client.parse_result(result)
print(f"SMILES: {smiles}")
print(f"{result_data}\n")

## Step 4: SELFIES to SMILES
print("Step 4: SELFIES to SMILES")
selfies = "[C][C][O]"
result = await client.client.call_tool(
    "SELFIEStoSMILES",
    arguments={"selfies": selfies}
)
result_data = client.parse_result(result)
print(f"SELFIES: {selfies}")
print(f"{result_data}\n")

await client.disconnect()
```

### Tool Descriptions

**SciToolAgent-Chem Server:**
- `SMILESToInChI`: Convert SMILES to InChI
  - Args: `smiles` (str)
  - Returns: InChI string

- `InChIToSMILES`: Convert InChI to SMILES
  - Args: `inchi` (str)
  - Returns: SMILES string

- `SMILEStoSELFIES`: Convert SMILES to SELFIES
  - Args: `smiles` (str)
  - Returns: SELFIES string

- `SELFIEStoSMILES`: Convert SELFIES to SMILES
  - Args: `selfies` (str)
  - Returns: SMILES string

- `InChIToInChIKey`: Convert InChI to InChIKey
  - Args: `inchi` (str)
  - Returns: InChIKey (27-character hash)

- `InChIKeyToInChI`: Convert InChIKey to InChI
  - Args: `inchikey` (str)
  - Returns: InChI string

### Input/Output

**Input:**
- **SMILES**: Simplified Molecular Input Line Entry System (e.g., "CCO")
- **InChI**: IUPAC International Chemical Identifier (e.g., "InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3")
- **InChIKey**: Hashed InChI (27 characters, e.g., "LFQSCWFLJHTTHZ-UHFFFAOYSA-N")
- **SELFIES**: Self-Referencing Embedded Strings (e.g., "[C][C][O]")

**Output:**
- Converted molecular representation in target format

### Format Comparison

| Format | Canonical | Human-Readable | Database-Friendly | ML-Friendly |
|--------|-----------|----------------|-------------------|-------------|
| SMILES | Partial | High | Medium | Medium |
| InChI | Yes | Low | High | Low |
| InChIKey | Yes | No | Very High | No |
| SELFIES | Yes | Low | Low | Very High |

### Use Cases

- **SMILES**: Standard format for most cheminformatics tools
- **InChI**: Canonical representation for database searching
- **InChIKey**: Fast database lookups and duplicate detection
- **SELFIES**: Machine learning models (guarantees valid molecules)

### Format Details

**SMILES (Simplified Molecular Input Line Entry System)**
- Pros: Human-readable, widely supported
- Cons: Not canonical (multiple SMILES for same molecule)
- Example: "CCO", "c1ccccc1", "CC(=O)O"

**InChI (International Chemical Identifier)**
- Pros: Canonical, includes stereochemistry and isotopes
- Cons: Long, not human-readable
- Example: "InChI=1S/C2H6O/c1-2-3/h3H,2H2,1H3"

**InChIKey**
- Pros: Fixed-length hash, fast comparison
- Cons: Cannot reconstruct molecule from key
- Example: "LFQSCWFLJHTTHZ-UHFFFAOYSA-N"
- Structure: 14 characters (connectivity) + separator + 8 characters (stereo) + separator + version

**SELFIES (Self-Referencing Embedded Strings)**
- Pros: Always generates valid molecules, ideal for ML
- Cons: Less human-readable, newer format
- Example: "[C][C][O]"
- Used in: Generative models, molecular optimization

### Additional Conversion Tools

- `ConvertSmilesToInchi`: Alternative SMILES to InChI converter
- `GenerateMolKeyFromSmiles`: Generate molecular key
- `InChIKeyToMOL`: Convert InChIKey to MOL file
- `IsValidInChIKey`: Validate InChIKey format

### Error Handling

Some conversions may fail for:
- Invalid input formats
- Unsupported chemical features
- Very large or complex molecules

Always check for errors in the returned data.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…