Commit Graph

5411 Commits

Author SHA1 Message Date
Hussein Faara
701395b9da remove no-op macros and dead code (pt 2) (#8035)
* remove no-op macros and dead code (pt 2)

* test failures due to whitespace changes?

* actually run the testFeatures tests

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2025-01-30 05:51:09 +01:00
Richard Gowers
2090717371 fix SetPositions when using strided numpy array (#8150)
* fix SetPositions when using strided numpy array

previously SetPositions assumed that the provided numpy array used contiguous-C stride patterns

* cast to a const pointer to avoid compiler warning
2025-01-30 05:50:54 +01:00
Eisuke Kawashima
977cc9ac11 fix: apply modernize-use-nullptr (#8134)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2025-01-30 05:50:36 +01:00
Ricardo Rodriguez
7eb5b422f9 Fix leaks in MIF wrappers (#8143)
* fix leaks in wrappers

* decref on not-sequence obj or bad seq size

* PySequence in DistGeom wrappers
2025-01-30 05:50:20 +01:00
Ricardo Rodriguez
2a5dd00288 fix (#8144) 2025-01-30 05:49:58 +01:00
tadhurst-cdd
b475bc62a5 relax two tolerances for ARM64 builds (#8148) 2025-01-30 05:49:08 +01:00
tadhurst-cdd
bcef6669fa Fix for removing bad stereo indications from Atropisomer parsing (#7984)
* Fix for removing bad stereo indications

* removed one unneed change

* removed mistaken change
2025-01-30 05:46:52 +01:00
Jeremy Monat
5f3f80a681 GetAtomsMatchingQuery: Tell where to find query options for (#8132)
* For GetAtomsMatchingQuery, note that "Atom query options are given in the rdkit.Chem.rdqueries module"

* wording change

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-01-30 05:46:34 +01:00
tadhurst-cdd
bbb9c2d04e Bad radical values are now ignored for MRV generation (#8130)
* Bad radical values are now ignored for MRV generation

* Update Code/GraphMol/MarvinParse/MarvinWriter.cpp

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-01-30 05:46:19 +01:00
David Cosgrove
9a1125c91f SynthonSpace search timeout (#8070)
* Add timeout to searches.

* Correct docstring.

* Include chrono header.

* Get it compiling with gcc.

* And then clang didn't like it...

* Revert to tmpnam as msktemp isn't available on Windows.

* Response to review.
Run time no longer saved in SearchResults.
Timeout check not tied to size of results.
Made the test timeout shorter.

* Fix the Python wrapper.

* Shamelessly steal the better timeout method from PR8110.

* suggested changes

* be more conservative about what does not time out

the CI machines can be surprisingly slow

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-01-30 05:45:57 +01:00
David Cosgrove
9fcaf3b271 Handle DOS files in SynthonSpaceSearch (#8075)
* Handle DOS files.

* Smaller test file.
Add DOS file to .gitattributes.

* Update Code/GraphMol/SynthonSpaceSearch/substructure_search_catch_tests.cpp

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-12-20 08:51:14 +01:00
Paolo Tosco
11ee676efd - str_to_c() should initialize len to 0 even if memory allocation fails (#8112)
- str_to_c() should check the ptr returned by malloc for non-nullness before using it
- change has_coords() mol_pkl parameter to const
- use assert.equal in JS tests where possible

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-20 08:44:56 +01:00
Greg Landrum
0dfc28f656 allow specified chiral features to SSS match unspecified features (#8115) 2024-12-20 08:44:42 +01:00
greg landrum
7ba2b3773c fix a cherry-pick inconsistency 2024-12-19 10:13:18 +01:00
Paolo Tosco
f4d4a9fe19 normalizeDepiction() should always center coordinates on the coordinate centroid, irrespective of the canonicalize parameter (#8107)
* normalizeDepiction() should always center coordinates on the coordinate centroid, irrespective of the canonicalize parameter

* Update Code/GraphMol/Depictor/catch_tests.cpp

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

* fix catch test

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-12-19 10:00:40 +01:00
David Cosgrove
ba35526646 Use endian-aware read/write for length of string. (#8105)
* Use endian-aware read/write for length of string.

* Re-run clang-format.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 10:00:24 +01:00
David Cosgrove
ff1d6f8f8b SynthonSearch synth check (#8109)
* Catch errors when creating products.

* Extra python test.

* Fix formatting.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 10:00:07 +01:00
David Cosgrove
50ff4ff4c0 Handle DOS files in SynthonSpaceSearch (#8075)
* Handle DOS files.

* Smaller test file.
Add DOS file to .gitattributes.

* Update Code/GraphMol/SynthonSpaceSearch/substructure_search_catch_tests.cpp

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-12-19 10:00:01 +01:00
Nikitas Rontsis
6a764dc32a Avoid unnecessary matching (#8111) 2024-12-19 09:56:57 +01:00
David Cosgrove
26fa79b89a Fix empty results bug. (#8099)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 09:55:19 +01:00
Greg Landrum
644296fe13 Add Molecular Interaction Fields (#7993)
* Add RealValueVect.

* Add UniformRealValueGrid3D

* Add Molecular Interaction Fields (MIFs)

* line endings

* cherry-pick f1bc94a4c8

* format

* Adapt tests for python3.

* Adapt RealValueVector pickling for python3.

* Speed-up of MIF calculations.

* Bugfix in MIFDescriptors.cpp.

* all tests pass

* clean up some memory leaks

* update copyrights

* rename

* rename the library

* complete the rename

* lost file

* another forgotten file

* cleanup

* clang-tidy

* clang-tidy

* windows DLL builds work

* python wrapper and tests cleanup

* convert to catch2 testing

* switch RealValueVect to use std::vector

* remove obsolete friend

* - Replace explicit loops with stdlib implicit equivalents
- Replace explicit types with auto where possible
- Avoid unnecessary copy operations where possible
- Replace raw pointers with exception-safe unique_ptr
- Replace C-style #define with constexpr
- Replace C-style casts with C++ casts
- Replace C-style arrays with std::vector
- Avoid code duplication with templated operators
- Replace VdWaals class taking multiple atom type definitions and force-field name as string parameter with force-field-specific classes deriving from an abstract VdWaals class
- Replace x,y,z doubles with Point3D class where possible
- Removed unused (and untested) DistanceToClosestAtom class
- Renamed some variables and functions for better clarity
- Converted tabs to spaces
- Made the mol parameter in cube read/write functions optional for convenience
- Made the Python wrappers more pythonic (e.g., avoid C++-style passing objects as parameters which are modified in place)
- Implemented alternative Python class constructors using boost::python::make_constructor rather than with external non-class functions
- The Python wrappers taking a sequence of Point3D now take a sequence of sequences, such that the output of Conformer.GetPositions() can be passed
- Made the Python wrapper sequence parsing more robust
- Removed duplicated code from Python wrappers

* - avoid an unnecessary copy

* progress

* works

* more cleanup

* all tests pass

* changes in response to review

---------

Co-authored-by: dfhahn <dfhahn@users.noreply.github.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 09:54:52 +01:00
David Cosgrove
86b5335770 Allow fragments of aromatic rings to match in RascalMCES (#8088)
* Allow fragments of aromatic rings to match.

* Use existing code for checking bond is in ring.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 09:54:23 +01:00
Paolo Tosco
802f9d2991 Fix #8027 (#8031)
* - Fix #8029
- avoid unnecessary rounding errors in the JSON writer
- remove a warning when compiling MinimalLib without SubstructLIbrary support

* changes in response to review

* changes in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 09:53:20 +01:00
greg landrum
b0f48e8c9e Revert "Fix #8027 (#8031)"
This reverts commit 7b2c9dfa58.
2024-12-19 09:36:58 +01:00
David Cosgrove
4773d1ba61 Synthon search fp bug (#8086)
* Fix bug - connector patterns weren't being matched to the synthon connector patterns.

* Tiny tweak.

* Typo in comment.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 08:57:46 +01:00
Greg Landrum
160991375c fixes #8060 (#8087)
* fixes #8060

* check the new stereo code too
2024-12-19 08:57:28 +01:00
Paolo Tosco
429008e561 Make sure that loggers can be enabled, disabled, captured and tee'd from MinimalLib (#7962)
* make sure that loggers can be enabled, disabled, captured and tee'd from MinimalLib without issues

* changes in response to review

* change in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 08:56:13 +01:00
Paolo Tosco
7851770f99 avoid that map::at() throws an exception in case atomColourPalette includes neither 6 nor -1 (#8085)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 08:55:01 +01:00
Ricardo Rodriguez
3095fccb53 Fixes #8065 (#8066)
* add test + fix

* simplification

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-12-19 08:54:49 +01:00
David Cosgrove
1b79e6014c Resolve clashing atom labels in 2D drawing (#8074)
* Move atom labels round if they clash.

* Tidy.

* Re-work orientation logic.
Remove virtual fns from AtomSymbol.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-19 08:54:33 +01:00
Brian Kelley
79fa3a1fc8 Fix #4570 Segfault on Property Getters/Setters (#8042)
* Fix #4570 Segfault on Property Getters/Setters

* Revert regression, response to review

* Remove print statement
2024-12-19 08:53:39 +01:00
Paolo Tosco
7b2c9dfa58 Fix #8027 (#8031)
* - Fix #8029
- avoid unnecessary rounding errors in the JSON writer
- remove a warning when compiling MinimalLib without SubstructLIbrary support

* changes in response to review

* changes in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 08:52:04 +01:00
David Cosgrove
b76122b510 Synthon fingerprint search (#8025)
* First pass at splitting molecule.

* Interim commit.  Reading libraries from file in original format.

* Basic search seems to be working.

* Pattern fingerprint screening.

* Connector region heuristic.

* Fixed triazole (aromatic/non-aromatic connectors).

* Fix search with non-split parent query, where query is substructure of a single reagent.

* Remove duplicate hits by reaction/reagents used.

* Implement largest fragment heuristic.

* Extra test files.

* Read/write binary file.
Program for conversion from text format to binary format.

* Remove empty reagent sets on reading, probably due to synthon number counting from 1 rather than 0.

* Tidy SSSearch functions.

* Stash pending major surgery for triazole bug.

* Revert to using unique_ptr.
Correct use of reagent order.

* Function to summarise Hyperspace.

* Delay building hits till end and put cutoff on number.

* Earlier bale-out in getHitReagents.

* Streamline checkConnectorRegions.

* Remove free functions for search.

* Correct name of Python test.

* First stage of Python wrappers.

* Rename namespace.

* Parameters object.

* Mysterious windows export thing.

* Fix bug - not matching number of connectors in fragment and synthon.

* Back like it was.  The connector count wasn't the problem.

* Put the substructure results into their own class.

* gcc 14 didn't like my use of std::reduce.
Update expected test results.

* Remove write statement.

* Tidy.

* Tidy.

* Enable random sample of hits.

* Test that complex SMARTS works.
Update Python wrappers.

* Rename Hyperspace to SynthonSpace.

* More renaming.
Python test.

* Enable Python test.
Remove write.

* Plug memory leak.

* Response to Greg's initial look.

* More response to Greg's initial look.

* get the windows DLL builds working

* Do away with mutable.
Purge a few more uses of reagent in favour of synthon.
Remove the c++ exe for converting text to binary databases.

* Better Synthon c'tor.

* More feedback from Greg.

* Tidy the Python wrapper.

* Remove tags from catch tests.

* Don't allow copying of SubstructureResults.

* Revert to allow copying of SubstructureResults.  The Python wrapper needs it.

* Refinements based on CLion/clangd suggestions.

* Allow for map numbers in connectors in space file.

* Refactor to make the searcher a separate class from the space.

* Transfer Greg's review suggestions from Hyperspace merge.

* First cut of fingerprint searcher.

* Python wrapper.
Some tidying.

* Better random selection.

* Fix bug in preparing frags for fingerprints.
Re-factor.

* Minor-refactor.

* Sort hits by similarity if available.

* Option for a few different fingerprint types.  Pending a better solution.

* Write fingerprints to binary file.

* Use any fingerprint generator for similarity searching.  No Python wrapper yet.

* Python wrapper.

* Change random selection to use distribution weighted by number of hits in each reaction.

* Lots of suggestions from CLion/clang.

* Use boost discrete_distribution for cross-platform consistency.

* Tidy test up.

* Try boost rng as well.

* uniform_int_distribution to boost also.

* Small tidy.

* Method to write enumerated library.

* Windows export thing.

* Windows export thing.

* Allow for commas in tab-separated fields.

* win64 dll builds now work

* More aliphatic synthon, aromatic product joy.

* Force ring finding if it hasn't been done.

* Fingerprint hits not being sorted if maxHits reached.

* Remove debugging write.  Doh!

* Response to review of SynthonSpace2.

* Missed one.

* Add test file.

* Hand merge Greg's #8050.

* Discard nodiscard.

* Move include of export.h inside include guards.

* Response to review.

* Fix memory leaks.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-11-29 13:20:15 +01:00
Greg Landrum
1e9ec2f381 Fixed #7986 (#7987)
* Fixed #7986

* get builds working on linux

* try again

* oops, use std::uint32_t
2024-11-29 10:43:56 +01:00
greg landrum
1d2fb5c5b5 Revert "Expose propertyFlags to CFFI and MinimalLib (#7960)"
This reverts commit 6f33d827aa.
2024-11-28 08:49:49 +01:00
greg landrum
b669cf2c4b Revert "implemented JSON parsers for SanitizeFlags and RemoveHsParameters for CFFI and MinimalLib (#8000)"
This reverts commit 5d1ab5d6b7.
2024-11-28 08:48:54 +01:00
greg landrum
603de6caab Revert "Expose molzip functionality to MinimalLib (#7959)"
This reverts commit 1086ba089b.
2024-11-28 08:46:41 +01:00
Dan Nealschneider
44da77fb31 Remove explicit default constructor from Compute2DCoordParameters (#8046)
The explicit default constructor actually blocks the other
defaults. It also means this is no longer a "plain struct",
and so designated initializers aren't available.

I wanna be able to do:

    Compute2DCoordParameters params{.useRingTemplates = true};

Or even:

    RDDepict::compute2DCoords(*mol, {.useRingTemplates = true};
2024-11-28 08:30:39 +01:00
Eric Boittier
a6baf10807 [fix] issue #7572, precondition rootAtAtom if more than one fragment exists (#7811)
* [fix] re: issue #7572; added precondition check to prevent setting a root atom when more than one fragment exists

* tests for #7572, precondition rootAtAtom if more than one fragment exists

* test the fix to issue #7572

* [fix] moved the precondition to a block which get atom at index to prevent unhandled exceptions, MHFP tests pass now

---------

Co-authored-by: Eric Boittier <ericdavid.boittier@unibas.ch>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-11-28 07:31:39 +01:00
Brian Kelley
5af73489ed MergeQueryHs better detects hydrogens in OR queries (#8043)
* Fixes #7687

* Make sure high and low precedence ands also work

* really fix the issue

* Fix merge conflict

* Add AtomType to MergeH check with test
2024-11-28 07:30:55 +01:00
Hussein Faara
17c75bf219 remove no-op macros and dead code (pt 1) (#8012) 2024-11-28 07:30:39 +01:00
Ricardo Rodriguez
e9e13f6523 Fix shifting of a potentially negative number (#8014)
* fix shifting a potentially negative number

* add a test

* fix signed comparison
2024-11-28 07:30:26 +01:00
Greg Landrum
5c7e881182 Fixes #8023 (#8024) 2024-11-28 07:29:09 +01:00
Ricardo Rodriguez
0baaf75353 Fix some minor issues reported by ubsan and the compiler (#8015)
* initialize chiralityPossible

* fix build warning

* Fix integer overflow

* fix downcasting MarvinMolBase to MarvinMol

* Fix buildwarning

* increase PairList container to 64 bit

* fix testDict

* Update Code/RDGeneral/testDict.cpp

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

* Update Code/GraphMol/CIPLabeler/rules/Pairlist.h

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

* Update Code/GraphMol/CIPLabeler/rules/Pairlist.h

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

* Fix catch_tests.cpp

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-11-28 07:28:31 +01:00
Paolo Tosco
312dff466b fix #8019 (#8020)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-11-28 07:28:16 +01:00
Ivan Tubert-Brohman
72007c75fd Catch exceptions in MultithreadedMolSupplier callbacks (#7810)
* Catch exceptions in MultithreadedMolSupplier callbacks

* In next(), simply ignore any exceptions from nextCallback.
* In reader(), if readCallback throws, log a warning and proceed using
  the unmodified record.
* (The writer() was already handling exceptions from writeCallback.)

* Remove unused parameter names

Hopefully this will placate the warning/error settings used by the Linux
build.
2024-11-28 07:28:01 +01:00
Ricardo Rodriguez
6a290ca52f Throw when attempting to normalize a Zero RDGeom::Point (#8008)
* throw if close to zero

* fix moldraw2DTestCatch

* Fix testRGroupDecomp

* fix one test in distGeomHelpersCatch

* fix tests in distGeomHelpersCatch

* retry finding a dir vector when adding Hs

* push UFF fixes to calculateCosY

* fix the setTerminalAtomCoords deg 4 patch

* add a test

* reduce zero tolerance
2024-11-28 07:27:45 +01:00
Ricardo Rodriguez
cf8dd5646c avoid division by zero (#8013) 2024-11-28 07:27:27 +01:00
Ricardo Rodriguez
32ae3107cd look at y if x is very small (#8011) 2024-11-28 07:27:12 +01:00
David Cosgrove
1580ba9109 SynthonSpace Search (#7978)
* First pass at splitting molecule.

* Interim commit.  Reading libraries from file in original format.

* Basic search seems to be working.

* Pattern fingerprint screening.

* Connector region heuristic.

* Fixed triazole (aromatic/non-aromatic connectors).

* Fix search with non-split parent query, where query is substructure of a single reagent.

* Remove duplicate hits by reaction/reagents used.

* Implement largest fragment heuristic.

* Extra test files.

* Read/write binary file.
Program for conversion from text format to binary format.

* Remove empty reagent sets on reading, probably due to synthon number counting from 1 rather than 0.

* Tidy SSSearch functions.

* Stash pending major surgery for triazole bug.

* Revert to using unique_ptr.
Correct use of reagent order.

* Function to summarise Hyperspace.

* Delay building hits till end and put cutoff on number.

* Earlier bale-out in getHitReagents.

* Streamline checkConnectorRegions.

* Remove free functions for search.

* Correct name of Python test.

* First stage of Python wrappers.

* Rename namespace.

* Parameters object.

* Mysterious windows export thing.

* Fix bug - not matching number of connectors in fragment and synthon.

* Back like it was.  The connector count wasn't the problem.

* Put the substructure results into their own class.

* gcc 14 didn't like my use of std::reduce.
Update expected test results.

* Remove write statement.

* Tidy.

* Tidy.

* Enable random sample of hits.

* Test that complex SMARTS works.
Update Python wrappers.

* Rename Hyperspace to SynthonSpace.

* More renaming.
Python test.

* Enable Python test.
Remove write.

* Plug memory leak.

* Response to Greg's initial look.

* More response to Greg's initial look.

* get the windows DLL builds working

* Do away with mutable.
Purge a few more uses of reagent in favour of synthon.
Remove the c++ exe for converting text to binary databases.

* Better Synthon c'tor.

* More feedback from Greg.

* Tidy the Python wrapper.

* Remove tags from catch tests.

* Don't allow copying of SubstructureResults.

* Revert to allow copying of SubstructureResults.  The Python wrapper needs it.

* Refinements based on CLion/clangd suggestions.

* Allow for map numbers in connectors in space file.

* Response to review.

* update binary file spec

* Changes after review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-11-28 07:26:56 +01:00