69 Commits

Author SHA1 Message Date
Eisuke Kawashima
e89c9f656a style: apply readability-braces-around-statements (#8136)
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
2026-02-09 12:10:50 +01:00
Greg Landrum
951be4f06e fixes #5078 (#8795)
* fixes #5078

* add some more tests
2025-09-22 11:06:42 +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
28db5d706c Revert "Fixes #5134 (#5136)" (#8319)
This reverts commit 8691c58055.
2025-03-05 18:11:24 +01:00
Ricardo Rodriguez
5596179c95 Fixes #8256 (#8257)
* add test

* fix
2025-02-12 15:34:28 +01:00
Greg Landrum
8691c58055 Fixes #5134 (#5136) 2025-01-30 16:10:57 +01:00
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
Greg Landrum
da6cd73168 Run clang-format across everything (#7849)
* run clang-format-18 across Code/*.cpp and Code/*.h

* run clang-format-18 across External
2024-09-26 13:39:02 +02:00
Juuso Lehtivarjo
9824a9d964 Expose MMFF aromaticity model for SetAromaticity (#7765)
* Expose MMFF aromaticity model for SetAromaticity

* Test, backward compatibility, missing AromaticityModel wrapper
2024-09-18 05:59:02 +02: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
Ric
58d135a874 Reformat C/C++ code ahead of 2023.03 release (#6295)
* format files

* format template files too
2023-04-28 04:42:35 +02:00
Greg Landrum
1f4584b2ca run clang_format (#5676) 2022-11-01 04:14:26 +01:00
Dan N
f3ae1e90fb Update warning message about aromaticity detection (#5696)
An internal user encountered the existing error message and became alarmed by the implication that no aromaticity detection was even attempted.

I think that the new error message more accurately reflects the logic - we halt the search eventually if the ring system is too large.
2022-10-28 19:45:45 +02:00
alexwahab
f4b6345978 add condition for arom calc of large ringysystems (#5648)
Possible ring combinations expand combinatorially, so for large ring systems, just checking for ring fusions may be slow. For a reported example of 900 rings, the calculation never completes. 300 is about 2 million iterations, which takes approximately 1 minute.
2022-10-16 08:10:22 +02:00
Rachel Walker
30547e4451 Fix performance issue in RingUtils::checkFused that slowed down sanitization (#5410) 2022-07-08 05:19:22 +02:00
Greg Landrum
67409c3acf Fixes #5152 (#5153)
Also adds a typeLabel to the bond order queries so that they are easier to recognize
2022-04-04 06:07:57 +02:00
Paolo Tosco
dc4893132b Fixes #4721 (#4722)
* fixes #4721

* - store in RingInfo the index of the ring(s) each atom and bond belongs to rather tham just their size
- expand the RingInfo API with a few useful methods
- identify rings that are certainly aliphatic upfront
- avoid unnecessary copying atomRings when RingInfo is already initialized

* - code modernization and cleanup
- better handling of dummies in aromatic rings
- exposed atomMembers() and bondMembers()
- added several tests

* - avoid order dependency on rings
- added test for the above

* changes in response to review

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-01-28 16:38:46 +01:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04:00
Dan N
b5dcb21fef Improve performance of aromaticity detection for large molecules (#3253)
* remove trailing spaces

* 3256: Envelope aromaticity not detected in complex fused system

Removes stopping point in aromaticity detection when all atoms
are "done". This also markedly improves the performance of
aromaticity detection for very large molecules - for example,
aromitization of 3EOH from the PDB was dominated by done atom
checking before this commit.

Some aromatic bonds were missed before this commit in complex fused
systems. This happened if all atoms in the fused system were also
in some smaller aromatic ring and there was at least one fused edge
that was single in the kekule form.

Some example molecules for which envelope aromaticity failed
before this commit:

c1cc2n(c1)c1cccn1c1cccn21
-> became c1cc2n(c1)-c1cccn1-c1cccn1-2 before this commit
c1cc2c3cc[nH]c3n3cccc3n2c1
-> became c1cc2n(c1)-c1cccn1-c1[nH]ccc1-2 before this commit
c1cc2c3cc[nH]c3c3cc[nH]c3n2c1
-> became c1cc2n(c1)-c1[nH]ccc1-c1[nH]ccc1-2 before this commit

Here's a similar example that didn't fail even before this
commit. The central ring only shares double bonds with the
exterior rings.
* c1cc2c([nH]1)c1cc[nH]c1c1cc[nH]c21

Requires updates to some MQN descriptors tests because some
bonds become aromatic (MQN includes counts of single and
double bonds of kekule form).

FWIW, for the molecule that had a change in counts, the counts
were incorrect both before and after this commit, because
MQN uses an approximation (dividing aromatic bonds evenly
between single and double bonds) to avoid kekulization.
This approximation is invalid when there are oodles of
nitrogens lone pairs participating in the aromatic
bonds.

(the failing line was 2558 in aromat_regress.txt: Cc1cc2n(n1)c1cc(C)nn1c1c(C=O)c(C)nn21)

* Detect envelope aromaticity in fused systems

In #3253, we proposed removing doneAtoms for performance, and it was
noted that it also fixed detection of envelope aromaticity in some
fused systems. However, when I completely removed doneAtoms, I saw
hangs in sanitization of things like nanotubes. Using doneBonds
allows envelope aromaticity, while preserving a reasonable break
on runaway work for crazy molecules.

The performance issue was addressed by caching the ring bond
count.

Here are some sanitize timings on proteins from the RCSB PDB:
Before this commit:
* 3eoh 1.21s
* 2j3n 0.77s
* 1nks 0.053s

Afterwards:
* 3eoh 0.42s
* 2j3n 0.15s
* 1nks 0.046s

* Use boost::dynamic_bitset instead of unordered_set

To cound ring bonds.
2020-08-13 05:57:16 +02:00
Greg Landrum
7e2ccecc8d Fixes #2895 (#2906)
* Fixes #2895

* typo fix
2020-01-26 07:41:51 -05: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
Eisuke Kawashima
dc7cc84a0c Fix typo [ci skip] 2019-10-17 17:45:50 +09:00
Greg Landrum
5bb4522810 Fix github1928 (#1946)
* add the failing test and some debugging info

* fixes #1928
Stop allowing rused-ring aromaticity if the rings share more than one bond
2018-07-14 12:32:38 -04:00
Greg Landrum
d9b06a733b Fixes #1936 (#1945)
* Fixes #1936
doctests of the book still need to be verified

* a fix that is related to #1940

* add test for what was actually reported
2018-07-05 11:53:54 -04:00
Boran Adas
8452ec59f9 Fix for issue #1730 (#1792)
* Fix for issue #1730

setAromaticity() now works even if there are aromatic atoms present and the relevat test case is added

* Removed setaromaticity flag
2018-03-25 06:38:34 +02:00
Greg Landrum
5c21c0ad67 Fixes #1703 (#1714)
* does not actually work

* all tests pass;
Fixes #1703

* make that a bit cleaner
2018-01-08 20:06:42 -05: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
f6ced134f0 a number of other small changes from manually reviewing the PR 2017-04-22 17:24:57 +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
270f7b76e5 Partial support for reading CXSMILES (#1237)
* add a SmilesParserParams object to prepare for this

* add a SmilesParserParams object to prepare for this

* add tests for the SmilesParseParmas

* support name parsing, should it be the default?

* rename CXNSmiles to CXSmiles;
add a spirit parser for CXSmiles coordinate that is at least syntax correct

* abandon boost::spirit for now; crude atom token parser

* support params in smiles parser (not tested, may not build)

* can read coords and atom labels along with mol names; crude, but works

* read coordinate bonds

* remove some compiler warnings with VS2015

* remove a bunch of compiler warnings on windows

* remove more warnings on windows

* remove more warnings on windows

* backup commit: first pass at parsing query features

* radical spec parsing

* handle attachment points using atom mapping

* switch to a named property for atom labels

* fix handling of the "A" atom query

* add functions to construct A and Q queries (needs more work)

* fix a problem created while cleaning up warnings earlier

* add some additional convenience functions for making generic atoms.
Still need M and to recognize these while writing CXSMILES

* add M queries; update some tests

* fix a linux compile problem

* get the cxsmiles stuff working in python; basic testing

* support "M" in CXSMILES
2017-01-31 13:50:36 -05:00
Greg Landrum
452ed7156f Add support for a simplified aromaticity model. (#942)
* first pass

* Fixes #623

* fix a merge problem

* move the aromaticity perception to a helper fn

* python doc update

* replace setSimpleAromaticity() with a parameter to setAromaticity()

* add simple test for the custom aromaticity function
2016-06-17 17:48:20 -04:00
Greg Landrum
6a4a032e92 Fixes #518 2016-03-21 16:57:12 +01: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
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
Paolo Tosco
c6362c8930 - fixed indentation 2015-07-16 20:10:21 +01:00
Paolo Tosco
565819a97f - removed spurious debug code 2015-07-16 20:09:12 +01:00
Paolo Tosco
48396640c1 - fixed lack of tropylium/ciclopropenyl cation aromaticity perception
- added a test for allyl cation conjugation
- added a test for tropylium/ciclopropenyl cation aromaticity
2015-07-16 20:05:46 +01:00
Paolo Tosco
27ce1daa1c - fixes lack of conjugation detection on allyl cations and the like 2015-07-16 18:56:02 +01:00
Greg Landrum
74125f685c Fixes #443 2015-03-05 06:38:38 +01:00
Greg Landrum
4363ac9338 Fixes #432 2015-02-21 08:15:58 +01:00
Brian Kelley
95a92282d1 Dictionary access is saniztized and optimized.
o rdkit gains a RDKit::common_properties namespace that contains common string value properties

 o Dict.h and below gain getPropIfPresent that attempts to retrieve a property and returns
  true/false on success or failure.  This is used to optimize access.

 o rdkit learns how to pass property keys by reference, not value.

A new namespace has been added to RDKit, common_properties
that contains the std::string values for commonly used
properties.  This helps to avoid typos in string values
but also avoids a creation of std::strings from character
values.  All accessors (has/get/clear and getPropIfPresent) now pass
the key by reference.

Additionally, getPropIfPresent removes the double lookup
of hasProp/getProp which can be a significant speedup
in the smiles and smarts parsers (10-20%)
2015-01-15 12:23:29 -05:00
Greg Landrum
0f92877061 stop messing up aromaticity and hybridization;
all tests pass, but this is definitely not the most efficient thing.
2013-11-30 08:07:09 +01:00
Greg Landrum
86b9e6b089 Fixes #72 2013-08-25 06:36:10 +02:00
Greg Landrum
6555d2062f more changes connected to sf.net issue 249 2012-09-16 05:40:17 +00:00