Commit Graph

59 Commits

Author SHA1 Message Date
Greg Landrum
8fbc3e66b1 Fixes #5930 (#5931) 2023-01-07 05:13:00 +01:00
Greg Landrum
67409c3acf Fixes #5152 (#5153)
Also adds a typeLabel to the bond order queries so that they are easier to recognize
2022-04-04 06:07:57 +02:00
Eisuke Kawashima
ba6d8e0d3b clang-tidy: readability-simplify-boolean-expr (#4639) 2022-03-17 13:50:50 +01:00
Paolo Tosco
0d8e985c38 queries containing AtomAnd should not be considered atom lists (fixes #5006) (#5007)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-02-14 04:58:27 +01:00
Greg Landrum
db15b372a1 Fix some problems turned up by ossfuzz (#4927)
* resolves oss-fuzz #24399

* clean up some undefined behavior

* fix some UB in mergeQueryHs

* be more defensive

* defensive programming

* fix a _cxsmilesBondIdx bug

* more defensive programming
2022-01-22 04:30:06 +01:00
Greg Landrum
8390dfd181 Fixes #4785: aromatic bonds no longer set aromatic flags on atoms (#4806)
* preliminary

* all tests pass

* cleanup

* more testing!

* we do still want to raise errors for aromatic atoms not in rings
fix one missed change for mol blocks

* update expected results for psql test
2021-12-17 10:26:59 +01:00
Riccardo Vianello
9a0a9e769c Prevent some loop variables from creating unnecessary copies (#4610) 2021-10-15 04:11:15 +02:00
Paolo Tosco
788f3ce02c Fixes #4496 (#4497)
* wip

* fixes #4496

* reverted file committed by mistake

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-09-13 04:54:26 +02:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04: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
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
fa6de7b423 Fixes #3912 (#3914) 2021-03-11 17:15:08 +01:00
Greg Landrum
0e89b2dbea cleanup a bunch of compiler warnings (#3849)
* cleanup a bunch of g++ warnings

* make it work with clang

* remove some additional warnings based on CI builds

* fix that version number

* stop being verbose when building
2021-02-26 05:10:02 +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
a068a18a53 all tests now passing 2020-12-08 15:39:45 +01:00
greg landrum
55bc8d7ec1 backup 2020-12-08 15:39:45 +01:00
Paolo Tosco
a9da05570e Fixes a couple of query-related bugs (#3398)
* - fixes a bug with the MDL MolParser (M  ALS queries clobber previously existing queries)
- fixes a regression introduced by #3389 (duplicate formal charge queries may arise)

* changes in response to review

* forgot to commit
2020-09-17 08:16:43 +02: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
Greg Landrum
1630540ef0 Add cxsmiles query atoms to CTAB parsers and writers (#3261)
* allow CXSMILES generic query atoms to be parsed from mol;
need more tests here

* remove vestigial directory

* Add d_queryType to Query
This opens up additional flexibility with customizing the way queries are handled
Also includes some assorted cleanups in the Query directory

* remove the MolFileSymbol hack added in #3235
We don't need it anymore

* Add support for additional ChemAxon extensions and document them

Signed-off-by: greg landrum <greg.landrum@gmail.com>

* bump pickle version

* add an additional test
2020-07-03 12:51:19 -04: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
Dan N
3b6dfb0343 Enable larger ring matches in SMARTS expressions (#2981)
Although these are probably nonsense, I've seen some pretty
big [r#] expressions in SMARTS expressions. In particular, for
SMARTS generated for toolkits that don't have the range
extension, people do this to mean "in rings bigger than 6" or
whatever:

   [r7,r8,r9,r10
2020-03-07 15:09:38 +01: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
920bf6b300 Fixes #2604 (#2689)
* Fixes #2604

* Changes in response to review

* Fixes #2709

* add tests
2019-10-13 09:33:10 -04:00
Greg Landrum
d8c49e6dab Code cleanups from PVS/Studio (#2531)
* first round of cleanups based on PVS-studio suggestions

* a couple more

* a few more cleanups

* another round of cleanups

* undo one of those cleanups
we want the integer rounding behavior here

* add a comment to make that clear

* Fix for filter catalog PRECONDITION redundancy
2019-07-13 07:25:37 +02:00
Brian Kelley
b6e5bdd111 Fix/rgroup sdf isotope (#2449)
* update version of japanese docs

* Remove external labels from cores

* Fix syntax errors

* Add better autodetection of labels, add dummyatom label, don't fall back to indexes when onlyMatchAtRgroups are set

* Add better autodetection of labels, add dummyatom label, don't fall back to indexes when onlyMatchAtRgroups are set

* Move autodetection before alignment, fix final core labelling

* Fix stupid bit twiddling mistake

* None of the original mol's should actually match the cores with onlyMatchAtRgroups

* Convert PRECONDITION to CHECK_INVARIANT

* Run clang-format

* use nullptr instead of 0 for pointers

* Handle cases where molecules don't have anything for an R-group properly.

Here's the python demo of the bug:

```
In [14]: scaffold2 = Chem.MolFromSmiles('c1c([*:1])cncn1')

In [15]: scaffold = Chem.MolFromSmiles('c1c([*:1])cccn1')

In [19]: mols2 = [Chem.MolFromSmiles(smi) for smi in 'c1c(F)cc(O)cn1 c1c(F)cncn1 c1c(Cl)cc(O)cn1'.split()]

In [20]: print(rdRGroupDecomposition.RGroupDecompose([scaffold,scaffold2],mols2,asSmiles=True,asRows=False))
({'Core': ['c1ncc([*:2])cc1[*:1]', 'c1ncc([*:1])cn1', 'c1ncc([*:2])cc1[*:1]'], 'R1': ['F[*:1]', 'F[*:1]', 'Cl[*:1]'], 'R2': ['[H]O[*:2]', '[H]O[*:2]', '']}, [])
```

* Fixes #2471
2019-06-04 15:41:20 +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
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
87786c08b5 Merge branch 'master' into modern_cxx
# Conflicts:
#	.travis.yml
#	Code/GraphMol/FileParsers/MolFileParser.cpp
#	Code/GraphMol/FileParsers/MolFileStereochem.cpp
#	Code/GraphMol/ForceFieldHelpers/UFF/testUFFHelpers.cpp
#	Code/GraphMol/MolAlign/testMolAlign.cpp
#	Code/GraphMol/MolDraw2D/MolDraw2D.cpp
#	Code/GraphMol/MolDraw2D/Wrap/rdMolDraw2D.cpp
#	Code/GraphMol/QueryOps.cpp
#	Code/GraphMol/ROMol.cpp
#	Code/GraphMol/SmilesParse/test.cpp
#	Code/GraphMol/Trajectory/Trajectory.cpp
#	Code/GraphMol/Wrap/Atom.cpp
#	Code/GraphMol/Wrap/Bond.cpp
#	Code/GraphMol/new_canon.cpp
#	Code/RDGeneral/testDict.cpp
#	Code/SimDivPickers/Wrap/MaxMinPicker.cpp
2017-10-05 05:58:38 +02: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
915cf08faa run clang-format with c++-11 style over that 2017-04-22 17:19:10 +02:00
Greg Landrum
7c0bb0b743 clang-tidy output 2017-04-22 17:09:24 +02: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
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Greg Landrum
00146b2cd7 Move the query information functions from Fingerprints to QueryOps.h 2015-08-18 16:41:24 +02:00
Brian Kelley
7fcf0bda9e RDKit learns how to query Atom/Bond properties
QueryBond qB;
  qB.setQuery(makePropQuery<Bond, double>("foo", 2));

  QueryAtom qA;
  qA.setQuery(makePropQuery<Atom, string>("foo", “bar”));
2015-02-27 08:28:17 -05:00
Brian Kelley
7a8df171d0 RDKit learns how to query properties on Atoms
Examples:

    QueryAtom qA;
    qA.setQuery(makeAtomHasPropQuery("foo"));

    QueryAtom qA;
    qA.setQuery(makeAtomPropQuery<double>("foo", 2));

    QueryAtom qA;
    qA.setQuery(makeAtomPropQuery<std::string>("foo", "bar"));
2015-02-25 15:28:34 -05:00
Greg Landrum
2d8500b407 Fixes #314 2014-08-21 07:29:09 +02:00
Greg Landrum
8959e07798 Fixes #313
NOTE: this still needs testing on machines with older versions of flex/bison
2014-08-19 07:20:04 +02:00
Greg Landrum
36ec3ff809 move towards more flexible queries 2013-12-14 09:59:12 +01:00
Greg Landrum
2cbc96aec2 laying the groundwork for more generic atomic query functions 2013-12-14 09:32:12 +01:00
Greg Landrum
b45423be3e rename makeAtomNumEqualsQuery() to makeAtomNumQuery() 2013-12-14 09:14:57 +01:00
Greg Landrum
97dd2d1f44 Fixes #60 2013-07-04 06:47:03 +02:00
Greg Landrum
e7d25d7973 tests passing except reactions 2012-04-21 04:40:55 +00:00
Greg Landrum
3b3d44db16 remove exe property from source files 2011-01-13 04:22:56 +00:00
Greg Landrum
f3fbef45c5 update copyright statements 2010-09-26 17:04:37 +00:00
Greg Landrum
e05580e495 This is a sizeable one: change the way BGL is used so that atoms and bonds are stored as bundled properties
instead of using the property map interface.
A nice side-effect is that the wart of having to use property maps to loop over bonds or atom neighbors
is now gone.
This potentially breaks lots of client C++ code.
2009-02-11 20:19:25 +00:00
Greg Landrum
335820c020 add explicit valence query 2008-11-17 08:09:23 +00:00