Commit Graph

84 Commits

Author SHA1 Message Date
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Hussein Faara
44364fd982 remove no-op macros and dead code (pt 4) (#8037)
* remove no-op macros and dead code (pt 4)

* review comments
2025-01-26 07:49:50 +01:00
David Cosgrove
293328845b Add overloads of MolOps::getMolFrags and MolOps::getMolFragsWithQuery (#7823)
* Add overloads of getMolFrags and getMolFragsWithQuery that fill in using std::unique_ptr rather than boost::shared_ptr.

* Response to review - do things in unique_ptrs from the outset rather than raw pointers.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-09-20 09:48:08 +02:00
Yakov Pechersky
c25abde7cf Include macrocycles in atropisomer calculation by not sanitizing them away (#7291)
* Include macrocycles in atropisomer calculation

Previously, atropisomeric bonds were sanitized away if they were part of a "ring bond", which happens in macrocyclic systems.
None of the existing test cases fail if that sanitization check is removed.
The sanitization step is removed to support biaryls that are part of a larger macrocyclic system.
A set of test cases is included that cover potential macrocyclic atropisomeric systems

* Remove unmentioned files

* Keep ring check, and narrow it to when bond is in as many rings as atoms

* exclude atropisomer bonds if in rings < 8 atoms

Co-authored-by: tadhurst-cdd <112502803+tadhurst-cdd@users.noreply.github.com>

* Clarify macrocycle behavior in RDKit book

* fix typo

---------

Co-authored-by: tadhurst-cdd <112502803+tadhurst-cdd@users.noreply.github.com>
2024-04-09 06:05:25 +02:00
Greg Landrum
e7084bb400 Do not wedge bonds to attachment points (#7212)
* make sure added attachment points have valences set

* do not wedge bonds to attachment points if at all possible
2024-03-05 21:13:26 +01:00
Greg Landrum
01ec60a856 Fixes #7078 (#7155)
* add MolOps::expandAttachmentPoints, along with tests

* support expandAttachmentPoints in the mol file parser

* switch the v2 stuff in the guts of the reaction parser

* add collapseAttachmentPoints()
add addAsQueries option to expandAttachmentPoints()

lots of testing

* an edge case and some cleanup

* add python wrapper for those two functions

* Update Code/GraphMol/FileParsers/FileParsers.h

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

* changes in response to review

- support addCoords in expandAttachmentPoints()
- support the new attachment point stuff to/from CXSMILES
- add MolOps::details::addExplicitAttachmentPoint() and MolOps::details::isAttachmentPoint() utility functions

---------

Co-authored-by: Ric <ricrogz@users.noreply.github.com>
2024-02-28 17:05:53 +01:00
Greg Landrum
21b9ba1685 Fix a pathological slow case with the new getMolFrags() (#7121)
* backup

* revert changes to hanoitest.cpp

* don't just handle single-atom fragments

* polishing

* remove boost::timer

I used it to track down the problem
2024-02-06 04:23:48 +01:00
Greg Landrum
d1b9331a36 Fixes #7122 (#7126) 2024-02-03 06:47:28 +01:00
tadhurst-cdd
eb2606d617 fragmentation of mol loses any sgroups (#7056)
* fragmentatin of mol loses any sgroups

* removed unneeded test

* Fixes #7071

* simplification. tests do not pass

* Changed test for sgroup retention as per PR review

* Fix testing errors

* attempt to get CI windows to build

* removed files incorrectly committed, and removed code no longer needed

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-01-25 13:32:55 +01:00
MarioAndWario
9ca7a2e00d Sanitize number of radical electrons in case of invalid value assigned by CXSMILES (#6842)
* Sanitize number of radical electrons in case of invalid value assigned by CXSMILES (#6370)

* static_cast<int> for integer comparison

* Add unittests for 0 explicit hydrogens

* Fix unittests of radical count in fileParsersTest1

* Fix testMolWriter

* Fix testMrvToMol

* Address Greg's comments
2024-01-23 06:21:26 +01:00
tadhurst-cdd
d5d4d194ec atropisomer handling added (#6903)
* 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

* 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

* fix for CI build

* attempt to fix java build in CI

* attempt to fix java build in CI #2

* New routine to remove non-explicit  3D-geneated chirality

* changed to use pair for atrop atoms and related bonds

* Changes as per PR reviews

* PR review respnses

* PR review reponse - more

* Fix merge from master

* fixing java ci after merge

* Updated the help doc for atripisomers

* update the atropisomer docs

* improve the images

* add the source CXSMILES

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-12-22 04:58:18 +01:00
tadhurst-cdd
d7c01af9c8 Fixes for canonicalization, and stereochemistry (#6743)
* Fixes for canonicalization, and stereochemistry

* chnages from code review

* test that was omitted for canon correction

* PR review changes

* changes as per PR review

* missed file checkint to make PR tests compile

* PR conflict resolution

* change to fix PR buld errors (hopefully)

* line delete to force re-running of tests

* changes as per PR review

* resolve merge conflicts with master

* some suggestions

* revert chirality modifications when sanitization isn't being done

* addl changes: no stereo percept when no sanitize

* missing test expected files added

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-11-06 07:40:23 +01:00
Greg Landrum
91d32dda50 fix order of cleanupOrganometallics() in sanitizeMol() (#6690)
* fix order of cleanupOrganometallics in sanitizeMol

* make sure cleanupOrganometallics() works on non-sanitized molecules
2023-09-07 12:58:03 +02:00
Ric
8176f5c962 Fail CI builds on compiler warnings + some fixes (#6675)
* enable Werror on Mac and Linux

* do not fail on boost multiprecision pessimizing move

* fix eigen array_bounds warning

* Fix unused arg in Rascal MCS

* fix range-loop-construct warning in Rascal MCES

* fix sign mismatched comparison

* drop unused lambda capture

* allow FMCS timeout test more time under Debug (not a warning!)

* fix fwd declaration of struct RascalClusterOptions

* fix deallocator mismatch

* fix two minor leaks

* fix a real leak

* more minor leaks

* fix another real leak, plus some potential ones

* fix std::move preventing copy ellision

* allow longer run time for debug builds

* make maxBondMatchPairs and getLargestFragSize unsigned int

* make snake case camel case

* update to current master, fix new warnings

* update again and more fixes

* add #include <optional>

* fix char array deallocation

* update and fixes in Marvin writer

* unsigned int

* more copy ellision fixes

* more copy ellision fixes, and typos

* and some more
2023-09-02 04:38:45 +02:00
Ric
d033aee043 Optionally forward Enhanced Stereo Group ids (#6560)
* add id members to StereoGroup class

* add optional read id argument to StereoGroup constructors

* add functions forward Stereo Group Ids and assign the missing ones

* update ops updating stereogroups to forward read id

* update CX Smiles to parse/write stereogroup ids

* Add test cases for stereo group id forwarding/canonicalization

* update mol block (V3K only) to parse/write stereogroup ids

* update pickling to parse/write stereogroup ids

* update cdxml parser to store stereogroup ids

* update mol interchange to parse/write stereogroup ids

* update draw code with new stere group ids

* update test

* add some tests

* Update Code/GraphMol/Wrap/rdmolfiles.cpp

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

* Update Code/GraphMol/Wrap/rdmolfiles.cpp

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

* Update Code/GraphMol/Canon.cpp

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

* Update Code/GraphMol/SmilesParse/CXSmilesOps.cpp

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

* review

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-07-27 18:53:40 +02:00
David Cosgrove
2d881e0abb Fix cleanupOrganometallics and reinstate to sanitisation (#6357)
* Fix canonically correct single to dative bond conversion for organometallics.

* Cleanups from review.

* Process atoms in canonical order.
Extra test.

* Only do the expensive bit if there's something to fix.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-05-23 09:49:40 +02:00
Greg Landrum
7c93c02205 remove cleanupOrganometallics() from the default sanitization (#6292)
* remove cleanupOrganometallics() from the default sanitization

* doc update
2023-04-14 08:49:26 +02:00
David Cosgrove
a4ea4f2ee5 Fix _MolFileBondEndPts after dativeBondsToHaptic. (#6254)
* Fix end points.

* Set common_properties::_MolFileBondAttach as well.

* Response to review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-03-31 04:50:38 +02:00
Ric
bc8d2e7556 Fix build warnings (#6235)
* un/signed comparisons in molops

* reference in loop in EmbeddedFrag.cpp

* un/signed comparison in filtercatalogtest.cpp

* un/signed comparison in Descriptors/catch_tests.cpp

* un/signed comparisons in DetermineBonds.cpp

* drop unused 'params' arg from static functions in MolInterchange/Writer.cpp

* un/signed comparisons in MolDraw2D/catch_tests.cpp

* unused var in SubgraphUtils.cpp

* 'move' preventing copy ellision in CDXMLParser.cpp

* fix infinite recursive call in SubstructLibraryWrap.cpp
2023-03-30 19:21:51 +02:00
David Cosgrove
5fe20d270f Improved handling of organometallics (#6139)
* First stab at disconnecting organometallics the Syngenta way.

* Add support for Li and Na compounds, with tests.

* Correct docstrings.

* Add -1 valence to sodium.

* Add changes from PR 5997.

* Move declaration of disconnectOrganometallics.

* Re-factor tests for disconnectOrganometallics to read V3000 files rather than hard-code in file.

* Add optional options to constructor.

* Python wrapping for disconnectOrganometallics.

* Python tests.

* Correct docString.

* Test using in place overload of disconnect free function.

* options_ should not be a reference.

* Re-work the wrappers.

* Added test MOL files.

* Correct charge on iron atoms.

* Fix tests for charged iron.

* Added some more test complexes.

* Port Marco's oxidation number Python to C++ Descriptor.

* Rename functions.

* Another test.

* Python wrappers.

* Comment in test.

* Throws exception if atom-based function called with non-kekulized parent.

* Fix typo.

* Allow potassium as well.

* Whole molecule calculations for oxidation number only.
Rename prop to OxidationNumber.

* Add OxidationNumber to common_properties.

* Extra comment.

* When deleting atom, update any ENDPTS props on bonds.
Copied in from stale PR ExtraDoc.

* Added hapticBondsToDative with python wrapper.

* Extra test.

* Re-factor endpts parsing.

* Typo.

* Add function for haptic end points inc. Python wrapper.

* Add dative bonds in separate step.

* C++ version of dativeBondstoHaptic.

* Update test mols.

* Python wrapper.

* Fix indents in Python test script.

* Corrected expected test result.

* Only do non-metal to metal conversion of single bond to dative if the explicit valence of the non-metal allows it.

* Fix test broken in a non-material way by previous change.

* Export for DLL.

* Remove redundant function declaration.

* Dave hates Windows.

* Move hapticBondEndpoints to Molops::details.

* And take it out of the Python wrappers.

* Run yapf on reformatted test script.

* Get the DLL builds going.

* addDativeBond -> addHapticBond.

* Batch edits.

* Position arithmetic.

* setQuery.

* Dummy positions for all confs.

* Fix tests for dummy positions for all confs.

* Move tests to catch_organometallics.cpp.

* Modern docString.

* Change member variable names.

* sProp length, bonus batchEdit.

* Add options object to disconnectOrganometallics.

* Tidied license.
Atom precondition.

* GetIntProp.

* Test opts aren't defaults.

* Python wrapper for disconnectOrganometallics with options.

* Minor edit.

* Slightly random attempt to fix Java build.

* Response to review.

* Another stab at the doc strings.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-03-18 04:36:38 +01:00
Greg Landrum
7153918af4 Fixes #4642 (#6115)
* Fixes #4642

We should consider whether or not it's right to remove stereo from atoms which were in stereo groups but are not any longer.

* split stereogroups across fragments

* cleanup

* Changes in response to review
2023-03-02 19:01:45 +01:00
Greg Landrum
72286f5ddd Fixes #6100 (#6105)
* fixes #6100

* cleanup commented line
2023-02-18 21:17:45 +01:00
David Cosgrove
42782d31cf Change IUPAC metal->non-metal single bonds to dative (#6038)
* Change atom to metal bonds from single to dative if appropriate.

* Pedantic change whilst I was in the area.

* Reinstate all tests, leave in debugging writes to see failing tests.

* Re-did it.  Failing tests now pass.

* Move any positive charge from the non-metal to the metal.
Fix expected test results.

* Write dative bond to JSON.

* Bump currentRDKitJSONVersion to 11, but allow parser to still read 10.

* Only move 1 unit of charge at a time from non-metal to metal.

* Greg's hack to not do it for O+ and N+ etc.
Explicitly exclude H, He, F, Ne from dative bonds.
Fix tests.

* Update expected PostGres json version to 11.

* suggestions for PR

* Correct comment.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-02-06 04:37:32 +01:00
Greg Landrum
fd44d72fb7 Fixes #5849 (#5861)
* Fixes #5849
This may not be the best fix since it adds another step to canonicalization

* more test cases

* update docs
2022-12-28 20:10:13 +00:00
Greg Landrum
edb542097b Fixes #5462 (#5463) 2022-08-03 04:46:17 +02:00
Greg Landrum
85608555fe add ROMol::atomNeighbors() and ROMol::atomBonds() (#4573)
* add ROMol::atomBonds() and ROMol::atomNeighbors() methods

* remove some warnings

* start using the new code

* add default for those template params

* some more applications

* get the SWIG builds working

* get rid of extraneous ref

* remove extraneous comments
2021-10-02 07:28:24 +02:00
Greg Landrum
6fbe4f788d Fixes #3330 (#3869) 2021-03-05 19:59:37 -05:00
Greg Landrum
3b79156697 Fixes #3805 (#3838) 2021-02-23 14:25:39 +01: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
Rocco Moretti
3cc2123637 Fix undefined behavior in testCoordGen test (#3495)
* Fix ROMol->RWMol static casts

* Fix accessing of end-iterator.

* Fix some test build issues I saw while compiling with Clang.

* Add build settings for sanitizers.

* Revert "Add build settings for sanitizers."

This reverts commit 5dc84374f0.
2020-10-17 04:26:13 +02: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
Eisuke Kawashima
5cd27a242f Fix typo (#2862)
* Fix typo

* Reflect the comments

* Fix more typos
2019-12-31 06:43:27 +01:00
Greg Landrum
253f172353 Allow identification of chemistry problems (#2587)
* add AtomValenceException

* refactor a bit and add KekulizeException

* add copy ctor and copy() method

* add detectChemistryProblems

* add getType() method
want to be able to get the type of the exception without requiring doing a bunch of dynamic casts

* first pass at exception inheritance/translation
needs some cleanup and expansion, but this does pass all tests.

* cleanup and finish the python wrappers for the new exceptions

* make sure things are truly polymorphic

* wrap shared_ptrs of the new exception types

* expose DetectChemistryProblems()

* get the java wrappers building again

* transfer those changes to the c# wrapper

* add detectChemistryProblems()
and deal with the fun fun exception inheritance things that ensue

* response to review
2019-08-28 14:15:55 -07: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
Alain Vaucher
ee12b4c0bd correct mistake in halogen cleanup and add test cases, fix for #2020 (#2021)
* correct mistake in halogen cleanup and add test cases

* Add same example for the test as in #2020
2018-09-05 16:13:50 +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
e8c46ca2a9 Fix/github1810 (#1811)
* Fixes #1810
There's still a problem with stereo atoms (see the commented out test),
but this takes care of the basics and that's up next.

* clean up that last problematic bit.
Still needs all tests to run

* this seems to be a necessary workaround for problems with VS2017.
It's a bit ugly, but shouldn't have any performance impact, so I'm not
going to get too worked up.

* This set of changes alters what we get for some of the InChI test cases.
Adjust for that.
2018-04-11 04:48:16 +02: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
a58f9bef8e Add an MDL aromaticity model (Fixes #1622) (#1693)
* backup

* Add a couple of more tests and an exclusion for triple bonds.

* expose the MDL aromaticity model to python and test it.

* exocyclic bonds should not “steal” electrons in the MDL model

* backup (partial) update for aromaticity model documentation

* add examples to testGithub1622 for aromatic and nonaromatic compounds

* updates to aromaticity model and docs based on additional information from @bannanc

* some additional examples from @bannanc

* add rule to allow exocyclic multiple bonds to disqualify an atom.

* minor doc update

* address some review comments
2017-12-21 08:39:49 -05:00
Greg Landrum
f94e277856 another pass of clang modernize 2017-10-12 06:35:51 +02:00
Greg Landrum
8d31f56c29 Merge branch 'master' into modern_cxx 2017-10-07 06:46:28 +02:00
Greg Landrum
d29844a614 Fixes #1605 (#1606) 2017-10-06 11:07:10 -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
f762346ced make the perchlorate cleanup pattern more generic to cover all halogenates;
Fixes #115
2016-04-01 07:54:32 +02:00
Greg Landrum
cf7ceab383 remove wave of warnings 2016-03-30 13:09:59 +02:00
Greg Landrum
d7d95dd684 an alternate approach to fixing #805 2016-03-13 04:21:36 -07:00
kelley
5dbec2fe85 Adds rdcasts where appropriate 2015-11-29 17:52:27 -05:00
Greg Landrum
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Brian Kelley
403a3d6b7c Suppresses Boost warnings 2015-10-18 13:41:03 -04:00