31 Commits

Author SHA1 Message Date
Rody Arantes
5d9892575c Fix STEREOANY (wavy bond) loss during InChI roundtrip (#9315)
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>
2026-06-02 14:41:00 +02:00
Yakov Pechersky
b9f7d4787b When ignoring tetrahedral chirality for inchi, case on degree, not valence (#8266)
Fixes #8238
Fixes #8239
Modification of #8126
2025-02-13 19:14:57 +01:00
Greg Landrum
e6a45a8d17 Fixes two out-of-bounds bugs in the InChI wrapper (#8126) 2024-12-25 21:32:35 +01:00
Greg Landrum
b1663052b8 Remove Descriptors as a dependency of many other RDKit libraries (#7700)
* move mol weight and formula calculators to MolOps and refactor them a bit.
The descriptors are still there and should remain.

* remove other unnecessary dependencies on Descriptors

* Update adapter.cpp

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

---------

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
2024-08-13 13:22:43 +02:00
Greg Landrum
31f11952e0 Fix #7311: problem with InChI for phosphinic acid (#7419)
* backup

* remove default valence for Tl
2024-05-03 21:23:37 +02:00
Greg Landrum
41d0139c4b Fixes #6172 (#6388) 2023-05-23 16:09:52 +02:00
Ric
76e8b2a3f3 fix + test (#5057) 2022-03-05 04:32:31 +01:00
Greg Landrum
06027dcd05 Remove unnecessary mutex in InChI wrapper (#4680)
* External/INCHI-API: drop unnecessary mutex

A mutex was introduced in 6cfd34 from 2012 around all InChI library
calls, and InChI v1.05 release notes from 2017 announce that they fixed
race conditions to support multithreading.

We find that the InChI library mutex is no longer necessary with v1.05
and this patch removes it, which enables rdkit users to concurrently
call InChI-related methods.

This patch also updates the InChI multithreading tests to cover
`MolBlockToInchi`, so we have test coverage of concurrently making all
InChI calls.

I ran `testInchi` under asan 200x and all runs passed cleanly.  I was
unable to configure the build toolchain with msan or tsan, so it is
unclear to me if those sanitizers would flag any issues.

* External/INCHI-API: add second multithreading test

This test covers case where immediate concurrent usage of the InChI
library leads to memory corruption.

* remove ASAN workaround (not needed for InChI 1.06)
clang-format run
update inchi version to 1.06 in docs

Co-authored-by: Jin Pan <jinxp1@gmail.com>
2021-11-10 04:08:30 +01:00
Ric
703fe5a225 Remove boost::foreach from public headers (#3820)
* remove include from headers

* update implementation files

* completely remove BOOST_FOREACH (#7)

* convert those changes to use auto

* get rid of all usage of BOOST_FOREACH

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-02-17 14:15:48 +01:00
Greg Landrum
454abb257c A couple of InChI bug fixes (#3656)
Fixes #3645
Fixes #3655
2020-12-17 09:32:51 -05:00
Greg Landrum
9b2dcf2c53 enable accidentally disabled inchi tests (#3468) 2020-10-07 05:47:31 +02:00
Greg Landrum
c259a81e01 Fix #3365 (#3366)
* Fixes #3365

* update expected inchi results

Note that this actually increases the number of failures with one of the tests.
That's because I believe the expected InChIs to be wrong and these new results to be correct.
2020-08-26 19:10:15 -04:00
Greg Landrum
d41752d558 run clang-tidy with readability-braces-around-statements (#2899)
* run clang-tidy with readability-braces-around-statements
clang-format the results
clean up all the parts that clang-tidy-8 broke

* fix problem on windows
2020-01-25 14:19:32 +01:00
Greg Landrum
ec31bea97b clang-tidy-7 pass (#2408) 2019-04-16 12:05:47 -04:00
Greg Landrum
bebf0c9002 Allow converting mol blocks directly to InChI (#2262)
* basics of enabling molblock -> InChI

* first pass at python wrapper

* test that options work
2019-02-13 09:43:02 -05:00
Ric
a6b26253ff Fix (most of) mem problems (#2123)
* do not use new on loggers

* del pointers in testDistGeom

* Update Dict hasNonPOD status on bulk update

* delete new Dicts in memtest1.cpp

* fixes in MolSuppliers and testFMCS

* PeriodicTable singleton as unique_ptr

* fix EEM_arrays leak

* fix leaks in testPBF

* fix ParamCollection leak in test UFF

* fix leaks in MMFF

* clear prop dict before read in in pickler

* fix leaks in testFreeSASA

* fix leaks in test3D

* modernize Dict.h & SmilesParse.cpp

* fix leaks in testQuery

* fix leaks in testCrystalFF

* fix leaks in cxsmilesTest

* fix leaks in Catalog & mol cat test

* fix leaks in ShapeUtils & tests

* fix leaks in testSubgraphs1

* fix leaks testFingerprintGenerators

* fix leaks in Catalog/FilterCatalog

* fix leaks in graphmolqueryTest

* these changes reduce bison parse leaks

* fixed leaks in testChirality.cpp

* fix leaks + 2 tests in testMolWriter

* fix 4m leaks in substructLibraryTest

* small improvements to molTautomerTest; still leaks

* fix leaks in testRGroupDecomp

* fix leaks in test; parser still leaks

* fix leaks in itertest

* fix 4m leaks in testDepictor

* fixes in smatest; still leaking due to parser

* fixes in testSLNParse; still leaking due to parser

* flex/bison: always add atoms with ownership; smarts error cleanup

* fix leaks in testReaction

* fix leaks in testSubstructMatch

* fix leaks in resMolSupplierTest

* fix leaks in testChemTransforms + bug in ChemTransforms

* fix leaks in testPickler

* fix leaks in testMolTransform

* fix leaks in testFragCatalog

* fix leak in testSLNParse. Still leaks due to Smiles

* fixed most leaks in testMolSupplier

* pre bison fix

* fix some atom & bond parse problems; others still fail

* bison smiles & smarts, atoms & bonds more or less fixed

* fix leaks in molopstest.cpp

* fix leaks in testFingerprints, MACCS.cpp & AtomPairs.cpp

* fix leaks in moldraw2Dtest1

* fix leaks in testDescriptors

* fix leaks in testInchi

* fix leaks in testUFFForceFieldHelpers

* fix leaks in hanoiTest & new_canon.h

* fix leaks in testMMFFForceField

* fix leaks in graphmolTest1

* fix leaks in testMMFFForceFieldHelpers

* fix leaks in testDistGeomHelpers

* fix leaks in testMolAlign

* initialize occupancy & temp facto with default values

* fix leak in TautomerTransform

* updated suppressions

* fix testStructChecker

* fix logging & py tests

* fix TautomerTransform class/struct issue

* remove misplaced delete in testSLNParse

* deinit in testAvalonLib1

* fix Avalon-triggered(?) bug in StructChecker/Pattern.cpp

* fix random testMolWriter/Supplier fails

- diversify output file names to avoid clashing.
- unify Writers close/destruct behavior.
- flushing/closing in tests.

* use reset in FFs Params.cpp

* comments on testMMFFForceField

* unrequired 'if's added to mol suppliers

* correct cast in FilterCatalog.h

* use unique_ptr in MACCS Patterns

* remove unrequred if in new_canon

* update & move suppressions
2018-10-29 14:33:26 +00:00
Greg Landrum
e8c46ca2a9 Fix/github1810 (#1811)
* Fixes #1810
There's still a problem with stereo atoms (see the commented out test),
but this takes care of the basics and that's up next.

* clean up that last problematic bit.
Still needs all tests to run

* this seems to be a necessary workaround for problems with VS2017.
It's a bit ugly, but shouldn't have any performance impact, so I'm not
going to get too worked up.

* This set of changes alters what we get for some of the InChI test cases.
Adjust for that.
2018-04-11 04:48:16 +02:00
Greg Landrum
650ad9e4f3 Add MolToInchiKey function() (#1784) 2018-03-23 15:54:06 -04:00
Greg Landrum
108d84ab1e Switch from boost::thread to std::thread (#1745)
* boost::thread mostly gone... still need to get rid of once
everything compiles

* replace boost::call_once

* remove link-time dependency on boost::thread

* first pass at using async

* switch to using async everywhere
2018-02-22 03:43:07 +01:00
Greg Landrum
4160d20fdc Fixes github #1572 (#1573)
* Fixes #1572
initial pass

* one more cleanup; adjust expected results for the python unit tets
2017-09-15 12:59:26 -04:00
Greg Landrum
954411f9ea Fixes #614 2015-09-20 04:26:08 +02:00
Greg Landrum
3937182db7 Fixes #562 2015-08-13 13:54:23 +02:00
Greg Landrum
26db26e931 add a final test for #437 2015-04-19 06:21:38 +02:00
Greg Landrum
ca0c495676 this is the fix for #437
inchi tests now pass, the rest still need to be checked
2015-02-20 06:27:13 +01:00
Greg Landrum
170205afe5 Fixes #296 2014-08-14 05:38:17 +02:00
Greg Landrum
246e300784 Fixes #68
Note that the molecules that are produced are still definitely
  not chemically sensible, but the InChI processing at least
  no longer hangs
2013-08-09 05:50:39 +02:00
Greg Landrum
0407268aa8 Fixes #67
this stereochemistry case is not correctly handled, but at least it
no longer generates a seg fault
2013-07-21 17:51:44 -04:00
Greg Landrum
f97705c7f2 Fixes #40 2013-06-07 06:59:04 +02:00
Greg Landrum
f467bdad9a fix problem caused by github-8 fix 2013-03-14 06:23:13 +00:00
Greg Landrum
8ff0480194 fix and test github issue 3: problems with inchi generation 2013-02-13 03:33:52 +00:00
Greg Landrum
6cfd347eaf make the inchi code thread safe 2012-03-10 05:40:53 +00:00