mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
When converting molecules with wavy bonds (Bond::STEREOANY on double bonds) through InChI and back, the stereo information was silently dropped. This affected any workflow using InChI roundtrips for canonicalization (e.g. with -SUU flag). Two bugs in External/INCHI-API/inchi.cpp: Reverse path (InchiToMol): The stereo0D processing loop skipped INCHI_PARITY_UNDEFINED entries before they could reach the double bond handler. The handler already had an else clause that correctly sets Bond::STEREOANY, but it was never reached. Fix: only skip INCHI_PARITY_NONE at the top level, and add a guard in the Tetrahedral case to prevent UNDEFINED/UNKNOWN from incorrectly setting chirality. Forward path (MolToInchi): STEREOANY double bonds were only handled by collapsing the coordinates — InChI then produced no stereo annotation under -SUU. Fix: also emit a stereo0D entry with INCHI_PARITY_UNKNOWN parity so InChI's -SUU output correctly carries the "stereo unknown" designation. StereoAtoms may be cleared for STEREOANY, so we locate the two outer neighbors by iterating bonds. New test testStereoAnyRoundtrip in External/INCHI-API/test.cpp covers 9 representative cases (Schiff base, oxime, cinnamic acid, chalcone, crotonaldehyde, tamoxifen-like, retinal-like, plus two molecules with a chiral center adjacent to the wavy bond). Counts in rdkit/Chem/UnitTestInchi.py shift by 1 (689 same, 492 reasonable) because the new STEREOANY emission produces a more accurate roundtrip for one entry in the test inventory. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
To build the optional InChI support, run cmake with the -DRDK_BUILD_INCHI_SUPPORT=ON argument. If InChI sources could not be found, the CMake build system will attempt to download the InChI distribution from the following URL: http://www.inchi-trust.org/wp/wp-content/uploads/2014/06/INCHI-1-API.zip The default download URL and MD5 checksum can be overridden with the following CMake definitions: INCHI_URL INCHI_MD5SUM If INCHI_URL is set to "", no download will be attempted. If INCHI_MD5SUM is set to "", no MD5 checksum will be performed. If you prefer to install InChI sources manually, please follow these instructions: 1. Download the zip file from http://www.inchi-trust.org/wp/wp-content/uploads/2014/06/INCHI-1-API.zip 2. Unzip the package, which creates a INCHI-1-API folder. 3. In the unzipped folder, find INCHI-1-API/INCHI_API/inchi_dll, under which there are 73 files including things like ichi.h and ikey_dll.c. Create a 'src' directory inside the same directory that contains this README file you are readingCopy, and copy all those 73 files 'src' you have just created. The actual path is '$RDBASE/External/INCHI-API/src'. 4. Rerun `cmake` with `-DRDK_BUILD_INCHI_SUPPORT=ON` as an additional argument Alternatively, if you are on a UNIX variant system (Linux, Mac OS X, Cygwin, etc), you may invoke the included script `download-inchi.sh`: $ bash download-inchi.sh When the download is successful, rerun`cmake` with `-DRDK_BUILD_INCHI_SUPPORT=ON` as an additional argument