Commit Graph

240 Commits

Author SHA1 Message Date
Ricardo Rodriguez
f3dd424d28 make ringdecomposerlib a mandatory dependency (#9209) 2026-03-27 18:17:27 +01:00
Ricardo Rodriguez
680520e0ad Follow up to PR #8968 (#9168)
* implement consistency check

* add more consistency checks

* check direction consistency accross double bond

* clean up directions for non-stereo bonds

* fix counts for second from atom dirs; add check

* handle inconconsistent bond dirs

* add more tests, pubchem cases, and update existing

* drop statics

* fix typo

* make sourceBond arg const

* fix consistency check
2026-03-20 04:28:17 +01:00
Ricardo Rodriguez
d5aa90e18f Fix for issue #8965 (#8968)
* add a test

* change stereo bond canonicalization

* update canonicalization watch test with fixed cases

* make canonicalization test stricter (compare CIP codes)

* add reverse symmetry condition

* rewrite double bond canonicalization code

* update tests

* fix multiline comment

* update java tests

* update python test

* nix switchBondDir (unused)

* fix and rename flipBondDir

* refactor comment

* fix shadowed var name, casting

* fix neighbor sorting

* make seen_bonds a vector

* abstract setDirectionFromNeighboringBond

* handle both sides of the bond have directions

* move getNeighboringStereoBond

* check seen_bonds after popping connectedBondsQ

* use references for arguments

* add release note

* add example required by Dan

* add example requested by Dan
2026-02-26 08:58:36 +01:00
Eisuke Kawashima
e89c9f656a style: apply readability-braces-around-statements (#8136)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2026-02-09 12:10:50 +01:00
Ricardo Rodriguez
d4641c1f58 Fix removing (non)redundant bond dir specs when exporting SMILES (#9066)
* increase counts to avoid removing non-redundant bond dirs

* update tests
2026-01-24 07:15:00 +01:00
Ricardo Rodriguez
22a9814655 Convert graphmolMolOpsTest to catch2 (#8978)
* move test to catch2

* fix one broken test

* make some stuff constexpr

* refactor some checks involving exceptions

* replace CHECK_INVARIANT

* replace CHECK_INVARIANT

* clean up commented out debug logging

* initialize var

* remove redundant REQUIRE_MSG
2025-12-03 06:28:56 +01:00
Greg Landrum
adf72c984f Do not reset the ringInfo information when adding bonds to RWMol (#8934)
* Do not reset the ringInfo information when adding bonds

This call was inconsistent (for example, the version of addBond() in ROMol did not do it)
and is unnecessary since the standard assumption is molecules need
to be re-sanitized after adding atoms and bonds

* response to review

clear the property cache on atoms after adding a bond.

* add a property cache update to the reaction runner

* add something to the release notes
2025-11-07 14:41:01 +01:00
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +02:00
Greg Landrum
951be4f06e fixes #5078 (#8795)
* fixes #5078

* add some more tests
2025-09-22 11:06:42 +02:00
Greg Landrum
21d694e88a fix a problem with stereogroups involving bonds and getMolFrags() (#8558)
This is a continuation of #8542
2025-05-27 16:43:20 +02:00
paconius
1147bcbc6d Fixes #8527 (#8542)
* Add getMolFrags test

confirm bond-only stereogroups are preserved during fragmenation

* Update molopstest.cpp

* Prevent deletion of stereogroups

Prevent removeAtomFromGroups from deleting stereogroups that have bonds but no atoms
2025-05-25 14:58:48 +02:00
Greg Landrum
86141183c1 Moving towards getting all tests to pass when using the new stereo code (#8409)
* Fixes #8379

* check in some working tests

* test passes

* test passes

* test passes

* test passes

* test passes

* ensure that the invariants flush the streams on failure

* tests pass

* test passes

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* Fixes #8391

* tests pass

* fix a test with legacy
not clear why this was not causing problems before

* make a test work

* Fixes #8396

* gcc builds work

* fingerprint tests pass

* mention backwards incompatible change

* fix a problem with FindMolChiralCenters

* more testing details

* enable the test status output

* Fixes #8432

fix a bug in double-bond stereo handling for template matching

* all depictor tests pass

* use the new-stereo chiral ranks in the depiction code

* always assign new-stereo chiral ranks

* make _ChiralAtomRank a computed property
This is analogous to _CIPRank

* tweak to the way the atom ordering is computed for 2D coordinate generation

* update two expected results

* backup

* response to review

* tests pass

* tests pass

---------

Co-authored-by: = <=>
2025-04-15 14:00:32 +02:00
Greg Landrum
28db5d706c Revert "Fixes #5134 (#5136)" (#8319)
This reverts commit 8691c58055.
2025-03-05 18:11:24 +01:00
Greg Landrum
8691c58055 Fixes #5134 (#5136) 2025-01-30 16:10:57 +01:00
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Brian Kelley
7b31d5307b MergeQueryHs better detects hydrogens in OR queries (#8043)
* Fixes #7687

* Make sure high and low precedence ands also work

* really fix the issue

* Fix merge conflict

* Add AtomType to MergeH check with test
2024-11-26 04:44:32 +01:00
Hussein Faara
f35e7e6414 remove no-op macros and dead code (pt 1) (#8012) 2024-11-19 04:31:56 +01:00
David Cosgrove
293328845b Add overloads of MolOps::getMolFrags and MolOps::getMolFragsWithQuery (#7823)
* Add overloads of getMolFrags and getMolFragsWithQuery that fill in using std::unique_ptr rather than boost::shared_ptr.

* Response to review - do things in unique_ptrs from the outset rather than raw pointers.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-09-20 09:48:08 +02:00
Juuso Lehtivarjo
9824a9d964 Expose MMFF aromaticity model for SetAromaticity (#7765)
* Expose MMFF aromaticity model for SetAromaticity

* Test, backward compatibility, missing AromaticityModel wrapper
2024-09-18 05:59:02 +02:00
Greg Landrum
724716b2c6 Switch to isoelectronic valence model (#7491)
* change valence model to use isolobal analogy

Remove support for five-coordinate C+ and, by analogy, five-coordinate N+2

Removes support for charge states that take atoms past the end of the periodic table
  i.e. [Lv-4] is no longer supported

* update the tests for that

* remove valence state of 6 for Al

* fix representation of phosphate in the mol2 parser

this is a correction of what was done during #5973

* cleanup the exceptions for P, S, As, and Se

* drop valence states:

Si 6, P 7, As 7

* a couple of additional changes from #7397

* update java tests

* fix an inconsistency: Rb now supports valence -1

* documentation

* - replace operator[] with at() for bounds check
- extract some code into a function to avoid duplication
- use TAB as separator throughout in the periodic table data for consistency

* removing the .at() usage

We know that these vectors aren't empty, so there's no need for the bounds check.

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-06-25 15:38:49 +02:00
Paolo Tosco
f5431728db make sure outdated ring fusion information is recomputed before attempting to use it (#7274)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-03-20 09:37:10 +01:00
Ric
8d6e6aa00c Fixes #7123 (#7124)
* don't set noimplicit

* remove the (unused) origNoImplicit property

* update old test

* add check to test
2024-02-02 05:27:47 +01:00
tadhurst-cdd
73b4da2a44 New tests for specical query atoms and atropisomers (#7010)
* New tests for speical query atoms and atropisomers

* fixed error, and used unique_ptrs

* Removed test that makes GraphMol depend on GenericGroups

* More to remove GraphMol dependency on GenericGroups
2024-01-11 05:54:14 +01:00
Brian Kelley
cccee15a91 Add hasQueryHs (#6702) 2023-09-15 08:59:56 +02:00
Paolo Tosco
350370abe3 - Changed all unsigned to unsigned int for clarity (#6646)
- Switched from dynamic to static allocation for an instance of `MCSParameters`
- Switched to using `auto` where possible
- Added a few `CHECK_INVARIANT` where appropriate before dereferencing pointers
- Moved some inline comments to the previous line to improve readability
- Added a early check for `CompleteRingsOnly` in `checkBondRingMatch()` to improve computational efficiency
- Removed `RingMatchTableSet` entirely as 1) it is unnecessary since its functionality is already provided by `RingInfo` 2) it abused the `userData` pointer. This allows cleaning up and simplifying the code, particularly the Python wrappers which had a significant amount of added complexity to support it
- Removed all the code that was deprecated several releases ago
- Reimplemented ringFusionCheck() from scratch to address several bug reports; also switched from std::set to boost::dynamic_bitset for better efficiency
- Replaced boost::tie with boost::make_iterator_range
- Modernized `for` loops where possible
- Removed entirely the QueryRings structure as its functionality is already available in RingInfo
- Removed entirely the _DFS() function since the same algorithm can be implemented in a simpler and more efficient way using RingInfo (from 2m28.441s to 2m9.859s for the same task)
- Replaced std::vector<bool> with boost::dynamic_bitset
- Replaced C-style casts with C++ casts
- Replaced some size_t with unsigned int
- Refactored checkIfRingsAreClosed() such that checkNoLoneRingAtoms() is not needed anymore
- Added a test for slow runtimes with CompleteRingsOnly
- Setting Timeout to 0 means no timeout, as it should be
- Removed unused `steps` variable from `MaximumCommonSubgraph::growSeeds`
- Storing both Atom and Bond pointers and their indices on Seed and MCS data structures is time-consuming and a potential source of incons
istencies; storing pointers is sufficient
- Promoted `MaximumCommonSubgraph::match` from `private` to `public`
- `NewBonds` was declared `mutable`, but `Seed::fillNewBonds()` was incorrectly declared as `non-const`, which caused the need for an ugly
(and unnecessary) `const_cast`.
I have now removed the `const_cast` and correctly declared functions that alter `NewBonds` as `const`, since `NewBonds` is explicitly `mut
able`
- Removed some useless random scoping that was peppering the MCS code
- Removed a significant amount of duplicate code from the Python wrappers by inheriting from a base `PyMCSWrapper` class
- Fixed #6082
- Fixed #5510
- Fixed #5457
- Fixed #5440
- Fixed #5411
- Fixed #3965
- Fixed #6578

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2023-08-25 06:09:19 +02:00
Greg Landrum
58b79c6f8e BondDir not cleared from bonds that aren't stereoactive (#6162)
* backup

* update .gitignore

* passes tests

* all tests now pass

* update release notes

* cleanup

* changes in response to review
2023-03-07 15:15:11 +01:00
Ric
00460547a0 fix + test (#5100) 2022-03-17 04:53:17 +01:00
Paolo Tosco
dc4893132b Fixes #4721 (#4722)
* fixes #4721

* - store in RingInfo the index of the ring(s) each atom and bond belongs to rather tham just their size
- expand the RingInfo API with a few useful methods
- identify rings that are certainly aliphatic upfront
- avoid unnecessary copying atomRings when RingInfo is already initialized

* - code modernization and cleanup
- better handling of dummies in aromatic rings
- exposed atomMembers() and bondMembers()
- added several tests

* - avoid order dependency on rings
- added test for the above

* changes in response to review

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-01-28 16:38:46 +01:00
Ric
1c6b70fff3 fixes (#4569) 2021-09-28 04:42:39 +02:00
Greg Landrum
df72c241c5 Improve test coverage and some bug fixes (#4536)
* test getIdOfEntryWithBitId()

* remove unused functions

* improve bv tests in python wrapper

* more UniformGrid tests

* improve deprotect coverage

* improve abbreviations coverage

* add operator!= to DeprotectData

* more testing for adjustQueryProperties

* fix a copy-paste bug

* copy-paste bug

* more testing

* more testing

* more testing

* fix an edge case bug in getValenceContrib

* more bond tests

* add operator!= to StereoInfo
tests StereoInfo::operator==

* make some internal functions testable

* more testing

* minor code cleanup

* fix some bad caching behavior in getDistanceMat() and get3DDistanceMat()

testing

* test FixeMolSizeMolBundle() copy ctor

* deprecate BalabanJ

* more testing

* testing

* mods to get things working for windows DLL builds
(don't bother running some of the tests there)

* fix a typo
2021-09-26 07:45:06 +02:00
Greg Landrum
4c2a580ad1 Fixes github #4311 (#4312)
* a bit of simple refactoring

* Fixes #4311

- adds getValenceContrib() to QueryBond
- adds hasBondTypeQuery() and hasComplexBondTypeQuery() to QueryOps namespace
- atoms with complex bond type queries now have explict and implicit valences of 0
- adds tests for the above

* add a test
2021-07-09 15:06:54 +02:00
Greg Landrum
3a82159b57 Cleanup some problems found during an ASAN build (#4054)
* MolFragmenter: fix a leak when exceptions are thrown

* DistGeomHelpers: fix leaks when exceptions are thrown

* SubstructLibrary: fix usage of invalid memory

* clear up leaks found during ASAN testing
2021-04-21 10:22:04 -04:00
Paolo Tosco
0e3aa77fd0 Make sure that added R-groups have non-zero coordinates (#3877)
* Make sure that added R-groups have non-zero coordinates

* - renamed setHydrogenCoords to setTerminalAtomCoords (and parameters accordingly)
- switched from ROMol* to RoMol& to remove a PRECONDITION
- documented the newly exposed C++ function
- added a Python wrapper
- added C++ and Python tests

* fixed conflicts and added a test

* Update Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* Update Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* Update Code/GraphMol/MolOps.h

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* Update Code/GraphMol/Wrap/MolOps.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

* changes in response to review

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-03-19 08:17:56 +01:00
Greg Landrum
f0896508f3 Fixes #3932 (#3933) 2021-03-15 17:21:50 +01:00
Greg Landrum
2e3f31990d Allow batch editing of molecules: removal only (#3875)
* backup

* simple first pass, passes all tests

* cleanup a bunch of existing uses

* ensure that we can safely add atoms/bonds while in edit mode

* add context manager on python side

* handle exceptions properly in those

* changes in response to review
2021-03-11 05:10:43 +01:00
Paolo Tosco
f04a9c9a42 - switched to using std::vector<unsigned int> for isotopichs property (#3878)
- switched to using std::vector<int> instead of std::list<int> for _ErGAtomTypes property
- added RegisterListConverter<std::vector<unsigned int>>

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-03-05 16:37:43 +01:00
Ric
bd712483cd Addresses #3854 (#3855)
* add fix

* add test

* fix the referenced issue

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-03-01 05:38:27 +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
b81e313c51 Fix #3631 (#3632)
* Fixes #3631

Still worth investigating *why* this happened.

* a bit of simplification/refactoring
2020-12-12 05:50:29 +01:00
Paolo Tosco
24e644dd29 Add better support for isotopic Hs to removeHs() and addHs() (#3396)
* Add better support for isotopic Hs to removeHs() and addHs()

* simplify the new code to add Hs back

* Changes in response to review

* revert FindCairo.cmake that I pushed by mistake (grrr)

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2020-09-24 05:09:42 +02:00
Paolo Tosco
d372865b67 Fixes a bug in AddHs() involving sp2 centers with degree 1 (#3383)
* Fixes a bug in AddHs() involving sp2 centers with degree 1

* Changes in response to review

* forgot to run clang-format
2020-08-31 13:42:37 +02:00
Greg Landrum
45b9aef28b clang-tidy modernize-use-default-member-init and modernize-use-emplace (#3190)
* run clang-tidy with modernize-use-default-member-init

* results from modernize-use-emplace

* one uniform initialization per line
otherwise SWIG is unhappy

Co-authored-by: Brian Kelley <fustigator@gmail.com>
2020-05-28 09:07:58 +02:00
Greg Landrum
c346aa1492 removes usage of the deprecated random_shuffle() function in a couple of tests (#3187) 2020-05-26 08:45:57 -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
dd21db1b06 Integrate Unique Ring Families from RingDecomposerLib (#2558)
* add the ring decomposer lib (temporarily?)

* simplify makefile

* very basics work

* backup

* 	basics working

* builds and basic tests pass

* get this building again

* expose the ring families

* add tests on the python side

* make the pywrapper for this optional

* remove some extra bits

* cleanup

* switch to using RDL as an external project

* make sure this still works if we do not use the URF code

* remove BUILD_ALWAYS

* fix linkage of Java wrapper and cartridge (hopefully)

* fix cmake for wrappers (hopefully)

* forgot a semicolon

* try to force URF lib to build first

* improve memory management and interface

* fix dependency specifier

* make pointer initialization explicit

This may not be necessary, but it feels safer.

* not pleasing and needs to be cleaned up
but it builds

* not pleasing and needs to be cleaned up
but it builds

* cleanup in preparation for merging

* cleanup in preparation for merging

* switch to rareylab repo

* fix updated copyright date

* Fix updated copyright date

* switch to a specific library tag

Co-Authored-By: Florian Flachsenberg <flachsenberg@zbh.uni-hamburg.de>

* change in response to review
2019-07-30 06:41:55 -04:00
Dan N
47acdc8b73 Issue #2403: Speed up SSSR symmetrization (#2410)
* Issue #2403: Speed up SSSR symmetrization

For my horrible example molecule (a highly symmetric
nanotube with 2400 atoms and > 1000 rings), this speeds up
symmetrizeSSSR() from 5s to about 0.002s. findSSSR() takes
another .4s or so.

* Refactor after Ricardo's suggestions

* Greg's review comments. use std::vector
2019-04-18 07:11:15 +02:00
Ric
6224a42516 Build warnings revisited (#2318)
* unused vars in bison parser cleanup

* initialization order in TopologicalTorsionGenerator

* unused params in SLN bison

* sln flex unused params

* throwing destructor in TDTWriter

* signed comparison in substructmethods

* unused input param in smiles/smarts bison

* unused ms param in sln bison

* signed comparison in FingerprintGenerator

* store return of fscanf in StructCheckerOptions

* unreferenced var in catch

* uninitialized value in FileParserUtils

* avoid override overload warning in MolDraw2DSVG

* non-final overrides in Validate.h

* unused static var in Avalon

* unused vars in catch blocks

* make AvalonTools avalonSimilarityBits & avalonSSSBits const int

* assert fscanf result in StructCheckerOptions
2019-03-08 16:42:54 +01:00
Greg Landrum
094f65f5f4 Fix #2148 and #2244 (#2275)
* not quite done yet

* Fixes #2244

* Fixes #2148

This fixes a few of the knock-on effects of the actual fix.

* Test that we still write SMILES properly

* Fixes #2266 (#2269)

* Fixes #2268 (#2270)

* Improve interactivity of output SVG (#2253)

* Add clickable atoms when tagAtoms() is called

* add python tests

* add class tags for atoms and bonds

* add marker to allow easy insertion of extra text
2019-02-21 08:03:28 -07: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
Paolo Tosco
f7c888844d moved test.h from RDBoost to RDGeneral for consistency with export.h (#2074) 2018-10-11 17:35:23 -04:00