pátek 30. ledna 2009

Converting old InChI strings to the new standard InChI format

Today I was faced with a task of converting a list of InChI strings in the format used prior to the release of InChI 1.02 final to the new standard format.
Even though it would be a no-brainer to write a small script for OASA to do it, it seemed to me that the InChI software itself should allow something like this.
After some poking around the stdinchi-1 help messages, here is my solution:
cat test.inchi | stdinchi-1 -STDIO -InChI2Struct 2>/dev/null |
grep AuxInfo | stdinchi-1 -STDIO -InpAux 2>/dev/null |
grep InChI=
(the code was broken into multiple lines to display properly)

This command assumes you have the stdinchi-1 program in your path and that you are using a decent OS, with grep and cat commands available (or at least some approximation like Cygwin).
The input file test.inchi contains a list of InChIs - one per line. The output is in the same format.
The sequence of commands at first converts the old InChI into the AuxInfo format used by the InChI program, then uses it as input to generate a new standard InChI.
Hopefully someone would find this information useful.