Commit Graph

70 Commits

Author SHA1 Message Date
Brian Kelley
21b79c13e2 Simple fix to allow aromatic CIS/TRANS SMARTS to match molecules (#8192) 2025-01-30 06:10:22 +01:00
tadhurst-cdd
ab5483dc51 Fix canonicalization of stereogroups (#7041)
* atropisomer handling added

* fixed non-used variables,  linking directives

* BOOST LIB start/stop fixes, linking fix

* Fixes for RDKIT CI errors

* minimalLib fix

* changed vector<enum> for java builds

* check for extra chars in CIP labeling

* removed wrong deprecated message

* fix ostrstream output error?

* restored _ChiralAtomRank to lowercase first letter

* changes for merged master

* Fixed catch label for new Catch package

* update expected psql results

* get swig wrappers building

* restore MolFileStereochem to FileParsers

* fix java wrapper for reapplyMolBlockWedging

* test changes

* some suggestions

* move a couple functions out of Bond

* Merge branch 'master' into pr/atropisomers2

* merged master

* Renamed setStereoanyFromSquiggleBond

* atropisomers in cdxml, rationalize atrop wedging, stereoGroups in drawMol

* Merge branch 'master' into pr/specialQueries

* changes from previous PR

* Iclude false chiral

* rigorous enhnced stereo canoncalization

* Added more tests and clenup

* removed commented out code

* corrected init of SmilesWriteParams

* added MolFileStereoChem.h to the header files

* Renamed Rxn parser to MrvBlockToChemicalReaction

* To make catch2 work, and match the checksum

* Fixed Structchecker errors

* fix CI for DetermineBonds catch test

* error in catch_test for CI

* Allow custom  smileWriteParams  in GetMolLayers

* misnamed entry point

* ReactionFromMrvString change name

* remove adding writeParams to GetMolLayers

* make rigorous enhanced stereo the default, and fix tests

* only one abs group no longer needs Rigorous Enhanced treatment

* changed string_view to string in catch test

* Canonicalize Enhnaced Stereo only resturne unique smiles

* Now allows or and and groups together

* internal routines inside detail scope

* fix test error

* changed string back to string_view and fixed a CHECK

* Fixes for PR review tests

* Fix RDKit_Book.rst failure on build test

* fix xqm sql test

* updated expected files for cxsmiles_test

* Fixed removal of atom attrs

* Fixed tests after merge of master

* More efficient version of Stereo Groups Canonicalization

* Fixes for ctests

* removed debug code

* readded cipLabel test

* fix generalizedSubstruct/catch_tests.cpp error

* hueristics to improve speed

* Rationaized control of abs groups

* removed unused routine

* added rigorous stereo group treatment to test

* some suggested changes

* Changes per PR review and removed some changes to smiles

* Fixed CI errors

* changes per PR review

* more PR review vhanges and cleanup

* Fixed PSql PKL change

* changes as per PR review

* Restored error type for bad mols for canonicalizeStereoGroups and added a test

* Merge master and fix test in MolDraw2D

* Fix for randomize test error and other PR review comments

* Removed unsued variable to fix mac CI

* do not force aromatization in canonicalizeStereoGroups

* changes as per PR review

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-10-25 05:09:30 +02:00
Greg Landrum
2bc3a2d3e2 Allow disabling output of dative bonds to SMILES (#7384)
* basic code to convert dative to single if we aren't outputting dative to the SMILES

add forms of GetAtomSmiles() and GetBondSmiles() that take SmilesWriteParams

* dative/coordinate bond support when writing CXSMILES

* expose all of that to Python

* remove usage of _doIsoSmiles property
add params to smarts writers

* allow disabling dative bonds in SMARTS

* typo

* add support to the reaction writers

* support params for SMARTS
2024-05-25 06:48:55 +02:00
John Mayfield
dd475b3677 Fix chirality handling when the chiral atom is the first one in a SMARTS (#6730)
* Set _SmilesStart when parsing SMARTS.

* SmartsWriter should also invert first atoms, like SMILES.

* Update test cases now these SMILES match themselves as SMARTS.

* rerun bison

* cleanup a possible repeated define

* When an atom moves from the first to second position winding should flip in SMARTS (i.e. same as SMILES).

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-10-05 06:02:49 +02:00
Ric
6b7c2e0488 Add a "rootedAtAtom" to MolToSmarts (#6581) 2023-08-19 19:17:45 +02:00
Ric
c1fc99e136 Enable "smilesSymbol" substitution in SMARTS (#6096)
* add some tests

* inject smilessymbol

* proposed changes (#9)

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-02-20 11:12:26 +01:00
Dan N
e60eaa3a90 Allow SMARTS of zero order bonds to match zero order bonds (#6037)
Before this commit, if you run MolToSmarts on a molecule with a
zero order bond (ZOB), the SMARTS won't match the ZOB! It's a bit
weird for a molecule not to be its own substructure...

This came up because in Schrodinger we see ZOBs somewhat frequently
in organometallics.
2023-02-02 05:05:11 +01:00
Greg Landrum
6a449def73 Fixes #4981 (#5030) 2022-02-22 20:35:44 +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
f777af9297 Fixes #4842: support $ for quadruple bonds in SMILES and SMARTS (#4850)
* add quadruple bond SMILES/SMARTS extension

* add .cmake files
2022-01-05 16:30:41 +01: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
ab3aafa330 CXSMILES improvements (#4396)
* docs

* cleanup

* docs

* backup

* support parsing polymer sgroups from cxsmiles

* add _smilesBondOutputOrder

* make that work with SMARTS too

* get the writer working and update the docs

* ensure processCXSmilesLabels() is called at the appropriate time

* test simplification

* handle multiple s groups
test multiple s groups + data

* set sgroup indices
handled sgroup hierarchy

* write linknodes
2021-08-09 17:21:00 +02:00
Greg Landrum
d4672519ee Fixes #4319: allow CXSMILES extensions for SMARTS (#4350)
* Fixes #4319

* python support

* doc update

* more testing
2021-07-23 04:40:22 +02:00
Greg Landrum
3f7a83c890 Fixes #3774 (#3842)
* Fixes #3774

also speeds up compiles of the SMILES catch tests by using the catch_main.cpp in GraphMol

* add a SMILES test too... just to be sure
2021-02-23 05:03:10 +01:00
greg landrum
55bc8d7ec1 backup 2020-12-08 15:39:45 +01:00
jones-gareth
aa4d5dc22c Fixes for aromatic bond fuzzy queries (#3328)
* C# wrapper for fragmentMolOnBonds

* Fix failing tautomer query test

* Fix ChemTransforms.i

* SmartsWriter fix
2020-08-10 05:00:19 +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
853d9137c8 Fixes #3197 and #3206 (#3208)
* add tests

* Fixes #3197

* Fixes #3206
2020-06-04 13:27:29 -04: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
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
a75018fe38 Cleanups and additional tests to improve test coverage (#2852)
* disable builds of the StructChecker code by default

* operator"" _smarts() doesn't need to catch sanitization errors

* remove unused function

* turn back on some tests that shouldn't have been disabled

* Remove unused code from SMARTS parser and simplify a bit

SmilesParseOps::AddFragToMol is now used only from the SMARTS parser, so we can simplify the API

* Removes obsolete special case code for SMARTS

This was relevant when organic atoms in SMARTS queries were stored as two-part queries.

* improve SMARTS testing

make sure we can generate SMARTS from all the examples and then parse that again.

* Fixes #2814

* Fixes #2815

* some additional smarts tests to improve coverage

* test copy ctor and getPos

* remove obsolete test_list files

* include tests for the morgan invariant generators

* more cleanups and coverage improvements

* remove files that were mistakenly added
2020-01-09 16:07:55 -05:00
Eisuke Kawashima
5cd27a242f Fix typo (#2862)
* Fix typo

* Reflect the comments

* Fix more typos
2019-12-31 06:43:27 +01:00
Greg Landrum
97b0b6b31d Fix a couple of smarts bugs (#2816)
* turn back on some tests that shouldn't have been disabled

* improve SMARTS testing

make sure we can generate SMARTS from all the examples and then parse that again.

* Fixes #2814

* Fixes #2815
2019-12-03 04:38:55 +01:00
Paolo Tosco
16c2b9ade1 - fixes #2801 (#2802)
- corrects a couple of typos
2019-11-29 13:39:43 +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
Ric
bb3bdb01ea Fix some chirality issues in SMARTS writing/parsing (Issues #2565 & #2568) (#2570)
* forward doIsomericSmiles

* added test for #2565

* fix for my snippet

* update test with Greg's comments

* add braces for readability to MolMatchFinalCheckFunctor

* small refactors: abstract label checking, while/size, final check

* merge loops reading order of bonds -- all tests pass

* fix chiral-lead fragments, allow frags w. degree < 3

* add new test, update old

* add test, update old

* fix (inocuous) bug with ranks assignment in MolToSmarts

* start SMARTS with first non-chiral atom

* use smart pointers in test

* reenable doIsomericSmiles

* update patch for #2594

* remove faulty fragments matching

* review tests, remove wrong flip
2019-10-03 15:33:46 +02:00
Dan N
e0f6119589 Adds MolFragmentToSmarts to generate smarts for a subset of a Molecule (#2594)
We have MolFragmentToSmiles already. But I think that when talking
about a fragment or part of a molecule, maybe SMARTS makes more
sense. If I see a SMILES string, I'll definitely think that
it should be a valid molecule, but I have no such
presumption about SMARTS.

Additionally, Schrodinger software sometimes generates SMARTS
for selection using a set of atoms picked in a GUI. It will
be useful to generate these SMARTS using RDKit.
2019-08-15 05:09:56 +02: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
Greg Landrum
bc0b177ceb Fixes #2450 (#2457)
* Fixes #2450
adds `hasOwningMol()` to the public API for Bond and Atom

* add to other classes;
add to python wrappers

* get the smiles generation partially working

* changes in response to review
2019-05-22 09:23:44 -04:00
Greg Landrum
7ba5c54277 Fix #2197 and #2237 (#2238)
* Fixes #2197

* Fixes #2237
2019-01-24 15:20:08 -05:00
Greg Landrum
da0674e7a7 Fixes #2142 (#2146) 2018-11-08 12:04:06 -05:00
Greg Landrum
a9ed60d17c Call updatePropertyCache() before generating SMARTS. (#1986)
Fixes: #1985
2018-08-12 16:57:03 -04:00
Greg Landrum
6021312630 Fixes #1906 (#1956)
* Fixes #1906

* changes in response to review
2018-07-17 04:45:29 +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
26718fd45f Fixes #1756 (#1757) 2018-02-22 03:43:46 +01: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
636a0f6e69 Cleanup a bunch of compiler warnings (#1697)
* remove a bunch of compiler warnings

* remove some more warnings on windows (there are still plenty to go...)
2017-12-22 12:59:52 +01:00
Greg Landrum
1efa8e696e another clang-format run 2017-10-12 06:42:15 +02:00
Greg Landrum
f40f75584b Fixes #1472 (#1473)
* Fixes #1472

* handle isotope info too
2017-07-02 11:30:44 +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
Jan Holst Jensen
5616dc2597 Add support for dative bonds. (#1190)
* Add support for dative bonds to molfile reader plus writer and to SMILES reader (SMILES writer already supports it).
Initial V3000 molfile reader and writer dative bond support by Esben Jannik Bjerrum.

* first pass at adding -> as dative bond in smiles/smarts
more testing required

* all tests pass

* update .cmake files for lex
2016-12-14 09:44:18 +01:00
Greg Landrum
080a659f78 Fixes #893 (#958) 2016-06-24 14:20:47 +02:00
Greg Landrum
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Brian Kelley
5f59333a56 Silences unused parameters 2015-10-18 14:02:29 -04:00
Greg Landrum
6d7b2b0914 merge with master 2015-01-22 06:30:51 -05:00
Brian Kelley
95a92282d1 Dictionary access is saniztized and optimized.
o rdkit gains a RDKit::common_properties namespace that contains common string value properties

 o Dict.h and below gain getPropIfPresent that attempts to retrieve a property and returns
  true/false on success or failure.  This is used to optimize access.

 o rdkit learns how to pass property keys by reference, not value.

A new namespace has been added to RDKit, common_properties
that contains the std::string values for commonly used
properties.  This helps to avoid typos in string values
but also avoids a creation of std::strings from character
values.  All accessors (has/get/clear and getPropIfPresent) now pass
the key by reference.

Additionally, getPropIfPresent removes the double lookup
of hasProp/getProp which can be a significant speedup
in the smiles and smarts parsers (10-20%)
2015-01-15 12:23:29 -05:00
Greg Landrum
ab0f1dcf60 rename to new_canon (probably should come up with a better name, but this will do for now) 2014-12-22 07:56:26 +00:00
Greg Landrum
06478b7779 Merge remote-tracking branch 'origin/NewCanonicalization_24July2014' 2014-08-23 02:03:52 +02:00
Greg Landrum
2d8500b407 Fixes #314 2014-08-21 07:29:09 +02:00
Greg Landrum
326fdc0463 Merge remote-tracking branch 'origin/master' into NewCanonicalization_24July2014 2014-08-21 05:08:56 +02:00