45 Commits

Author SHA1 Message Date
Raul Sofia
372fbad131 Extended fix for #9101 (#9255)
* fix extended boundary issue (3 mols)

* clang pass

* no change. retrigger CI for failed java test

there's a failing java test that seems to be failing by chance rather than by changes, as it depends on rng. this is just to retrigger the CI pipeline to confirm this

* no change. retrigger the CI (yet again)

* raw strings and removed garbage collector
2026-05-06 06:10:37 +02:00
Greg Landrum
6d75052459 Support using iterators with MolSuppliers (#9230)
* iterators for random-access MolSuppliers
add optional caching to SDMolSupplier

* add support to SmilesMolSupplier too
There is a lot of duplicate code between the random-access suppliers that would be worth trying to remove
but at the moment it looks like it would require multiple inheritance, and I think we want to avoid that

* add input iterators for ForwardSDMolSupplier()

* throw when calling begin() on a used supplier

* switch to use the spaceship operator

* init() should reset the mol cache

* Make SDMolSupplier and SmilesMolSupplier safe for multi-threaded reads

* add benchmarking

* add TDTMolSupplier support
improved testing
add benchmarks for parallel iteration
optional TBB support

* better const handling, add reverse iterators

doesn't look like const_iterator is possible since getting data from the underlyng supplier object is non-const

* improve docs
more usings
add reverse iterator to TDTMolSupplier

* tests only try execution::par when it is there

* fix typo

* more testing/demo

* remove accidentally added files

* review changes

* add default ctors

* disable a false-positive compiler warning
it is stupid to have to do this

---------

Co-authored-by: = <=>
2026-05-05 13:36:15 +02:00
Brian Kelley
ecdf55ac2a Fixes a boundary issue when indexing SDF (#9162)
* Fixes an index boundary error in SDMolSupplier

* Add test data

* Run clang-format

* Update Code/GraphMol/FileParsers/testMolSupplier.cpp

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

* Update Code/GraphMol/Wrap/rough_test.py

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

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2026-03-12 13:58:33 +01:00
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
Raul Sofia
4b92c2fa8c Performance improvement: Implement buffered reading for SDMolSupplier (#9010) 2026-01-10 18:29:56 +01:00
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +02:00
Greg Landrum
3a27ca2910 V2 API for the MolSuppliers (#7168)
* backup

* backup

* backup

* new testing file

* reorder things in the SMILES and SMARTS parser
parameters to allow easier struct initialization

* add v2 of SmilesMolSupplier

v1 is not yet there

* add TDTMolSupplier

add some very basic tests for v1 suppliers

* more progress

* all tests passing

I think all the suppliers are now moved over

* check for maeparser before building the tests

* get SWIG builds working

* changes in response to review
2024-02-29 06:46:56 +01: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
Paolo Tosco
41f3e0c64c Fixes #3517 (#3523)
* fixes #3517

* added test in response to review

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-11-04 12:54:47 +01:00
Brian Kelley
4c1ea25fda Fix a hang when trying to read mols from a directory not a file on linux (#2983)
* Fix a hang when trying to read mols from a directory not a file on linux

* thrown an exception at construction time

* clarify the readme

* update release notes

* Refactor the stream opening and checking code to a common method

Co-authored-by: Brian Kelley <bkelley@relaytx.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-03-09 15:27:58 +01: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
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
Ric
a6b26253ff Fix (most of) mem problems (#2123)
* do not use new on loggers

* del pointers in testDistGeom

* Update Dict hasNonPOD status on bulk update

* delete new Dicts in memtest1.cpp

* fixes in MolSuppliers and testFMCS

* PeriodicTable singleton as unique_ptr

* fix EEM_arrays leak

* fix leaks in testPBF

* fix ParamCollection leak in test UFF

* fix leaks in MMFF

* clear prop dict before read in in pickler

* fix leaks in testFreeSASA

* fix leaks in test3D

* modernize Dict.h & SmilesParse.cpp

* fix leaks in testQuery

* fix leaks in testCrystalFF

* fix leaks in cxsmilesTest

* fix leaks in Catalog & mol cat test

* fix leaks in ShapeUtils & tests

* fix leaks in testSubgraphs1

* fix leaks testFingerprintGenerators

* fix leaks in Catalog/FilterCatalog

* fix leaks in graphmolqueryTest

* these changes reduce bison parse leaks

* fixed leaks in testChirality.cpp

* fix leaks + 2 tests in testMolWriter

* fix 4m leaks in substructLibraryTest

* small improvements to molTautomerTest; still leaks

* fix leaks in testRGroupDecomp

* fix leaks in test; parser still leaks

* fix leaks in itertest

* fix 4m leaks in testDepictor

* fixes in smatest; still leaking due to parser

* fixes in testSLNParse; still leaking due to parser

* flex/bison: always add atoms with ownership; smarts error cleanup

* fix leaks in testReaction

* fix leaks in testSubstructMatch

* fix leaks in resMolSupplierTest

* fix leaks in testChemTransforms + bug in ChemTransforms

* fix leaks in testPickler

* fix leaks in testMolTransform

* fix leaks in testFragCatalog

* fix leak in testSLNParse. Still leaks due to Smiles

* fixed most leaks in testMolSupplier

* pre bison fix

* fix some atom & bond parse problems; others still fail

* bison smiles & smarts, atoms & bonds more or less fixed

* fix leaks in molopstest.cpp

* fix leaks in testFingerprints, MACCS.cpp & AtomPairs.cpp

* fix leaks in moldraw2Dtest1

* fix leaks in testDescriptors

* fix leaks in testInchi

* fix leaks in testUFFForceFieldHelpers

* fix leaks in hanoiTest & new_canon.h

* fix leaks in testMMFFForceField

* fix leaks in graphmolTest1

* fix leaks in testMMFFForceFieldHelpers

* fix leaks in testDistGeomHelpers

* fix leaks in testMolAlign

* initialize occupancy & temp facto with default values

* fix leak in TautomerTransform

* updated suppressions

* fix testStructChecker

* fix logging & py tests

* fix TautomerTransform class/struct issue

* remove misplaced delete in testSLNParse

* deinit in testAvalonLib1

* fix Avalon-triggered(?) bug in StructChecker/Pattern.cpp

* fix random testMolWriter/Supplier fails

- diversify output file names to avoid clashing.
- unify Writers close/destruct behavior.
- flushing/closing in tests.

* use reset in FFs Params.cpp

* comments on testMMFFForceField

* unrequired 'if's added to mol suppliers

* correct cast in FilterCatalog.h

* use unique_ptr in MACCS Patterns

* remove unrequred if in new_canon

* update & move suppressions
2018-10-29 14:33:26 +00: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
e08e0d16d8 first pass, using google style 2015-11-14 14:58:11 +01:00
Paolo Tosco
9a70ce00b8 - changed SDMolSupplier to be tolerant of spurious lines after
a blank line in a property when strictParsing = false; properties
  are truncated after the first blank line. Also spurious lines
  before the first property are tolerated (and ignored)
- added the strictParsing parameter to the setData() method in C++
  and to the SetData method in Python. Previously, when the setData()
  method was invoked, the strictParsing flag could not be set.
  Moreover, df_strictParsing was not initialised , which might result
  in undefined behaviour
- added relevant C++ and Python tests
2015-05-10 22:54:30 +01:00
Greg Landrum
5bffcbd4ad Fixes #392 2014-11-28 06:06:43 +01:00
Greg Landrum
8462195001 fix and test GitHub issue 19 2013-04-21 05:22:57 +00:00
Greg Landrum
bbde03e9d6 fix and test issue 3524949 2012-05-09 03:19:30 +00:00
Greg Landrum
dbd78604c8 fix and test issue 3477283
add a new option for ctab parsing to cause the parser to be less strict about
  errors in the file syntax.
2012-01-22 09:40:54 +00:00
Greg Landrum
839104b2d0 forward progress; basic function is there; tests pass on the mac 2011-11-19 13:20:08 +00:00
Greg Landrum
0797140488 fix a problem with stream state that occurs with g++ 4.6.0 (report and patch from Riccardo V.) 2011-08-15 05:40:34 +00:00
Greg Landrum
3b3d44db16 remove exe property from source files 2011-01-13 04:22:56 +00:00
Greg Landrum
f3fbef45c5 update copyright statements 2010-09-26 17:04:37 +00:00
Greg Landrum
305bf237b4 add the ForwardSDMolSupplier to allow use of gzipped sd files;
remove the long-obsolete SDFileParser stuff.
2009-05-14 18:07:57 +00:00
Greg Landrum
8bdf357e55 make the len() operation of SDMolSuppliers faster; start thinking about making SDView4 useable 2009-04-05 18:45:57 +00:00
Greg Landrum
ca85699bef get this working properly on windows; update the explanatory comment about std::ios_base::binary 2009-01-14 06:06:31 +00:00
Greg Landrum
6e05e3c7c2 update the chirality from 3d stuff a bit and expose it to python; fix a reporting error in SDMolSupplier 2008-07-09 15:43:04 +00:00
Greg Landrum
45be1150f6 support taking streams in ctors for suppliers 2008-07-07 05:29:54 +00:00
Greg Landrum
61b05af6fc Modify suppliers and parsers so that they don't throw
exceptions into python when reading a bad molecule. (Feature
request 1932875)

Modify constructors for both suppliers and parsers so that 
throw BadFileExceptions if they cannot open the file. (Feature
request 1938303)
2008-04-09 03:33:49 +00:00
Greg Landrum
b0f9f42ac7 fix sf.net issue 1904170 (suppliers not resetting properly after running off end 2008-02-28 19:19:04 +00:00
Greg Landrum
4adeb603af fix sf.net issue 1874882
https://sourceforge.net/tracker/index.php?func=detail&aid=1874882&group_id=160139&atid=814650
2008-01-19 10:04:44 +00:00
Greg Landrum
3518e10919 make file parsing more efficient 2007-11-27 18:01:16 +00:00
Greg Landrum
f1ef2a593c add getItemText() method to the suppliers and expose this in the wrappers 2007-10-09 05:22:26 +00:00
Greg Landrum
c75aa34b4b - Expand availability of the protrude distance measure.
- Remove a few confusing and unnecessary SD file handling functions from FileParsers (better functionality is available in the SDMolSupplier)
- Support not removing Hs in the Mol file handlers (C++ and Python)
2007-08-11 16:22:42 +00:00
Greg Landrum
47c222e3d5 clear up some compiler warnings 2007-05-04 04:59:30 +00:00
Greg Landrum
b176a0dc70 working towards a fix for Issue 1695221 (http://sourceforge.net/tracker/index.php?func=detail&aid=1695221&group_id=160139&atid=814650) 2007-04-27 05:21:23 +00:00
Greg Landrum
7407f8cfc8 this is a partial fix for issue 1702647, TDTMolSuppliers still need to be tested and probably fixed
http://sourceforge.net/tracker/index.php?func=detail&aid=1702647&group_id=160139&atid=814650
2007-04-18 17:34:36 +00:00
Greg Landrum
cf1fa4fb06 minor cleanups... this seems to fix the memory corruption problems I found earlier, but there's no particular reason whey it should.
http://sourceforge.net/tracker/index.php?func=detail&aid=1607290&group_id=160139&atid=814650
2006-12-17 15:33:57 +00:00
Greg Landrum
6f92ce7bdb add setStreamIndices() to SDMolSupplier 2006-10-24 04:07:08 +00:00
Greg Landrum
6615ae5a01 SDMolSupplier: don't throw on errors parsing molecules. This allows the parsing of further mols to continue.
Conformer.cpp: make sure we don't ask for space for zero atoms.

Kekulize.cpp: don't complain about marked bonds if we aren't removing markers.

molopstest.cpp: bad smiles corrected in one test.exe

ROMol.cpp, RWMol.cpp: extra preconditions added (should have been there all along)

Wrap/MolOps.cpp: docs for replacesubstructs.
2006-09-18 05:21:39 +00:00
Greg Landrum
5d03333c22 setup svn keywords (should have done this before import... grn) 2006-05-06 22:54:39 +00:00
Greg Landrum
75a79b6327 initial import 2006-05-06 22:20:08 +00:00