Molecular format conversion

From InternScience/DrClaw · View interactive version

Molecular format conversion is an AI agent skill from the GitHub repository InternScience/DrClaw. Convert between molecular formats including SMILES, InChI, InChIKey, and SELFIES for cheminformatics applications.

How to use this skill

Skill file

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:

## 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:

Input/Output

Input:

Output:

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

Format Details

SMILES (Simplified Molecular Input Line Entry System)

InChI (International Chemical Identifier)

InChIKey

SELFIES (Self-Referencing Embedded Strings)

Additional Conversion Tools

Error Handling

Some conversions may fail for:

Always check for errors in the returned data.

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.