Skip to content

Instantly share code, notes, and snippets.

@mesprague
Created November 25, 2008 05:59
Show Gist options
  • Save mesprague/28806 to your computer and use it in GitHub Desktop.
Save mesprague/28806 to your computer and use it in GitHub Desktop.
namespace ChemSharp.IO
{
public static class InChI
{
private static OpenBabel.OBConversion converter;
static InChI()
{
converter = new OpenBabel.OBConversion();
converter.SetInAndOutFormats("inchi", "inchi");
}
public static Molecule ParseInChI(string inchi)
{
OpenBabel.OBMol mol = new OpenBabel.OBMol();
if (!converter.ReadString(mol, inchi))
throw new ArgumentException(inchi + " is not a valid inchi");
return new Molecule(mol);
}
public static string WriteInChI(Molecule m)
{
return converter.WriteString(m.obMol, true);
}
}//end class InChI
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment