Commit Graph

67 Commits

Author SHA1 Message Date
Greg Landrum
52f73e4be0 Add support for Beilstein generics when doing substructure queries (#4673)
* backup commit
This is mabye heading in the right direction and at least passes the basic tests which are there.

* some progress

* more tests and refactoring

* additional aliases
add carboaryl

* add CYC and ACY

* add ABC

* add AHC

* CBC and AOX

* add CHC and HAR

* add CXX

* cleanup: remove a bunch of nullptrs

* initial tagging support

* remove atom labels/sgroups after using them

* docs

* start handing writing

NOTE: this does not currently work: the generic code needs to move out of SubstructSearch

* move the generic groups to their own library

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

* make sure the generic groups end up in ctabs

* add forgotten CMakeLists.txt

* fix includes

* expose this stuff to Python

* CYC needs to initialize rings

* renaming

* add docs

* change in response to review
2021-12-01 06:01:53 +01:00
Brian Kelley
cc5a941269 Recursive Substructure Search Deadlock (#4656)
* fixes #4651

* Remove unused import

* Switch to RAII

* clang-format

* Response to review

* Response to review - remove prints, use assertRaises
2021-11-08 06:30:14 +01:00
Paolo Tosco
3904b6958d Fixes RDK_BUILD_THREADSAFE_SSS=OFF build (#4349)
* - fix non-threaded *nix builds that currently fail because
  boost flyweight introduces a dependency on pthreads
- make sure that mutexes and futures are only used when
  RDK_BUILD_THREADSAFE_SSS is ON
- fix SubstructMatch failing test when RDK_BUILD_THREADSAFE_SSS is OFF
  due to misplaced #ifdef's
- rename RDK_TEST_MULTITHREADED to RDK_THREADSAFE_SSS in inchi.cpp
  (which is not a test)

* - the limitexternal Linux build is now single-threaded so we make
  sure single-threaded builds do not break in the future
  (suggestion from Greg)

* reverted unnecessary change to Code/GraphMol/FileParsers/testMultithreadedMolSupplier.cpp

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-07-23 14:25:25 +02:00
Paolo Tosco
4451bcde67 Make sure that ResonanceMolSupplier substructure matches are uniquified consistently (#4274)
* make sure that ResonanceMolSupplier subtructure matches are uniquified consistently

* 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

* Support using SubstructMatchParameters in RGD (#4318)

* support substructure search parameters in RGD.
Still needs testing/verification of the enhanced stereo stuff

* test enhanced stereo

* add support to python wrapper

unfortunately some python reformatting got mixed in there.

* addressed comments in review

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-07-13 06:54:07 +02:00
Gareth Jones
c2fb57c19f RGD - a fix for the cubane issue (single target atom matches 2 user R group attachments) (#4002)
* Most tests working

* All tests working

* Fixed tests after merge with master

* Create header and implementations for RCore

* Updated comments

* Removed old code

* DLL export for MolMatchFinalCheckFunctor

* Information line for failing Mac test

* Log replace core behaviour

* Ordering fix for OSX

* Possible fuzzer fix

* Removed debug output

* Fix unmatched user R group bug

* Code review changes

* Bug fix and ChemTransforms test
2021-05-23 15:16:03 -04:00
Greg Landrum
b6515eaade Fixes #4138 (#4145)
adds a short-circuit test to the substructure matching so that it immediately returns an empty result set if either the molecule or the query is empty
2021-05-18 08:44:12 -04: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
Brian Kelley
728bb8defe Fixes #3403 (#3405)
* Fixes #3403

* Fix Typo

V is actually a set so we can clear it.

* Fix bug, use self.assertFalse
2020-09-10 08:11:47 +02:00
Ric
66a38d3751 Address build warnings (#3082)
* do not throw in desctructor

* remove unused var; reserve

* provide operator= for DiscreteValueVect

* provide operator= for SparseIntVect

* remove unknown 'omp' #pragmas; refactor loop

* remove unused var

* remove unused variables

* give EmbeddedAtom a default constructor & early exit on self assignç

* handle unused vars/args

* catch exception by ref

* address unused args

* fix signed type comparison; refactor extra checks

* remove unused variable

* suppress switch fallthtough warning

* handle signed type comparison

* handle signed type comparison

* potentially uninitialized vars

* fix abs() of bool

* unused vars in catch statements

* remove unused variables

* python::list returns will be copied

* give ValidationMethod constructor & virtual destructor

* remove extra semicolon
2020-04-17 14:40:15 +02:00
Dan N
3dc1a220b7 Allow enhanced stereo to be used in substructure search (#3003)
* Test only commit for using enhanced stereo in substructure search

Adds some test cases to demonstrate what I'm planning.

When the test cases fail, the messages look like this:

    -------------------------------------------------------------------------------
    Enhanced stereochemistry
    AND and OR match their enantiomer
    -------------------------------------------------------------------------------
    /Users/wandschn/Documents/src/rdkit/Code/GraphMol/Substruct/catch_tests.cpp:216
    ...............................................................................

    /Users/wandschn/Documents/src/rdkit/Code/GraphMol/Substruct/catch_tests.cpp:218: FAILED:
    CHECK_THAT( *opposite_mol, IsSubstructOf(*mol_and, ps) )
    with expansion:
    CC[C@@H](F)[C@@H](C)O is not a substructure of CC[C@H](F)[C@H](C)O |&1:2,4|

    /Users/wandschn/Documents/src/rdkit/Code/GraphMol/Substruct/catch_tests.cpp:219: FAILED:
    CHECK_THAT( *opposite_mol, IsSubstructOf(*mol_or, ps) )
    with expansion:
    CC[C@@H](F)[C@@H](C)O is not a substructure of CC[C@H](F)[C@H](C)O |o1:2,4|

* rename parameter to include q and m to reduce my confusion

* Don't keep recreating a map

This map is the same in every loop. And actually, the desired
information is slightly different than what was formerly stored
in the map.

* Fix tests after our discussion.

Also adds more exciting tests of disastereomers and structures
with multiple stereo groups.

* Use enhanced stereochemistry in substructure searching

Allows use of enhaced stereochemistry in substructure searching
if `SubstructMatchParameters.useEnhancedStereo` is set.

The matching rules are pretty obnoxious, but a synopsis is:

* An achiral query/substructure matches everything, because it
  means "ignore chirality".
* An absolute query matches AND or OR, because they both include
  the molecule with an absolute center
* An query with an OR matches either an OR or an AND, because
  AND is more molecules.

* add info about matching to the documentation

* expose extended stereo matching option to python

* Some updates/tweaks to the documentation of enhanced stereochemistry

especially about searching.

* Code review comments.

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2020-03-21 05:12:40 +01:00
Greg Landrum
1830767d5d Fix a couple residual problems created by #2899 (#2935) 2020-02-05 16:32:08 +01:00
Greg Landrum
a2767d9f7d Allow custom post-match filters for substructure matching (#2927)
* backup, does not work

* working on the C++ side

* backup

* fix the API

* document the new functionality

* improve that example

* final bit of cleanup

* switch to std::function
2020-02-04 11:22:38 -05: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
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
Ric
df522d02aa E/Z and CIS/TRANS stereo bonds are incorrectly matched (#2596)
* add E/Z to CIS/TRANS translator

* use translator in matching

* add a test
2019-08-21 16:35:35 +02:00
Greg Landrum
a102eaf932 Add options for substructure searching (#2254)
* first pass at adding a SubstructMatchParameter struct

* start moving the rest of the backend to use the parameters

* backend at least mostly moved over

* add aromaticMatchesConjugated
add tests

* switch over the MolBundle too
Add templates to reduce duplicated code

* support older compilers

let's see if it works...

* add SubstructMatchParameters to Python wrapper

* remove some deprecations and warnings

* damn compilers

* parameter support for bundles in python wrapper

* add the parameters to the java wrappers

* response to review
2019-02-08 09:10:10 -05:00
Gregor Simm
c8154a4f5d Add missing boost header (#2016)
Add missing boost header for v1.64
2018-09-05 05:52:42 +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
1efa8e696e another clang-format run 2017-10-12 06:42:15 +02: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
bbd615497a Add a MolBundle class (#1537)
* very basics

* add the version to get all matches

* better exceptions, including tests

* documentation and actually add the test code

* responses to review
2017-09-11 13:04:58 -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
e625c58bab Add cis/trans tags to double bonds (#1316)
* add cis and trans to bond stereo

* compiles, does not work

* tests all pass

* Whitespace cleanup to recent changes.

* C++ test case for Bond::setStereo using Bond::STEREOCIS and Bond::STEREOTRANS

* Adding a PRECONDITION to Bond::setStereo to make sure the stereo atoms
are already specified if CIS or TRANS is being specified.

E/Z is technically defined by the topology of the molecule so the
stereo atoms are redundant (easier to understand and use!), but
ultimately redundant with the graph. However, CIS and TRANS is _only_
defined in this usage as the orientation of the atoms in the
getStereoAtoms vector.

* Exposing Bond::setStereo to Python and adding test cases to make sure
it can be used to set CIS/TRANS stereochemistry.

* verify substructure matching works

* Adding Bond::setStereoAtoms to C++ Bond class.

This allows setting the atoms to be considered for CIS or TRANS
directly without a much more costly determination of ranking that E/Z
requires.

* Wrap Bond::SetStereoAtoms into python with a new type of test case.

* docs
2017-02-26 08:15:44 -05:00
Greg Landrum
b31ae66e2d passes all tests except FMCS 2015-12-13 17:18:36 +01:00
Greg Landrum
40bbaa98fa still not there, but closer (maybe) 2015-12-13 10:58:41 +01:00
Greg Landrum
8b65790fde backup 2015-12-11 10:09:53 +01:00
Greg Landrum
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Greg Landrum
e37296d7c7 post review 2015-11-14 08:08:14 +01:00
Greg Landrum
5618819c64 merge #641 2015-11-14 05:03:24 +01:00
Paolo Tosco
95fcfe5cc4 - Fixed a post-decrement which causes a crash when compiling under Windows
with MSVC 9
2015-11-12 13:43:30 +00:00
Paolo Tosco
7f71c7033d - made the ResonanceMolSupplier really lazy, i.e. resonance structure
enumeration is only carried out when the user asks for a structure
  or when the user explicitly request that calling the enumerate()
  member function. This makes object creation fast and enables
  calling getNumConjGrps(), getBondConjGrpIdx() and getAtomConjGrpIdx()
  member function without incurring in the cost of necessarily
  enumerating resonance structures
- fixed some int/unsigned int inconsistencies
- now bonds and atoms with do not belong to conjugated groups
  get a -1 index
- added a few Python wrappers
- added a few tests
- removed unused variables from Code/GraphMol/ForceFieldHelpers/MMFF/Builder.cpp
- fixed ResonanceMolSupplier Java wrappers which were really broken
2015-11-03 14:57:56 +00:00
Paolo Tosco
3d48ba72e1 - added threading support to ResonanceMolSupplier and relevant tests
- added threading support to the ResonanceMolSupplier-enabled
  SubstructMatch() and relevant tests
- modified/removed some code in O3AAlignMolecules.cpp which doesn't
  seem necessary anymore
- modified Code/GraphMol/CMakeLists.txt to allow building
  on Windows
2015-11-01 23:01:34 +00:00
Brian Kelley
380badc12f Removes IFDEF internal API points, uses BOOST_FOREACH 2015-10-29 13:49:35 -04:00
Brian Kelley
bf99daea04 Merge branch 'master' into fix/fix-unlocking-mutexes-that-arent-locked
Merged with ResonanceSupplier based changes
2015-10-28 18:10:47 -04:00
Brian Kelley
340d4274cc Fixes trying to unlock mutexes that aren't locked 2015-10-28 16:42:36 -04:00
Paolo Tosco
f43677b978 - fixed a problem with thiocarboxylates/thiolates not being perceived
as conjugated like their oxygen analogs
- fixed an issue with large numbers of resonance structures exceeding
  the unsigned int allowance
- implemented the uniquify feature properly
- uniquify now defaults to false when using the ResonanceMolSupplier-
  enabled SubstructMatch() version
- the concept of 'laziness' is now clearer
- TODO:
  * remove some debugging info
  * move classes from .h to .cpp
  * SWIG wrappers
  * improve resonance structure sorting for degenerate resonance
    structures
  I will do all of the above ASAP
2015-10-21 20:06:53 +01:00
Brian Kelley
fbf9225172 Fixes more unused parameters 2015-10-18 16:07:57 -04:00
Brian Kelley
a146c3826a Remove unused variables/functions and register keyword 2015-10-18 10:01:00 -04:00
Paolo Tosco
eaa187b03d - added ResonanceMolSupplier
- added overloaded SubstructMatch() version supporting ResonanceMolSupplier
- added relevant Python wrappers
- added C++/Python tests
2015-10-04 23:21:28 +01: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
4b8caf2ceb Fixes #409 2015-01-10 07:21:55 +01:00
Greg Landrum
34ab68ca2a introduce QueryBond::QueryMatch, as with QueryAtoms;
all tests passing;
performance tests still needed
2014-05-07 05:29:25 +02:00
Greg Landrum
4a14a52674 Fixes #153 2013-11-15 06:47:18 +01:00
Greg Landrum
24764635d8 initial support for double bond stereochem in substructure searching 2013-03-11 05:36:00 +00:00
Greg Landrum
414b579b1c first pass at support for supporting atomic stereochemistry in substructure matches 2013-03-10 07:33:00 +00:00
Greg Landrum
14314b01ad add cmake configure variable to make multi-threaded stuff optional 2012-12-17 04:07:20 +00:00
Greg Landrum
bcf6310f11 an attempt to make handling of recursive SMARTS threadsafe.
This passes the tests here and in knime on linux64. Other OSs still need testing
2012-09-29 09:01:43 +00:00
Greg Landrum
3b3d44db16 remove exe property from source files 2011-01-13 04:22:56 +00:00