85 Commits

Author SHA1 Message Date
Greg Landrum
972b31e239 Add 'k' extension to SMARTS to support ringsize queries (#9172)
* switch the Query infrastructure to use std::function

* add releasenotes mention

* refactor makeAtomInRingOfSizeQuery() to use lambdas and support range queries

* add 'k' atom query to SMARTS

* changes in response to review
2026-03-17 15:02:59 +01:00
Greg Landrum
fa011fe425 switch the Query infrastructure to use std::function instead of function pointers (#9169)
* switch the Query infrastructure to use std::function

* add releasenotes mention

* response to review

Removed commented-out function pointer declarations for match and data functions.
2026-03-14 05:57:02 +01:00
Greg Landrum
32608ae0b4 Atoms bonded to metal atoms should always have their H counts explicit in SMILES (#8318)
* refactor the code to determine whether or not an atom is in brackets

* move the definition of isMetal to QueryOps

* atoms bound to metals in SMILES should always be in square brackets

Implementation and some test updates

needs confirmation that all of tests run

* basic tests pass

* java tests pass

* update js tests

* doc updates

* Update Code/GraphMol/catch_graphmol.cpp

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>

* Update Code/GraphMol/SmilesParse/test.cpp

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>

* finish fixing tests

* bump yaehmop version to allow compilation to work

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-03-29 07:26:03 +01:00
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Brian Kelley
eacc365b27 GitHub 7865 haspropwithvaluequery leaks (#7872)
* Properly cleanup Dict::Pair when serializing HasPropWithQueryValue

* Make sure pickling doesn't change original molecule

* Fix bad cut and paste

* Add PairHolder utility class for memory management of non Dict Dict::Pairs, fix mem leak in pickler

* Edit comment to force a rebuild

* Ignore PairHolder from Java/Swig builds

* Ignore PairHolder API from swig

* Reponses to review

* Add backward incompatible change

* Make release note a bullet point
2024-10-30 06:12:40 +01:00
Greg Landrum
da6cd73168 Run clang-format across everything (#7849)
* run clang-format-18 across Code/*.cpp and Code/*.h

* run clang-format-18 across External
2024-09-26 13:39:02 +02:00
Ricardo Rodriguez
4c37b03071 give a HasPropWithValueQueryBase a virtual destructor (#7786) 2024-09-09 13:06:44 +02:00
Brian Kelley
fa0463a591 Adds HasPropWithValue Pickler (#7692)
* Adds HasPropWithValue Pickler

* Revert changes

* Resolve review comments

* more comprehensive testing

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-08-26 16:27:58 +02:00
Greg Landrum
1790de84d3 Fixes #7675 (#7680)
* Fixes #7675

* update expected psql results
these changed because of the version bump to the pickles
2024-08-02 09:24:34 +02:00
David Cosgrove
f48c87444d Expose replaceAtomWithQueryAtom to Python (#7380)
* Expose QueryOpts::replaceAtomWithQueryAtom.

* Indentation error.

* Response to review.

* Update docstrings in response to review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-05-07 06:50:59 +02:00
MarioAndWario
643a356e44 Fix Mol block parser by resetting atomic number to 0 for COMPOSITE_OR query atoms (#6349) (#6768)
* Fix Mol block parser by resetting atomic number to 0 for COMPOSITE_OR query atoms (#6349)

* Fix fileParsersTest1

* Fix test23MolFileParsing

* Fix testRGroupDecomp

* Fix testSubstructMatch

* Use std::unique_ptr instead of raw pointer

* Add isAtomDummy() to QueryOps.h

* Add `!a->getQuery()->getNegation()`
2024-01-23 17:13:53 +01:00
Greg Landrum
22ac03329d switch from boost::any to std::any (#6662)
* switch from boost::any to std::any

* changes in response to review

* handle the slightly different error messages from different compilers

* document changed error message

* try to use g++10 for the linux builds

* remove those CXX defns

* another spelling

* stupid typo

* bump all linux builds to g++-10

* some day this will be done

* small steps

* increase mac ci builds runtime
2023-08-25 17:55:33 +02:00
Jonathan Bisson
eec44e4171 Support additional generic groups (#6570)
* Add search groups (#32)

Tracker story: 184574393 - Support additional query features [1]

All the special groups and atom from the Ketcher extended table are now supported in RDKit. The newley added ones include:
ABH, ACH, AEH, AHH, ALH, AOH, ARH, AYH, CAH, CBH, CEH, CHH, CXH, CTH, G, G*, GH, GH*, R, and the atom query types D, T, H+., and Pol

* Fix tests

Remove Marvin specific code

* Fix windows build

* Fix windows build

* Remove atom matches

* Remove test

* Fix doc

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/generic_tests.cpp

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

* Update Code/GraphMol/GenericGroups/generic_tests.cpp

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Added test for groups added manually to a query
as per PR review suggestion

* stop reading generic groups as atomnull queries

---------

Co-authored-by: tadhurst-cdd <112502803+tadhurst-cdd@users.noreply.github.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
Co-authored-by: Tad Hurst <tad.hurst@collaborativedrug.com>
2023-08-10 06:36:38 +02:00
Greg Landrum
0147cd8201 Fixes #5210 (#5408)
* revert duplicate chunk in release notes

* replace deprecated ifdefs
This one gets rid of USE_BUILTIN_POPCNT and RDK_THREADSAFE_SS
use RDK_OPTIMIZE_POPCNT or RDK_BUILD_THREADSAFE_SSS instead

* get rid of BUILD_COORDGEN_SUPPORT from ROMol.i

* fix a stupid typo

* update release notes
2022-07-11 11:20:03 +02:00
Eisuke Kawashima
ba6d8e0d3b clang-tidy: readability-simplify-boolean-expr (#4639) 2022-03-17 13:50:50 +01:00
Eisuke Kawashima
27f711a658 Run clang-tidy (readability-braces-around-statements) (#4977)
https://github.com/rdkit/rdkit/pull/3024#discussion_r526549843
2022-03-10 08:00:10 +01:00
Ric
64939375a0 fix warning (#4555) 2021-09-25 15:46:48 +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
Eisuke Kawashima
013ba4f21d Run clang-tidy (modernize-use-override) (#4251) 2021-07-01 05:18:56 +02:00
Eisuke Kawashima
48f4f3ee82 Run clang-tidy (modernize-pass-by-value) (#4224) 2021-06-14 06:57:08 +02:00
Eisuke Kawashima
78aac3c1bc Run clang-format against header files (#4143) 2021-06-08 07:57:51 +02:00
Greg Landrum
ee5176a557 Enable storing queries in JSON (#4003)
* start refactor query pickling

* further query pickling refactoring

* bit of modernization

* partial implementation of query writing

* serialize recursive queries

* new tests

* support QueryAtom and QueryBond with null queries

* more query cleanup

* tests pass

* switch from std::variant to boost::variant

* update clang version for CI

* explicit instantiation of templates

* get dll builds working on windows

* optionally skip h counts on parsing; more query tests

* change in response to review

* changes in response to review
2021-05-04 06:37:24 +02:00
Greg Landrum
487b1c9d51 Fix definition of bridgehead stereo (#3968)
* support ring stereo from Ns

* modify the definition of bridgehead from #3958

* changes in response to review
2021-03-24 14:45:35 +01:00
Greg Landrum
009e593b5c MolDraw2D: first pass at rendering atom lists (#3804)
* first pass at rendering atom lists

* a bit of additional cleanup
2021-02-17 15:25:53 +01:00
greg landrum
55bc8d7ec1 backup 2020-12-08 15:39:45 +01:00
Greg Landrum
f14f8a60de Expanded support for CXSMILES features (#3292)
* move replaceAtomWithQueryAtom() and completeMolQueries() to QueryOps namespace

* support ring bonds from cxsmiles

* add a test that is still failing

* update nonHydrogenDegree query, add SMARTS extension for that

* some cleanup

* unsaturation and substitution count

* fix typo in test

* update expected result

* add linknodes

* add variable attachment points

* improve documentation of supported cxsmiles features

* clarifying the docs

* support leaving out the outer atoms in LN specs
2020-07-25 05:06:08 +02:00
Greg Landrum
a9010da8a4 Small bug fixes and cleanups from fuzz testing (#3299)
* fix ossfuzz issue 24074

* fix ossfuzz issue 23896

* switch to throw exceptions when reading ints/floats

* remove extraneous benchmarking code

* change type of AH query

* confirm an invariant while finding rings

* no sense in adding these tests to github

* switch to use fail() instead of failbit
switch to acceptSpaces by default
2020-07-22 16:57:31 +02:00
jones-gareth
21a8a263bd Tautomer search (#3205)
* TautomerQuery class

* working test

* Comment header

* Merge with master. Greg's suggestions. More tests. Python wrapper

* Updated Pattern Fingerprints to merge with master. Reset email

* Java/C# wrappers. Java test

* Java/C# wrappers. Java test

* Java/C# wrappers. Java test

* Greg suggestions of 6_2_2020

* Explicit types in Java TautomerQueryTests class

* Update Code/GraphMol/QueryOps.h

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

* get windows dll builds working

* Removed tautomer query wrappers from RDKit namespace

* Fixes from evaluation

* Template molecule identification fix. Greg's suggestion

* Final check search functor for evaluating template matches as they are found

Co-authored-by: Gareth Jones <gjones@glysade.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-06-24 17:27:40 +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
Eisuke Kawashima
e86e2c1d5d Modernization: use nullptr (#3143) 2020-05-25 09:40:01 +02:00
Greg Landrum
9991c5247a cleanup of the SMILES/SMARTS parsing and writing code (#2912)
* first cleanup

* next round of changes. all tests pass

* Fixes #2909

* Fixes #2910

* further cleanup

* some cleanup/refactoring of the Dict class

* remove now extraneous calls to hasProp() before clearProp()

* minor refactoring of RDProps.h

* Switch from using our own version of round() to std::round()

* replace some boost::math stuff with the equivalents from std::

* cleanups in SmartsWrite

* refactor out a bunch of duplicated code

* fix an instance of undefined behavior

* changes in response to review
2020-01-29 15:13:39 +01:00
Greg Landrum
e49317bfcb merge 2019-10-25 04:48:08 +02:00
Greg Landrum
920bf6b300 Fixes #2604 (#2689)
* Fixes #2604

* Changes in response to review

* Fixes #2709

* add tests
2019-10-13 09:33:10 -04:00
Eisuke Kawashima
31b8f870b4 Do not catch exceptions by value 2019-10-10 20:22:17 +09:00
Greg Landrum
ec31bea97b clang-tidy-7 pass (#2408) 2019-04-16 12:05:47 -04:00
Brian Kelley
46d68bbe67 Add ExplicitBitVect prop and query (#2384)
* Add ExplicitBitVect prop and query

* Fix for review comments
2019-04-03 04:46:14 +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
Ric
91008ff11d Address compile warnings & trivial improvements (#2097)
* Address compile warnings & trivial improvements

* revert unwanted initializers; use RDUNUSED_PARAM for unused params

* revert fix in testRDFcustom; marked with 'TO DO' comment
2018-10-12 06:39:32 -04:00
Greg Landrum
2738c35178 Fixes #1903 (#1971)
* Fixes #1903

* update SWIG bindings too
2018-07-25 09:14:17 +02:00
Greg Landrum
dfae8377dd Some optimization of the queries constructed from SMARTS (#1940)
* Fixes #1929

* add a tests to make sure bogus template directories work

* add a combined atomic number + aromaticity query operation to speed up SMARTS matches
Still needs to be recognized by the SMARTS writer, serialization, and no doubt a few other places.

* add a combined query for the single/aromatic bond query that shows up in SMARTS

* Stop using a dead pointer in the when parsing Marvin SMARTS in a CTAB

* At this point all tests pass on windows

* debugging info back in

* update the bison output
2018-06-30 20:22:06 -04:00
Brian Kelley
c5deeb4839 Fix for matchOnlyAtRgroups to allow H replacements as well (#1871)
R-group Decomposition: allow H replacements when matchOnlyAtRgroups is set
2018-05-21 05:37:15 +02:00
Paolo Tosco
c08ea49bda - enable building DLLs on Windows (#1861)
* - enable building DLLs on Windows

* - export.h and test.h are now auto-generated by CMake
2018-05-16 08:42:41 +02: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
ba12d98ad0 Removes ATOM/BOND_SPTR in boost::graph in favor of raw pointers (#1713)
* Removes ATOM/BOND_SPTR in boost::graph in favor of raw pointers

* Actually delete atoms and bonds...

* RWMol::clear now calls destroy to handle atom/bond deletion

* Changes broken Atom lookup for windows/gcc

* Adds tests for running with valgrind

* Adds test designed for valgrind and molecule deletions

* Removes RNG, actually tests bond deletions

* update swig wrappers

* deal with most recent changes on the main branch
2018-01-07 14:19:47 -05:00
Greg Landrum
4049814132 Support some cactvs extensions to SMARTS (#1704)
* add queries for the number of heteroatom neighbors

* support cactvs "z" extension
this includes support for range queries on z that could
be extended to other query types as well

* extend range query extension to other SMARTS primitives

* add the less-than and greater-than versions of the range queries

* updates and new tests

* update .cmake files

* support [#6] in SMILES

* document SMILES extensions (such as they are)

* Add support for cactvs's Z queries

* add support for ^4 and ^5

* get tests running
doc update

* book updates

* update .cmake files
2018-01-04 12:00:39 -05:00
Greg Landrum
db89172bf8 handle the heavy-atom degree queries differently (#1560)
* handle the heavy-atom degree queries differently

* Fixes #1563

* add a test for the heavy atom degree option

* Support (and test) adjustHeavyDegree in the cartridge too.

* test results
2017-09-12 16:10:15 -04:00
Greg Landrum
270f7b76e5 Partial support for reading CXSMILES (#1237)
* add a SmilesParserParams object to prepare for this

* add a SmilesParserParams object to prepare for this

* add tests for the SmilesParseParmas

* support name parsing, should it be the default?

* rename CXNSmiles to CXSmiles;
add a spirit parser for CXSmiles coordinate that is at least syntax correct

* abandon boost::spirit for now; crude atom token parser

* support params in smiles parser (not tested, may not build)

* can read coords and atom labels along with mol names; crude, but works

* read coordinate bonds

* remove some compiler warnings with VS2015

* remove a bunch of compiler warnings on windows

* remove more warnings on windows

* remove more warnings on windows

* backup commit: first pass at parsing query features

* radical spec parsing

* handle attachment points using atom mapping

* switch to a named property for atom labels

* fix handling of the "A" atom query

* add functions to construct A and Q queries (needs more work)

* fix a problem created while cleaning up warnings earlier

* add some additional convenience functions for making generic atoms.
Still need M and to recognize these while writing CXSMILES

* add M queries; update some tests

* fix a linux compile problem

* get the cxsmiles stuff working in python; basic testing

* support "M" in CXSMILES
2017-01-31 13:50:36 -05:00
Greg Landrum
6745264a82 Adds some additional canned atom and bond query definitions (#1047)
* atoms: radical electrons and presence of a chiral tag

* bonds: presence of stereo

* add new atom queries to python wrapper

* add queries for missing atom chiral tags
2016-09-09 10:31:02 -04:00
Greg Landrum
03cd55e635 Dev/cleanup warnings (#948)
* Remove a bunch of warnings

The biggest change here is to treat the boost includes as system libraries.
This causes g++ to ignore warnings from boost.
This change still needs to be tested with clang and on Windows

* suppress a bunch of warnings on clang
2016-06-22 13:49:15 -04:00
Brian Kelley
bd8bdb09d4 Fixes exception when using gcc 4.1 or earlier (RHEL5 default compiler) 2016-04-01 11:02:35 -04:00