Created
November 25, 2008 05:59
-
-
Save mesprague/28806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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