Commit Graph

50 Commits

Author SHA1 Message Date
Paolo Tosco
30d57ebcaa Implement MinimalLib get_mcs() version that returns JSON (#6812)
* - added StoreAll to parseMCSParametersJSON()
- added get_mcs() to MinimalLib which returns results as JSON
- added tests for get_mcs()

* added test

* changes in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2023-10-22 05:22:14 +02:00
Paolo Tosco
d9d1fe2838 Fixes #6773 (#6785)
* fixes #6773

* removed unused captures

* update release notes and cmakelists for beta (#6788)

* Removed some code duplication between Depictor.cpp and common.h (#6368)

* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true)   to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications

* 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>

* Some small cleanups from the UGM Hackathon (#6744)

* move definition of a couple global constants from a .h to a .cpp

* careful removal of some redundant atom PRECONDITIONS

* careful remove of some redundant ROMol PRECONDITIONS
a bit of additional cleanup

* optimization masquerading as modernization

* some more tidying

* a bit more atom cleanup

* change in response to review

* Fixes #6756 (#6780)

* update release notes and cmakelists for beta (#6788)

* move problematic functions to Chirality namespace

* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true)   to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications

* move problematic functions to Chirality namespace

* added missing dependency

* let's check what is going wrong

* CoordGen tests should not run if CoordGen support is not available in the build

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
Co-authored-by: John Mayfield <john@nextmovesoftware.com>
Co-authored-by: greg landrum <greg.landrum@gmail.com>

* Revert "Removed some code duplication between Depictor.cpp and common.h (#6368)" (#6797)

This reverts commit ddfe708b37.

* All 3d des (#6741)

* add function to calc all 3D descriptors

* fix indentation in CalcMolDescriptors3D

* add error handling for 2D molecules

* suggested changes

* change exception type

* add unit tests

* add random seed to conf gen in unit tests

* fix function call in unit tests

* fix expected PMI1 value in tests

---------

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

* _moltoimg() should honor drawOptions.prepareMolsBeforeDrawing (#6792)

* _moltoimg() should honor drawOptions.prepareMolsBeforeDrawing and not run PrepareMolForDrawing if requested not to

* _moltoimg() and _moltoSVG() should honor drawOptions.prepareMolsForDrawing and not call PrepareMolForDrawing if asked not to

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>

* Bad lasso (#6751)

* Better separation of lines.

* Only put atoms in colour list once.

* Test.

* Hash codes.

* Response to review.

* First attempt at fixing stray line.

* Tidier.

* Squared distances.

* tag release (#6801)

* fixes #6773

* removed unused captures

* - fixed comment
- fixed bug found in checkIfRingsAreClosed()

* - removed redundant NRing queries
- added ring size queries to avoid incorrect matches with MCS results originated with MatchFusedRingsStrict

* fixed doctests

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
Co-authored-by: John Mayfield <john@nextmovesoftware.com>
Co-authored-by: Rachael Pirie <56546141+RPirie96@users.noreply.github.com>
Co-authored-by: David Cosgrove <davidacosgroveaz@gmail.com>
2023-10-19 05:01:27 +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
Paolo Tosco
02f492ae58 replace a try..catch block with an if clause (#6488)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-06-24 07:46:38 +02:00
Paolo Tosco
312fa9a703 Optionally expose MCS to JS and extend optional compilation to JSReaction and JSSubstructLibrary (#6409)
* reverted all changes that did not really belong to this PR

* I had forgotten ChemReactions_static

* changes in response to review

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-06-07 12:35:55 +02:00
David Cosgrove
94cde75973 Make FMCS check bond stereo. (#5009)
* Make FMCS check bond stereo.

* Increase timeouts.

* Remove spare test.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-02-22 06:50:17 +01:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04:00
Braxton
2235a790c0 3D MCS - Minimal version, no refactoring (#3749)
* 3D MCS

* Move test data to dedicated directory

* 3D MCS: changes based on code review

* Replace conformer generation code in MCS 3D test with mol blocks
2021-01-26 04:50:05 +01:00
Paolo Tosco
7fc8feee9e Addresses #3693 (#3695)
* addresses #3693

* change in response to review

* applied clang -format

* changes in response to discussion
2021-01-07 18:25:08 +01:00
Eisuke Kawashima
75f03412ef Modernize deprecated header inclusion (#3137) 2020-05-04 10:40:57 +02:00
Paolo Tosco
a6cafc4635 Added support for Python FMCS functors (#3023)
* Added support for Python FMCS functors

* - changes in response to review
2020-03-23 11:20:57 +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
ec366c1ab7 Dev/pvs studio cleanups2 (#2877)
* a round of cleanups courtesy of PVS studio

* add a test to make sure that a warning is a false alarm

* bug fix

* Fix a UFF bug

* more PVS studio cleanups

* next round of PVS studio cleanups

* completely remove the chances for that bug

* changes in response to review

* add an additional test
+ a bit of reformatting that snuck in
2020-01-22 15:10:58 +01:00
Paolo Tosco
864fdab349 - MatchFusedRings does not imply CompleteRingsOnly anymore (#2748) 2019-11-29 13:35:39 +01:00
Paolo Tosco
ab021aa960 Add consideration of ring fusion to the MCS algorithm (#2731)
* - Adds consideration of ring fusion to the MCS algorithm

* - removed some commented out lines
2019-10-25 04:35:10 +02:00
Steve Roughley
710bdfa60b Added AtomComparator.AtomCompareAnyHeavyAtom and test cases to FMCS code (#2656)
* Added AtomComparator.AtomCompareAnyHeavyAtom and test cases to FMCS code

* Added AtomComparator.AtomCompareAnyHeavyAtom

* Added AtomComparator.AtomCompareAnyHeavyAtom - fixed test typo

* Added AtomComparator.AtomCompareAnyHeavyAtom and test cases to FMCS code (2)

* Added AtomComparator.AtomCompareAnyHeavyAtom - fixed test cases

* Added AtomComparator.AtomCompareAnyHeavyAtom and test cases

* Update Code/GraphMol/FMCS/FMCS.cpp

Co-Authored-By: Greg Landrum <greg.landrum@gmail.com>

* Reverted tabs to 4 spaces

* Update FMCS.cpp
2019-10-03 17:19:22 +02:00
Greg Landrum
4db0bade46 Fixes $945
Fixes #2420

Tests updated to reflect changes.

The existing CompleteRingsOnly code wasn't actually guaranteeing CompleteRingsOnly at all, it was just causing #2420.
The updated code actually makes sure that bonds that were ring bonds in one of the queries are ring bonds in the final MCS.
This is done via a relatively simple DFS.
2019-04-24 14:30:38 +02:00
Greg Landrum
50d2328251 Fixes #2034 (#2035)
* Fixes #2034

* update release notes to describe that
2018-09-17 06:50:54 +02:00
Dan W
3c3106bd7b Allow types.h to be included in applications that use /D_USE_MATH_DEFINES (#1846)
* spelling

* Allow types.h to be included in applications that set _USE_MATH_DEFINES

Our application defines _USE_MATH_DEFINES on the visual studio
compiler command line, so every compilation includes the macro
definition. Including types.h (or anything other RDKit header,
basically) causes compilation to fail with a "doubly defined
macro" error message.

This commit defines the macro locally and only if it is not already
defined
2018-05-05 04:47:24 +02: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
4001b2ba0e Add the option to match formal charges to FMCS (#1311)
* very basics of charge checking in

* add the new parameters to the python wrapper. more testing please

* Additional testing.

* update which unittest methods are used
2017-02-28 08:49:28 -05: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
Alexander Savelyev
66c52aa701 fmcs: fix fmcs for chiral sub queries #688 2015-12-17 17:17:40 +03: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
Brian Kelley
daa7e62258 Fixes signed conversion issues (use rdcast) 2015-10-18 15:16:38 -04:00
Brian Kelley
5f59333a56 Silences unused parameters 2015-10-18 14:02:29 -04:00
Brian Kelley
403a3d6b7c Suppresses Boost warnings 2015-10-18 13:41:03 -04:00
Brian Kelley
a146c3826a Remove unused variables/functions and register keyword 2015-10-18 10:01:00 -04:00
Alexander Savelyev
11105660c8 fmcs: fixes #631 with chiralirty 2015-10-07 14:40:31 +03:00
Alexander Savelyev
e331a57791 fmcs: implement adding an initial seed structure 2015-08-25 14:21:04 +03:00
Alexander Savelyev
5fc0e5fd1d fmcs: add default parameters for AtomCompare and BondCompare 2015-04-17 18:27:54 +03:00
Alexander Savelyev
b0177a4ea1 restore java and python wrappers. New parameter (matchChiralTag) was added. New function findFMCS_P() receives json parameters 2015-04-10 16:24:58 +03:00
Alexander Savelyev
ec6ecdd3bc request notes were fixed. chirality algorithm was slighlty improved 2015-04-06 19:53:19 +03:00
Alexander Savelyev
dc208b0829 chirality flag was implemented for fmcs() function 2015-03-30 18:17:57 +03:00
Greg Landrum
403c83a73e Add initial (not yet complete) support for parsing JSON to MCS parameters.
Make it explicit that the MCSParameters argument to findMCS is optional
2015-02-17 04:13:49 +01:00
Greg Landrum
7cb35fd5a4 Fixes #397 2014-12-09 06:39:33 +01:00
Alexander Savelyev
cece0acaba fmcs: use the zero bond type instead of other 2014-10-30 17:07:28 +03:00
Greg Landrum
4c1c5498f9 remove some compiler warnings; possible minor optimization 2014-08-09 07:12:24 +02:00
Greg Landrum
7a2687e0c1 reformat code 2014-07-22 03:34:19 +02:00
Greg Landrum
c9b91cd744 code formatting changes (indentation and untabify) 2014-07-01 05:48:51 +02:00
Alexander Savelyev
21b2ea4a68 improve prune() heuristic. the search speed was increased. mem leaks fixed 2014-06-26 19:05:55 +04:00
Alexander Savelyev
98e052bc8c bug with isotopes was fixed 2014-06-11 17:38:20 +04:00
Savelyev Alexander
604ee4c675 bug with empty MCS was fixed. MT stub 2014-05-12 21:39:55 +04:00
Alexander Savelyev
ddba1b3650 fast match was implemented for FMCS. cosmetic changes 2014-04-29 15:34:21 +04:00
Greg Landrum
9d734e7b74 next round of updates from Alex 2014-04-14 12:32:18 +02:00
Greg Landrum
f8aff03024 get FMCS building on the mac 2014-04-07 09:57:12 +02:00
Greg Landrum
24a9689f45 dos2unix run 2014-04-07 09:27:07 +02:00
Greg Landrum
a5f5247d32 add initial implementation for testing 2014-04-03 05:07:47 +02:00