62 Commits

Author SHA1 Message Date
Greg Landrum
85f33083cd add checked atom and bond iterators (#9290)
* add checked iterators

* support checked atom and bond iterators

the idea here is to allow optional checking that the graph is not being
modified while an iterator is active

* ignore new member functions

---------

Co-authored-by: Ric R <ricrogz@gmail.com>
2026-05-26 15:25:34 +02:00
Greg Landrum
2c6efb4a65 Add some std::ranges support (#9218)
* initial ranges support for Atom/Bond iterators.
needs more testing

* support random access
test sort

more testing please

* compiles on windows

* fix size()
more testing
add some benchmarking

* disable benchmarking code by default

* do not allow modifying the graph through the iterators

---------

Co-authored-by: = <=>
2026-04-13 17:13:04 +02:00
Greg Landrum
9d4afd0e08 add clearPropertyCache() (#8533) 2025-05-18 08:14:05 +02: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
Richard Gowers
4db63b8ec1 Issue 6411 ROMol hasquery (#6739)
* added ROMol::hasQuery

* python bindings for Mol.HasQuery

* at least I checked that my Python tests were running...

* hasQuery use C++11 range iterators
2023-09-25 13:23:37 +02:00
Ric
eebb973ee9 fix + test (#6682) 2023-09-04 06:36:42 +02:00
Dan N
5393a005da Fix RWMol::addAtom docstring (#6477)
The docstring claimed that it returned the new number of atoms. It actually returns the index of the new atom.

I think it makes more sense to change the documentation than the behavior, because callers are definitely out there using the current behavior.
2023-06-23 13:49:01 +02:00
Paolo Tosco
6ef6958134 - added equality operator to CXXAtomIter and CXXBondIter classes such that they can used with implicit loop STL algorithms (#5995)
- added relevant unit tests

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-01-20 15:00:32 +01:00
Eisuke Kawashima
77db9ede80 fix doxygen comments (#5254) 2022-07-11 13:55:35 +02:00
Greg Landrum
a354f2db62 add boost::serialization support to ROMol (#5249)
* add boost::serialization support to ROMol

* add RWMol test

* get the windows DLL builds working

* switch FilterCatalog and SubstructLibrary to serialize ROMols

* an actual solution to the windows dll problem

* the FilterMatchers stuff was not working
2022-05-07 11:11:53 +02:00
Ric
918f0221b9 Make atom, bond iterators usable in STL algorithms (#5204)
* add fwditerator features

* add a test
2022-04-15 06:57:57 +02:00
Greg Landrum
555ab6f1fe Start adding move constructors and move-assignment operators (#4909)
* some initial work...
Still some real questions here about what should be done with dp_mol data members

* add some tests for move semantics of Dict and Props
remove extraneous clear()

* more in-depth testing of the molecule results

* test refactoring

* improve the molecule move test

* fix some leaks found by valgrind
the new tests are now all clean in valgrind

* additional classes
QueryAtom, QueryBond, RingInfo, Conformer

* get swig working again.
Not sure why this is necessary, but SWIG is a mysterious beast

* fixes in response to review

* updates in response to review
2022-02-09 14:20:49 +01:00
Greg Landrum
7e575db3c4 AssignStereochemistry should remove nonchiral atoms from StereoGroups (#4986)
* Nonchiral atoms should be removed from StereoGroups

This fixes a bug where atoms which have no chirality were left in StereoGroups

In order to make this work, ROMol::setStereoGroups() needed to be made public.
That shouldn't be a problem since it doesn't change connectivity.

* fix some broken old tests

* update cartridge tests
2022-02-08 05:17:34 +01: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
Eisuke Kawashima
78aac3c1bc Run clang-format against header files (#4143) 2021-06-08 07:57:51 +02:00
Greg Landrum
af3bb3e78b Allow partial deserialization of molecules (#4040)
* make pickling/depickling conformers optional

* make de-pickling properties optional

* support the new options in molecule ctors

* update doctest
2021-04-24 07:22:55 +02:00
Greg Landrum
2e3f31990d Allow batch editing of molecules: removal only (#3875)
* backup

* simple first pass, passes all tests

* cleanup a bunch of existing uses

* ensure that we can safely add atoms/bonds while in edit mode

* add context manager on python side

* handle exceptions properly in those

* changes in response to review
2021-03-11 05:10:43 +01:00
Jin Pan
d36bda6b08 ROMol: add inline impl for common getNumAtoms call (#3469)
This improves throughput of `MolToSmiles` by about 5%.
2020-10-11 08:02:58 +02:00
Greg Landrum
45b9aef28b clang-tidy modernize-use-default-member-init and modernize-use-emplace (#3190)
* run clang-tidy with modernize-use-default-member-init

* results from modernize-use-emplace

* one uniform initialization per line
otherwise SWIG is unhappy

Co-authored-by: Brian Kelley <fustigator@gmail.com>
2020-05-28 09:07:58 +02:00
Eisuke Kawashima
e86e2c1d5d Modernization: use nullptr (#3143) 2020-05-25 09:40:01 +02:00
Eisuke Kawashima
dc7cc84a0c Fix typo [ci skip] 2019-10-17 17:45:50 +09: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
Ric
6c619f6235 Added exports (#2242) 2019-01-25 04:38:13 +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
Dan N
eaa44b40c2 Enhanced stereo read/write support in SDF files. (#2022)
* add a couple test files

* backup

* first pass at some theory documentatin

* it's a draft

* Update enhanced stereochemistry documentation

Adds initial target use case and caveats about the tentative
nature of the current implementation.

* Support read/write of molfile enhanced stereochemistry

This includes reading and writing of enhanced stereochemistry
from v3000 molfiles (sdf). Enhanced stereochemistry encodes
the relative configuration of stereocenters, allowing
representation of racemic mixtures and compounds with
unknown absolute stereochemistry.

It does not include:
* Python wrapping
* invalidation of the enhanced stereochemistry
* use of enhanced stereochemistry in search
* depiction of enhanced stereochemistry.

* Update to reflect changes from #1971

* change names of enum elements to allow compilation in VS2017

I think it's also clearer to do things this way

* Addressed most review comments.

* Run missed test "testEnhancedStereoChemistry"
* In tests, added size checks to group equality checks
* Updated copyright statements
* Deleted mol created for a test
* Use perfect forwarding in RWMol::setStereoGroups()
* use references for stereo groups that are checked in write and pickle
* Updated stereogroup.h in hopes of fixing compilation on Windows.
* clang-format

* try allowing a switch to boost regex and requiring it for g++-4.8

* do a better job of that

* typo

* Code review comments. Updated Copyright notice.

* When an atom is deleted, delete stereo groups containing it.

Also updates StereoGroup toUse accessors instead of
constant member attributes. This allows move of StereoGroups.

* RDKit style guide

* Add header required on Windows.

* get the SWIG wrappers to build
2018-09-26 15:44:23 +02:00
Greg Landrum
2738c35178 Fixes #1903 (#1971)
* Fixes #1903

* update SWIG bindings too
2018-07-25 09:14:17 +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
0c530637f2 Stop dereferencing end() iterators (#1748)
* cleanup the build requirements for test-valgrind

* cleanup a recently added test

* the new iterators would dereference end() iterators. Fix that.
2018-02-22 03:43:28 +01:00
Greg Landrum
39ee6966fb new examples for looping over atom neighbors and bonds (#1709) 2018-01-09 12:22:38 -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
Brian Kelley
0a871bd72e Dev/modern cxx ranges (#1701)
Enable range-based for loops for molecules
2018-01-05 06:09:51 +00:00
Greg Landrum
bbd615497a Add a MolBundle class (#1537)
* very basics

* add the version to get all matches

* better exceptions, including tests

* documentation and actually add the test code

* responses to review
2017-09-11 13:04:58 -04:00
Brian Kelley
08be8d097e Removes exponetial numBonds behavior (#1154)
* Removes exponetial numBonds behavior

* Removes accidentally commited Get/SetName
2016-11-12 16:05:06 +01:00
Brian Kelley
2debdfde0d Adds RDAny (smaller generic holder) Updates all used dictionaries (#896)
* Adds RDAny (smaller generic holder) Updates all used dictionaries

This is an API compliant version of the current rdany system,
but uses a lot less memory in practice.

* Removes code duplication

* Converts CHECK_INVARIANT to TEST_ASSERT

* Fixes DoubleTag issue

* Adds Bool to DoubleMagic implementation

* Removes reference to property pickler
2016-05-29 17:04:21 +01:00
Greg Landrum
d018da2dec Fixes #760 2016-03-23 13:04:41 +01:00
kelley
3cca9298db Adds overloads to properly convert to the unsigned int API calls 2015-11-29 17:53:20 -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
Greg Landrum
b78bb40ca5 Fixes #384 2015-03-30 07:20:24 +02: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
Nadine Schneider
0bbf3ec79b Add function to test if UpdatePropertyCache is necessary 2014-12-19 13:59:42 +01:00
Greg Landrum
9f4471f872 more on #204
A few other cleanups
2014-02-06 06:43:28 +01:00
Greg Landrum
387406f657 ongoing optimization work 2014-02-05 04:22:59 +01:00
Greg Landrum
8076fefc17 add MatchingAtomIterator to C++ 2013-12-16 05:24:19 +01:00
Greg Landrum
932d6606d5 typo fix 2013-12-14 10:41:25 +01:00
Greg Landrum
9dca8636b7 Fixes #175 2013-12-07 08:26:58 +01:00
Greg Landrum
b5fe1f3f8c add return vals for getProps on ROMol, Atom, and Bond;
use a variable to store computed prop names
2013-07-20 06:07:19 -04:00
Greg Landrum
8d9fd053b2 fix and test issue 256;
this is a change that affects backwards compatibility.
2012-10-08 03:18:05 +00:00
Greg Landrum
f3fbef45c5 update copyright statements 2010-09-26 17:04:37 +00:00
Greg Landrum
116c036c07 doc updates for writers to indicate that "-" writes to stdout;
rename computedProps property to __computedProps
2010-09-19 13:13:10 +00:00