220 Commits

Author SHA1 Message Date
Greg Landrum
251353a217 Ensure that StereoGroups don't have duplicate atoms or bonds (#9258)
* check for duplicate atoms/bonds in StereoGroups

* explicit handling of duplicate stereogroup atoms in CTAB and CXSMILES parsers

---------

Co-authored-by: = <=>
2026-04-29 16:54:00 +02:00
Greg Landrum
e35f7db009 Cleanup/get atoms and bonds (#9243) 2026-04-18 05:22:09 +02:00
Ricardo Rodriguez
47f2b7c1b5 Fixes #9014 (#9016)
* add a test

* add a fix
2025-12-23 06:43:05 +01:00
Greg Landrum
c2e48f41d8 Stop writing so many atom properties to cxsmiles (#9002)
* fix a bug in copySelectedAtomsAndBonds()
we need to clear computed properties on the atoms here

* prune back the atom properties written to CXSMILES

* update minimallib tests
2025-12-13 04:35:57 +01:00
tadhurst-cdd
c948297d98 added new attributes for scsr template as per BIOVIA doc 2023 (#8911)
* added new attributes for scsr template as per BIOVIA doc 2003

* changed to allow any attributes for an SCSR Template def

* removed unneeded defs for TEMPLATE attribute names
2025-11-06 12:24:45 +01:00
Ricardo Rodriguez
9a4b3e2fc6 Implements #8873 (#8904)
* merge ABS groups on setStereoGroups

* warn/fail on multiple ABS groups on strict parsing

* add a test for setStereoGroups

* add a test for multiple ABS groups in mol blocks

* Drop the warning
2025-11-04 16:10:56 +01:00
Greg Landrum
00583fc1ab Fix a couple issues related to atom list handling in V3000 mol blocks (#8824)
Fixes #8820
Fixes #8823
2025-10-09 05:26:01 +02:00
tadhurst-cdd
8393e26292 allow nested parentheses in tokens (#8553)
* allow nested parens in tokens

* removed commented old code

* add the test file

* changes as per PR review
2025-06-01 12:46:53 +02: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
Greg Landrum
8ea8ec5e3f Fixes #7983 (#8342)
* Fixes #7983

move the call to cleanupAtropisomerStereoGroups() into assignStereochemistry()

* Additional tests from @susanhleung in #8323

* more testing

* changes in response to review

* changes for review
2025-03-20 07:40:33 +01:00
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Ricardo Rodriguez
bd49c8ae81 Fix parsing RBCNT from mol files, and add exporting it (#7638)
* write RBCNT

* Fix RBCNT allowed values

* add a test
2024-07-25 04:54:46 +02:00
Greg Landrum
9bb5e4834f Support zero order bonds in V3K CTABs (#7269) 2024-03-18 18:45:08 +01:00
Ric
5c73d27f84 Fixes #7256 (#7257)
* add a test

* allow 0 as a value in M RAD lines
2024-03-16 06:24:10 +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
fbb1e6baaa Add v2 API to FileParsers (#7077)
* basic approach to v2api

* does not work, backup commit

* well, that now compiles

* cleaner

* more cleanup and testing

* get the SWIG wrappers to build

* swig wrappers now build

* switch back to using references to default values

* adjust to new catch version

* move the implementation to v2 and call it from v1

* update the parameter object too

* move debugParse down

* a couple of review changes

* make v2 naming consistent with Python

* first pass at v2 for the ctab parsers

* move a the writing functionality to a different header

this is just an organizational thing at the moment; we still import the writers header in the parsers header so as to not break code

* do v2 of the tpl parser

* fix missing dependency

* Mol2 parser

* move over the XYZ parser

* switch over the PDB parsers too

* get mac and java builds working (hopefully)
2024-01-28 05:11:54 +01:00
MarioAndWario
643a356e44 Fix Mol block parser by resetting atomic number to 0 for COMPOSITE_OR query atoms (#6349) (#6768)
* Fix Mol block parser by resetting atomic number to 0 for COMPOSITE_OR query atoms (#6349)

* Fix fileParsersTest1

* Fix test23MolFileParsing

* Fix testRGroupDecomp

* Fix testSubstructMatch

* Use std::unique_ptr instead of raw pointer

* Add isAtomDummy() to QueryOps.h

* Add `!a->getQuery()->getNegation()`
2024-01-23 17:13:53 +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
Greg Landrum
a2ecd6723c Fixes #5819 (#6897)
* Fixes #5819
still some things to think about there

* test parsing

* make sure the fix for 5819 also shows up in reactions

* patch some other holes
2023-11-22 17:35:58 +01:00
Hussein Faara
ab7b8dd2c6 Remove boost::regex support #6817 (#6913)
Made the following changes
        * removed RDK_USE_BOOST_REGEX cmake option and its references
        * removed usage of RDKIT_USE_BOOST_REGEX macro
        * removed install instructions related to boost regex
2023-11-21 07:58:29 +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
Riccardo Vianello
ccf450e236 remove incorrect comment (#6717) 2023-09-15 09:06:07 +02:00
Ric
052d48e34e patch + test (#6697) 2023-09-08 06:45:24 +02:00
Ric
90d22c94c5 Fixes #6664 (#6692)
* add some testing

* fix issue

* update doctests
2023-09-07 12:32:38 +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
Jonathan Bisson
eec44e4171 Support additional generic groups (#6570)
* Add search groups (#32)

Tracker story: 184574393 - Support additional query features [1]

All the special groups and atom from the Ketcher extended table are now supported in RDKit. The newley added ones include:
ABH, ACH, AEH, AHH, ALH, AOH, ARH, AYH, CAH, CBH, CEH, CHH, CXH, CTH, G, G*, GH, GH*, R, and the atom query types D, T, H+., and Pol

* Fix tests

Remove Marvin specific code

* Fix windows build

* Fix windows build

* Remove atom matches

* Remove test

* Fix doc

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Update Code/GraphMol/GenericGroups/generic_tests.cpp

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

* Update Code/GraphMol/GenericGroups/generic_tests.cpp

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

* Update Code/GraphMol/GenericGroups/GenericGroups.h

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

* Added test for groups added manually to a query
as per PR review suggestion

* stop reading generic groups as atomnull queries

---------

Co-authored-by: tadhurst-cdd <112502803+tadhurst-cdd@users.noreply.github.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
Co-authored-by: Tad Hurst <tad.hurst@collaborativedrug.com>
2023-08-10 06:36:38 +02:00
thomp-j
7053e97a15 Fix vulnerabilities found by fuzzer. (#6579)
* Fix vulnerabilities found by fuzzer.

* Fix Typo in RWMol.cpp

* Update RWMol.cpp

This is an attempt to double check where the test failure is coming from.

* Update RWMol.cpp

Re-adding changes to test tests.
2023-08-06 06:33:08 +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
Jonathan Bisson
12e23a62d2 Add support for dative bonds in MOL files (#6566)
* Add support for dative bonds in MOL files

Dative bonds cannot be read in mol files V2000.
(really not supposed to be, but some software systems put them in there anyway)

* Add documentation about dative bonds in V2000

* suggestion from review

---------

Co-authored-by: Tad Hurst <tad.hurst@collaborativedrug.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-07-21 08:43:23 +02:00
Timothy Ngotiaoco
1b8b7d1cb4 Fixes #6395: Move string index appropriately with molfiles (#6402)
* Fixes #6395: Move string index appropriately with molfiles

This code gives a fix to issue #6395, where properties lines in molfiles might not be processed correctly when dealing with pairs of values.

* Update tests to reflect molblock parsing changes
2023-05-31 06:14:50 +02:00
Greg Landrum
bfea269b38 Fixes #6241 (#6257)
* handle the cases when the flag is set

* add python wrapper

* Fixes #6241

update and finish?

* set the chiral flag to 0 in the mol file parsers

* adjust to the chiral flag always being present

* add note
2023-04-13 15:38:29 +02:00
Gareth Jones
a5e9d63d3c ReactionFromRxnBlock fails on bond with reacting center status set (#6199)
* Fixed bug in MolFileParser::toInt.  Added test

* Also fix MolFileParser::toUnsigned

* ToInt and ToUnsigned to return 0 when parsing blank string

* Update Code/GraphMol/FileParsers/MolFileParser.cpp

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

* Update Code/GraphMol/FileParsers/MolFileParser.cpp

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

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-03-16 17:39:47 +01:00
Greg Landrum
286cb21302 Allow unrecognized atom types when strictParsing=False (#5891)
We should just read them in as dummies instead of throwing an exception.
A bit of light refactoring to accompany that
2022-12-28 08:25:34 -05:00
Eloy Félix
fde09f5f47 Fix #5810 in V2000 mol files. (#5864)
* fix #5810 for V2000

* fix #5810 for V2000

* fix #5810 for V2000

* fix #5810 for V2000

* fix test molfile indentation
2022-12-14 14:58:04 +01:00
Greg Landrum
2c16e09796 Fixes #5718 (#5825)
* add test

* Fixes #5718
2022-12-02 14:58:32 +01:00
Greg Landrum
f37abdd75c Fixes #5810 (#5811)
* Fixes #5810

* expand the test
2022-12-01 17:11:00 +01:00
Greg Landrum
2640819383 Fixes #5763 (#5764)
* Fixes #5763

* another test
2022-11-16 08:29:44 -05:00
Greg Landrum
42eed2605d Add CXSMILES support for bond wedging and wiggly bonds (#5575)
* initial support for wiggly and wedged bonds in cxsmiles
add CX_ALL_BUT_COORDS convenience option to CXSMILES writer

* move ClearSingleBondDirFlags to MolOps

* do a better job of handling the wiggly bonds

* mark 3D conformers from CXSMILES

* remove some extraneous printing

* test wD as well

* remove non-applicable test

* basic tests (not passing) for parsing t/c/ctu

* remove test for unimplemented feature

* changes in response to review

* changes in response to review

check for attempt to set the wedging more than once
testing for invalid w blocks
fix a bad comment
2022-09-24 05:44:01 +02:00
Ric
0d8ea2aec1 Fixes #5423 (#5424)
* fix

* always remove molTotValence
2022-07-13 05:36:54 +02:00
Greg Landrum
fbbddc6035 Start using string_views in the file parsers (#5301)
* slow steps towards a string_view experiment

* Move first set of file-handling code to use string_view
This is about 12% faster on my machine

* oops, yaehmop had not been updated to C++17

* start moving v3000 over

* disable storing string_views in Dicts.

* a bit more optimization

* get windows builds working

* fix a couple leaks in the test code

* changes in response to review

* changes suggested in review
+ more refactoring

* fix an oversight

* remove another one

* remove debugging numbers
2022-06-14 17:18:40 -04:00
Greg Landrum
d640eb98c9 [WIP] Fixes #5327 and #5328 (#5330)
* Fixes #5328
Fixes #5327

probably a good idea to add a bit more testing here

* more tests!
2022-06-01 04:45:14 +02:00
Greg Landrum
6e5b01200b Add support for Pol and Mod pseudoatoms (#5264)
* reading pseudoatoms

* basics of writing

* switch to using dummyLabel to make this consistent
add cxsmiles read/write support
2022-05-07 11:10:57 +02:00
Sreya Gogineni
757d088157 Fixes #5165 (#5209)
* Improved regex whitespace handling

Change was made in the parseEnhancedStereo function

* Files for Github #5165 test case

Both files use enhanced stereochemistry, but differ in whitespace content

* Test case for Github Issue #5165

Catches whitespace parsing error

* Improves test case check

Makes test case more specific, less prone to potential invalid access to container

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

* Improves test case check

Makes test case more specific, less prone to potential invalid access to container

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

* Update test case "Github #5165"

Add 'require(mol)' to confirm valid molecule before additional testing

* Cleans up test for Issue #5165

* Cleans up test for Issue #5165

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2022-04-17 17:35:43 +02:00
Paolo Tosco
67d8dd3dcd Add a couple of depiction helper functions and some JS bindings (#5115)
* - adds normalizeDepiction() and Python wrappers
- adds straightenDepiction() and Python wrappers
- adds an early check for R-labels to be in the accepted range to avoid throwing an exception later on
- adds a kekulize flag to process_details() to enable depicting molecules which fail to kekulize from JavaScript
- adds JavaScript functions to get fingerprints as Uint8Array
- adds JavaScript function to generate pickled molecule as Uint8Array
- adds JavaScript function to restore molecule from Uint8Array pickled
- adds has_coords() JavaScript function
- adds set_new_coords() to set JSMol coordinates in-place
- adds get_mol_copy() to obtain a JSMol copy

* fix build failures

* changes in response to review

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-03-22 14:18:30 +01:00
Eisuke Kawashima
ba6d8e0d3b clang-tidy: readability-simplify-boolean-expr (#4639) 2022-03-17 13:50:50 +01:00
Greg Landrum
8390dfd181 Fixes #4785: aromatic bonds no longer set aromatic flags on atoms (#4806)
* preliminary

* all tests pass

* cleanup

* more testing!

* we do still want to raise errors for aromatic atoms not in rings
fix one missed change for mol blocks

* update expected results for psql test
2021-12-17 10:26:59 +01:00
Greg Landrum
d20e5cadc8 Fixes #4561 (#4562) 2021-09-27 04:48:59 +02: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
Ric
c0923565e4 Fixes #4473 (#4474)
* allow MRV_COORDINATE_BOND_TYPE sgroups to reference bonds

* update to match Marvin behavior (always use bonds)
2021-09-04 16:55:55 +02:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04:00