Skip to content

Instantly share code, notes, and snippets.

@andersx
Created April 22, 2016 16:05
Show Gist options
  • Select an option

  • Save andersx/863d6368eb0134652271f7fc845eb626 to your computer and use it in GitHub Desktop.

Select an option

Save andersx/863d6368eb0134652271f7fc845eb626 to your computer and use it in GitHub Desktop.
Python2 script to convert a smilesstring to a IUPAC name using Cinfony.
#!/usr/bin/env python2
from sys import argv, exit
from cinfony import webel, pybel
if len(argv) != 2:
print "Usage: smi2name <SMILES>"
exit(1)
smiles_string = argv[1]
mol = pybel.readstring("smi", smiles_string)
name = webel.Molecule(mol).write("iupac")
if len(name) > 0:
print name
else:
print "ERROR: couldn't parse name for SMILES:", smiles_string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment