24 Commits

Author SHA1 Message Date
Greg Landrum
3aab2653cd Fixes #9068: raise a ValueError when trying to set properties with empty names (#9085)
* Fixes #9068

* fix a problem with empty labels in s-group parsing

* fix empty column names in smiles suppliers

* add the check to setPODVal()

---------

Co-authored-by: = <=>
2026-02-09 05:58:25 +01:00
Ricardo Rodriguez
47f2b7c1b5 Fixes #9014 (#9016)
* add a test

* add a fix
2025-12-23 06:43:05 +01:00
tadhurst-cdd
ca41fa5bfd Add SCSR parsing to RDKit (#8147)
* Parsing SCSR

* add scsrol to mol

* removed bad include file

* loosen distGeom test slightly

* add wrap test for SCSRMol

* Add test for scsr in python

* tests added for scsr and strict parsing removed

* remove extra stuff

* More fully specified use of SCSRMol for PR CI build

* Added flags for SCSR expansion to not include any leaving groups

* Added MolFromScsrParams to Wrap for python

* added SCSRMol destructor

* Added two tests for RNA macromols, and fixed a bug they revealed

* Added new tests abd expected files

* changes as per PR review

* SCSR Chnages for leaving groups

* fixed testScsr.py

* hydrogen bond treatment

* in SCSR expand, allow Hbond to be autoatically detected

* changes as per code review

* Adding new test file

* chages for SCSR contructors, destructors for CI build

* fixed pyton for SCSR hydrogen bond modes, and added tests

* Added new test files

* fixed edge case for SCSR

* fix checksum for inchi

* consistent capitalization of SCSR throughout

* switch to enum class

* make things shorter

* simplify

* get rid of the ATTCHORD class

* New section for SCSR in RDKit_book

* addeed section to RDKit_Book

* SCSRMol is no longer exposed in Python

* fix leak in MolFromSCSRFile()
light refactoring

* expose MolFromSCSRFile() to python
make the MolFromSCSR functions work with default args
a bit more testing

* removed C++ access to SCSRMol

* CXMsiles now ouputs hbonds, fix to template matching, and a few other things

* Addl fix for bad aromaticity in Hbond rings

* Test files needed

* Test files needed

* try to fix a CI build errors

* CI error fix

* Added missing test file

* CMake version - for CI build

* remove full file compoarison from macromol test file

* accidental change to debug restored to release

* Code review changes

* As per PR review

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-05-14 13:37:59 +02:00
thomp-j
4efc9a362b Vulnerability fixes (#8116)
* Vulnerability fixes

* Vulnerability fixes

* Move Iterator bounds check to a PRECONDITION for parse_data_sgroup_attr.

* Update MolFileParser.cpp

Remove ill-advised ASCII filter when parsing SDF V3000

* Update MolFileParser.cpp

Remove extra whitespace.

* Squashed commit of the following:

commit 1a1279c137afeca77d4fd68b287a7e36c6bf5c37
Merge: 7d0765c8b 3d2a43470
Author: James Thompson <thompj@google.com>
Date:   Wed Dec 18 14:22:29 2024 +0000

    Merge branch 'vuln_fix' of https://github.com/thomp-j/rdkit_vuln into vuln_fix

commit 7d0765c8ba2e0be54649613fce2f61545ad5d9d2
Author: James Thompson <thompj@google.com>
Date:   Wed Dec 18 14:20:54 2024 +0000

    Squashed commit of the following:

    commit 5a5902a874109d42cc4a20de535bdca0855c429b
    Merge: ec0ff4ee2 3d2a43470
    Author: James Thompson <thompj@google.com>
    Date:   Wed Dec 18 14:18:02 2024 +0000

        Remove whitespace

    commit 3d2a43470f
    Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
    Date:   Wed Dec 18 09:08:57 2024 -0500

        Update MolFileParser.cpp

        Remove extra whitespace.

    commit a8a718923c
    Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
    Date:   Wed Dec 18 09:08:09 2024 -0500

        Update MolFileParser.cpp

        Remove ill-advised ASCII filter when parsing SDF V3000

    commit 270136d6c0
    Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
    Date:   Wed Dec 18 09:07:05 2024 -0500

        Move Iterator bounds check to a PRECONDITION for parse_data_sgroup_attr.

    commit ec0ff4ee29e9cca5bbd9591d30f8a96646484ec5
    Merge: ca4ed2faa 2d257b119
    Author: James Thompson <thompj@google.com>
    Date:   Wed Dec 18 14:04:30 2024 +0000

        Merge branch 'vuln_fix' of https://github.com/thomp-j/rdkit_vuln into vuln_fix

    commit ca4ed2faa4219abfd97628d529be3a1fd97048bf
    Merge: c11caffbd 63123278c
    Author: James Thompson <thompj@google.com>
    Date:   Wed Dec 18 13:59:48 2024 +0000

        Merge branch 'vuln_fix' of https://github.com/thomp-j/rdkit_vuln into vuln_fix

    commit 2d257b1194
    Merge: d45612334 74fc77f95
    Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
    Date:   Wed Dec 18 09:03:06 2024 -0500

        Merge branch 'rdkit:master' into vuln_fix

    commit d456123344
    Merge: c11caffbd 63123278c
    Author: James Thompson <thompj@google.com>
    Date:   Wed Dec 18 13:59:48 2024 +0000

        Merge branch 'vuln_fix' of https://github.com/thomp-j/rdkit_vuln into vuln_fix

    commit c11caffbd7
    Author: James Thompson <thompj@google.com>
    Date:   Tue Dec 17 15:26:41 2024 +0000

        Vulnerability fixes

    commit 74fc77f959
    Author: Paolo Tosco <paolo.tosco.mail@gmail.com>
    Date:   Wed Dec 18 13:40:57 2024 +0100

        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>

    commit e589f173fd
    Author: David Cosgrove <davidacosgroveaz@gmail.com>
    Date:   Wed Dec 18 04:14:11 2024 +0000

        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>

    commit ce35b3c25b
    Author: David Cosgrove <davidacosgroveaz@gmail.com>
    Date:   Wed Dec 18 04:12:07 2024 +0000

        SynthonSearch synth check (#8109)

        * Catch errors when creating products.

        * Extra python test.

        * Fix formatting.

        ---------

        Co-authored-by: David Cosgrove <david@cozchemix.co.uk>

    commit 63123278ca
    Author: James Thompson <thompj@google.com>
    Date:   Tue Dec 17 15:26:41 2024 +0000

        Vulnerability fixes

    commit e640915d4e
    Author: Nikitas Rontsis <nrontsis@gmail.com>
    Date:   Tue Dec 17 15:11:40 2024 +0000

        Avoid unnecessary matching (#8111)

    commit 5aed3d886b
    Author: Greg Landrum <greg.landrum@gmail.com>
    Date:   Mon Dec 16 16:59:13 2024 +0100

        Fixes #8096 (#8104)

        * add test

        * Fixes #8096

        * change in response to review

    commit 6dce5d4080
    Author: Greg Landrum <greg.landrum@gmail.com>
    Date:   Sun Dec 15 05:58:20 2024 +0100

        Fixes #1670 (#8093)

        * add missing descriptors to Lipinski.py
        Fixes #1670

        * add to descriptor list

commit 3d2a43470f
Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
Date:   Wed Dec 18 09:08:57 2024 -0500

    Update MolFileParser.cpp

    Remove extra whitespace.

commit a8a718923c
Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
Date:   Wed Dec 18 09:08:09 2024 -0500

    Update MolFileParser.cpp

    Remove ill-advised ASCII filter when parsing SDF V3000

commit 270136d6c0
Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
Date:   Wed Dec 18 09:07:05 2024 -0500

    Move Iterator bounds check to a PRECONDITION for parse_data_sgroup_attr.

commit 2d257b1194
Merge: d45612334 74fc77f95
Author: thomp-j <58603847+thomp-j@users.noreply.github.com>
Date:   Wed Dec 18 09:03:06 2024 -0500

    Merge branch 'rdkit:master' into vuln_fix

commit d456123344
Merge: c11caffbd 63123278c
Author: James Thompson <thompj@google.com>
Date:   Wed Dec 18 13:59:48 2024 +0000

    Merge branch 'vuln_fix' of https://github.com/thomp-j/rdkit_vuln into vuln_fix

commit c11caffbd7
Author: James Thompson <thompj@google.com>
Date:   Tue Dec 17 15:26:41 2024 +0000

    Vulnerability fixes

commit 74fc77f959
Author: Paolo Tosco <paolo.tosco.mail@gmail.com>
Date:   Wed Dec 18 13:40:57 2024 +0100

    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>

commit e589f173fd
Author: David Cosgrove <davidacosgroveaz@gmail.com>
Date:   Wed Dec 18 04:14:11 2024 +0000

    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>

commit ce35b3c25b
Author: David Cosgrove <davidacosgroveaz@gmail.com>
Date:   Wed Dec 18 04:12:07 2024 +0000

    SynthonSearch synth check (#8109)

    * Catch errors when creating products.

    * Extra python test.

    * Fix formatting.

    ---------

    Co-authored-by: David Cosgrove <david@cozchemix.co.uk>

commit 63123278ca
Author: James Thompson <thompj@google.com>
Date:   Tue Dec 17 15:26:41 2024 +0000

    Vulnerability fixes

commit e640915d4e
Author: Nikitas Rontsis <nrontsis@gmail.com>
Date:   Tue Dec 17 15:11:40 2024 +0000

    Avoid unnecessary matching (#8111)

commit 5aed3d886b
Author: Greg Landrum <greg.landrum@gmail.com>
Date:   Mon Dec 16 16:59:13 2024 +0100

    Fixes #8096 (#8104)

    * add test

    * Fixes #8096

    * change in response to review

commit 6dce5d4080
Author: Greg Landrum <greg.landrum@gmail.com>
Date:   Sun Dec 15 05:58:20 2024 +0100

    Fixes #1670 (#8093)

    * add missing descriptors to Lipinski.py
    Fixes #1670

    * add to descriptor list

commit a4cdf5d21d
Author: Greg Landrum <greg.landrum@gmail.com>
Date:   Sun Dec 15 05:58:03 2024 +0100

    Fixes #8092 (#8094)

    * Fixes #8092
    cross-platform file stuff is just soooooo fun

    * response to review

    * works on windows

commit b7de0585ca
Author: Greg Landrum <greg.landrum@gmail.com>
Date:   Sat Dec 14 18:21:55 2024 +0100

    Add drawMols3D() and improve documentation for IPythonConsole (#8083)

    * Fixes #8082
    more docs

    * changes in response to review

commit 736e309f10
Author: David Cosgrove <davidacosgroveaz@gmail.com>
Date:   Sat Dec 14 17:21:29 2024 +0000

    Fix empty results bug. (#8099)

    Co-authored-by: David Cosgrove <david@cozchemix.co.uk>

commit c90cee9b77
Author: Greg Landrum <greg.landrum@gmail.com>
Date:   Sat Dec 14 17:08:43 2024 +0100

    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>

* Adds error message to parse_data_sgroup_attr PRECONDITION
2025-01-27 17:10:20 +01:00
Ric
5063bc1477 Fixes #7246 (#7247)
* add a test

* fix parsing empty sgroup fields
2024-03-16 07:37:16 +01:00
Alex Rebert
e2b0a850d7 Fix memory safety issues found by OSS-Fuzz (#4983)
* RWMol: replace atom in stereo groups

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36998, a
use-after-free in initFromOther.

* Fix out-of-bounds write in iterateCIPRanks

If the rank has not changed in the current iteration, the cipEntries
vectors might not have increased in size. Accessing `numIts + 1`
resulted in an out-of-bounds write. This commit skip the cipEntries
update when the rank is unchanged.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28660

* Fix use of uninitialized values in MolSGroupParsing

`stream >> count` may silently fail without an exception. In that case,
`count` was uninitialized but used. This commit initalizes `count` to 0,
as well as other variables that may be read without being initialized.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25220
Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25225

* Fix vector size cast in streamReadVec

In 32-bit systems, the implicit conversions from 64-bit to a 32-bit
size_t could lead to an underallocation of the vector. This would follow
by a out-of-bounds write while trying to populate the vector. Now, the
code throws an exception in case of a cast that would change the size.

Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28034

* RWMol: improve atom replacement in stereo groups

This code is cleaner and more efficient.

* Add test for replaceAtom and stereo groups
2022-02-06 05:06:38 +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
58e6743df0 Fixes #4468 and #4476 (#4482)
* stop removing substance groups with replaceAtom()
change default for keepSGroups argument to replaceBond()

* enable logging output for the fileparserscatch

* basics of parsing SMARTSQ SubstanceGroups

* Fixes #4476
test coming in the next commit

* handle multi-atom SMARTS as recursive
more testing
Test #4476

* a bit of cleanup

* get the tests working

* additional testing

* Update Code/GraphMol/FileParsers/MolFileParser.cpp

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

Co-authored-by: Ric <ricrogz@users.noreply.github.com>
2021-09-05 05:43:13 +02:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04:00
Ric
5d2f167bfe Addresses #4434 (#4435)
* add index property to v2000 sgroups

* add a simple test

* update old test
2021-08-24 05:10:06 +02:00
Greg Landrum
5d0eb77c65 allow more recoverable SGroup errors when strictParsing=false (#4210) 2021-06-07 15:39:49 +02:00
Greg Landrum
36ba6e2b4d support empty/missing SDT lines for SGroup data (#3916) 2021-03-12 04:30:26 +01:00
Paolo Tosco
4084284ba5 Make better use of strictParsing for SGroups (#3705)
* - eliminate some documentation ambiguity about the role of the strictParsing flag
- fix some inconsistencies between SGroup parsing function prototype declarations and implementations
- add a workaround for accepting malformed V2000 'M  SAP' entries affecting older version of MarvinJS (only if strictParsing is set to false)
- if strictParsing is set to false, malformed V2000/V3000 SGroups are ignored rather than causing the parsing to fail
- fix a couple typos in warnings

* changes in response to review
2021-01-14 10:29:41 +01:00
Greg Landrum
d65d47189c Fixes: #3415 (#3416)
* Fixes: #3415

* add another test
2020-09-18 10:01:10 -04:00
Greg Landrum
73d26036de Support enumerating some mol file features into MolBundles (#3257)
* backup

* compiles

* progress, but not there yet

* basics now working

* start towards adding another test

* test having two variation points

* add actual enumeration and the corresponding tests

* docs and cleanup

* cleanups to get the mac build working

* attempt to get win32 dll builds to work

* dlls are fun

* Add FixedMolSizeMolBundle class

* changes in response to review

Also: add warnings for bad input in ParseV3000Array

* a bit of refactoring

* additional testing

* does not work, backup

* LINKNODES work now

* cleanup

* allow silencing reaction validation warnings during initialization

* docs

* fix (and test) handling of empty enumerations

* silence warnings when doing alchemy

* first pass at a Python wrapper for the enumerator

* Add Java wrappers for MolBundle and the MolEnumerator

* cleanup some comment formatting
2020-07-11 12:54:23 +02:00
Greg Landrum
83a1e75597 basic handling of XBCORR and XBHEAD (#3242) 2020-06-22 16:54:57 +02:00
Greg Landrum
edd922c99c Cleanup warnings from clang-10 (#3238)
* stop returning local memory in exceptions

* remove a couple unnecessary copies in loops

* fix a bug in the way the default MMFF aromatic parameters are constructed

* remove a bunch of loop-variable warnings

* remove a bunch of clang warnings

* disable clang warnings in python wrappers

* remove some warnings when building the python wrappers
2020-06-19 17:16:22 -04:00
Greg Landrum
95613b6279 Allow SubstanceGroups to survive molecule edits (#3170)
* Progress on #3168

* Fixes #3167

* Fixes #3169

* deal with CBONDS too

* test PATOMS

* Fixes #3175

* a bit of code simplification and test updates

still needs more testing

* more testing

* handle s-group hierarchy
also a couple of other changes in response to the review

* add forgotten test file

* changes in response to review
2020-05-19 17:35:08 +02:00
Greg Landrum
60566aa35f SGroups with more than one attachment point are now properly parsed (#3072)
* SGroups with more than one attachment point are now properly parsed

Thanks to Roger S for the example and fix.

* Update Code/GraphMol/FileParsers/file_parsers_catch.cpp

Co-Authored-By: Ric <ricrogz@users.noreply.github.com>

Co-authored-by: Ric <ricrogz@users.noreply.github.com>
2020-04-12 10:25:39 +02:00
Eisuke Kawashima
dc7cc84a0c Fix typo [ci skip] 2019-10-17 17:45:50 +09: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
5a79190261 rename SGroup -> SubstanceGroup (#2375)
We leave the names of the bit connected with Mol files as SGroups, since that is
appropriate there, but the more generic pieces are renamed
2019-03-30 14:53:24 -04:00
Greg Landrum
b52ad644b2 Robustify parsing of CTABs and SGROUPs (#2283)
* Fixes #2277

* changes in response to review
the big one is to move the PXA parser into the normal mol file parsing

* move the PXA changes to the writer as well

* SCN actually only needs 7 characters

* add test

* fixes in response to review

* handle blanks (instead of zeros) in the counts line.
The ctfile.pdf doc says we should do this

* Make the SGroup reader more robust w.r.t. bad data
The current behavior leads to uncaught exceptions when a line is too short.
This should clear that up so that we always throw the usual FileParseException

* make error messages a bit easier to read
2019-02-21 17:39:39 +01:00
Ric
d26d4b076e Support for parsing/writing SGroups in SD Mol files. (#2138)
* Implementation of SGroups

* remove sample files test

* update gitignore with test outputs

* fix RevisionModifier

* re-enable tests

* backup commit; things seem to work so far

* some refactoring; obvious s group tests pass now

* more refactoring

* everything now out of the public API

* not sure why this was still in there

* rename functions; all tests now pass

* remove getNextFreeSGroupId; readd comment in copy SGroups

* clang-format

* squash-merge current master

* squash merge master

* Address comments on PR

- Update to current master.
- Move SGroup parse time checks to SGroupChecks namespace.
- Store SGroups in ROMOl as vector<SGroups>.
- SGroup methods return referenes instead of pointers.
- Use atom/bond/sgroup indexes for properties instead of pointers.
- Have SGroups inherit from RDProps; move properties to RDProps.
- Remove trivial/unused methods.
- Add a link to the SD specification atop SGroup.h
2019-01-22 15:42:27 +01:00