{"skill":{"slug":"intern-pubchem-name-conversion","displayName":"Intern PubChem Name Conversion","summary":"Convert molecules between IUPAC, SMILES, and molecular formula using PubChem as the source of truth. Use this whenever the user asks to convert, normalize, o...","description":"---\nname: intern_pubchem_name_conversion\ndescription: Convert molecules between IUPAC, SMILES, and molecular formula using PubChem as the source of truth. Use this whenever the user asks to convert, normalize, or cross-check molecular representations in chemistry/science workflows (including Intern research tasks). Prefer API lookup over memory; do not guess.\nhomepage: https://pubchem.ncbi.nlm.nih.gov/docs/pug-rest\nmetadata: { \"openclaw\": { \"emoji\": \"🧪\", \"requires\": { \"bins\": [\"curl\", \"python3\"] } } }\n---\n\n# Intern PubChem Name Conversion\n\nConvert one molecular representation into all three fields:\n- `smiles`\n- `iupac`\n- `formula`\n\n## When to use\n\nUse this skill when the user asks to:\n- convert IUPAC <-> SMILES\n- fetch molecular formula from IUPAC/SMILES\n- validate molecule identity against PubChem\n\nDo not use this skill for:\n- reaction mechanism explanation\n- quantum chemistry simulation\n- docking or property prediction beyond PubChem identifiers\n\n## Input contract\n\nExpect one input value and one type:\n- `input_type`: `iupac` or `smiles`\n- `input_value`: raw string\n\nIf the user gives only one string without type:\n- treat strings with many bond symbols (`=`, `#`, `[`, `]`, `@`) as `smiles`\n- otherwise treat as `iupac`/name query\n\n## Required behavior\n\nAlways query PubChem first. Do not answer from memory when tools are available.\n\n1) URL-encode the full input string:\n\n```bash\nENCODED=$(python3 -c 'import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=\"\"))' \"$INPUT_VALUE\")\n```\n\n2) Build the primary endpoint:\n- If `input_type == iupac`:\n  - `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/{ENCODED}/property/SMILES,IUPACName,MolecularFormula/JSON`\n- If `input_type == smiles`:\n  - `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/{ENCODED}/property/SMILES,IUPACName,MolecularFormula/JSON`\n\n3) If `smiles` primary endpoint is non-200, retry once with:\n- `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/smiles/{ENCODED}/property/SMILES,IUPACName,MolecularFormula/JSON`\n\n4) If still non-200, do CID fallback:\n- Resolve CID:\n  - iupac: `.../compound/name/{ENCODED}/cids/JSON`\n  - smiles: `.../compound/smiles/{ENCODED}/cids/JSON`\n- Then fetch properties by CID:\n  - `.../compound/cid/{CID}/property/SMILES,IUPACName,MolecularFormula/JSON`\n\n5) Parse `PropertyTable.Properties[0]` and map:\n- `smiles <- SMILES` (fallback `ConnectivitySMILES`)\n- `iupac <- IUPACName`\n- `formula <- MolecularFormula`\n\n## Output format\n\nReturn JSON only (no markdown fences, no extra prose):\n\n```json\n{\n  \"smiles\": \"...\",\n  \"iupac\": \"...\",\n  \"formula\": \"...\"\n}\n```\n\nIf all attempts fail, still return the same schema with empty strings:\n\n```json\n{\n  \"smiles\": \"\",\n  \"iupac\": \"\",\n  \"formula\": \"\"\n}\n```\n\n## Quality rules\n\n- Keep PubChem values verbatim; do not rewrite or normalize names.\n- If multiple records are returned, use the first record consistently.\n- Do not silently swap stereochemistry markers.\n","tags":{"chemistry":"0.1.0","latest":"0.1.0","name-conversion":"0.1.0","pubchem":"0.1.0","science":"0.1.0"},"stats":{"comments":1,"downloads":648,"installsAllTime":24,"installsCurrent":0,"stars":1,"versions":1},"createdAt":1772612956673,"updatedAt":1778491714733},"latestVersion":{"version":"0.1.0","createdAt":1772612956673,"changelog":"Initial release: PubChem-based conversion between IUPAC, SMILES, and formula with fallback strategy.","license":null},"metadata":{"setup":[],"os":null,"systems":null},"owner":{"handle":"guox18","userId":"s170rgv4et8n0z8r7kdwqyvtjn884wx6","displayName":"guox18","image":"https://avatars.githubusercontent.com/u/72451292?v=4"},"moderation":null}