Commit Graph

183 Commits

Author SHA1 Message Date
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
Ric
6b1a2eead3 Turn MRV_COORDINATE_BOND_TYPE data Substance Groups into coordinate bonds (#4299)
* add test

* add fix

* document wrapper

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-07-07 06:13:17 +02:00
Greg Landrum
2f8079f563 Fixes #4256 (#4269)
* Fixes #4256

* the V2000 part of the fix
2021-07-01 15:15:22 +02:00
Greg Landrum
5d0eb77c65 allow more recoverable SGroup errors when strictParsing=false (#4210) 2021-06-07 15:39:49 +02:00
Greg Landrum
c02e53d7aa Fixes #4099 (#4132)
Fixes #4131
2021-05-12 12:40:17 -04:00
Greg Landrum
193f27730c make sure atom and bond bookmarks survive replaceAtom/Bond (#4033)
* make sure atom and bond bookmarks survive replaceAtom/Bond

* fixes oss-fuzz #30572

* fix possible memory-access error in error reporting

* more defensive deserialization

* switch that recursive smarts error handling to not use an exception
2021-04-16 04:54:09 +02:00
Greg Landrum
0f6da8d3b6 allow short atom lines in mol blocks when strictParsing is disabled (#3961) 2021-03-23 04:42:43 +01:00
Greg Landrum
36c7c04344 basic h bond support (#3871) 2021-03-06 09:39:13 -05: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
7564a4af8b Merge branch 'feat/bond_query_drawing' of https://github.com/greglandrum/rdkit into greglandrum-feat/bond_query_drawing 2020-12-17 06:43:49 +01:00
Greg Landrum
b82b3c0695 Fixes #3620 (#3621) 2020-12-09 04:37:13 +01:00
greg landrum
55bc8d7ec1 backup 2020-12-08 15:39:45 +01:00
Paolo Tosco
7d0d7df5f0 Fixes a number of issues flagged by clang (#3498)
* - fixes a number of issues flagged by clang

* - removed commented line
2020-10-15 15:03:34 +02:00
Greg Landrum
819e46ed1e Fixes #3413 (#3414) 2020-09-18 05:44:24 +02:00
Paolo Tosco
a9da05570e Fixes a couple of query-related bugs (#3398)
* - fixes a bug with the MDL MolParser (M  ALS queries clobber previously existing queries)
- fixes a regression introduced by #3389 (duplicate formal charge queries may arise)

* changes in response to review

* forgot to commit
2020-09-17 08:16:43 +02:00
Greg Landrum
02d76edc09 more bug fixes and cleanups from fuzz testing (#3339)
* ossfuzz #22301

* ossfuzz 22307

* memory leak when failing cxsmiles

* MolPickler things found by ossfuzz

* changes in response to review
2020-08-17 06:51:24 +02:00
Greg Landrum
f14f8a60de Expanded support for CXSMILES features (#3292)
* move replaceAtomWithQueryAtom() and completeMolQueries() to QueryOps namespace

* support ring bonds from cxsmiles

* add a test that is still failing

* update nonHydrogenDegree query, add SMARTS extension for that

* some cleanup

* unsaturation and substitution count

* fix typo in test

* update expected result

* add linknodes

* add variable attachment points

* improve documentation of supported cxsmiles features

* clarifying the docs

* support leaving out the outer atoms in LN specs
2020-07-25 05:06:08 +02:00
Greg Landrum
a9010da8a4 Small bug fixes and cleanups from fuzz testing (#3299)
* fix ossfuzz issue 24074

* fix ossfuzz issue 23896

* switch to throw exceptions when reading ints/floats

* remove extraneous benchmarking code

* change type of AH query

* confirm an invariant while finding rings

* no sense in adding these tests to github

* switch to use fail() instead of failbit
switch to acceptSpaces by default
2020-07-22 16:57:31 +02:00
Greg Landrum
1630540ef0 Add cxsmiles query atoms to CTAB parsers and writers (#3261)
* allow CXSMILES generic query atoms to be parsed from mol;
need more tests here

* remove vestigial directory

* Add d_queryType to Query
This opens up additional flexibility with customizing the way queries are handled
Also includes some assorted cleanups in the Query directory

* remove the MolFileSymbol hack added in #3235
We don't need it anymore

* Add support for additional ChemAxon extensions and document them

Signed-off-by: greg landrum <greg.landrum@gmail.com>

* bump pickle version

* add an additional test
2020-07-03 12:51:19 -04:00
Greg Landrum
cc4b726c55 LINKNODEs are ignored by the CTAB parsers (#3247)
* make sure LINKNODE is saved from v3k mol files
v2k still needs work since the format is different

* write v3k linknodes

* support reading V2000 mol blocks too
2020-06-23 12:56:32 -04:00
Greg Landrum
b55376f284 Adds more options to adjustQueryProperties (#3235)
* add documentation

* backup

* first pass at 5-rings working

* add a static method to initialize an empty parameter object

* expose static method to python

* additional testing

* support the single bond adjustments

* cleanup

* preserve the symbol used in the query from a CTAB

* support the way the MDL code adjusts five-ring aromaticity in query rings

* in-code documentation

* while we're at it, cleanup the way Q and A atoms are handled in the v3k parser

* changes in response to review

* make this C++14 again.

* change in response to review
2020-06-22 09:17:50 -04:00
Greg Landrum
cc05e57180 fixes #3207 (#3221)
* fixes #3207

* changes in response to review

* logic problem
2020-06-16 04:34:51 +02:00
Eisuke Kawashima
75f03412ef Modernize deprecated header inclusion (#3137) 2020-05-04 10:40:57 +02:00
Greg Landrum
5712176605 Implement the two deprecations that were planned for the 2020.09 release cycle (#3047)
* Deprecation: planned removal of .message() and .getMessage() methods

* Deprecation: planned removal of old MolHash code

* document deprecations

* output the diffs when the psql tests fail

* remove .message() from SWIG wrappers

note that the KeyError doesn't work properly. We should clean up the the exceptions here anyway

* typo
2020-04-01 14:30:07 +02:00
Greg Landrum
2ee798ddca Add support for the rest of the v3000 atom properties (#3007)
* Add convenience functions for generating v3K mol blocks and mol files

* first pass at parsing/writing the remaining atom properties from the CTAB spec

* handle SUBST

* write out the bond props that were being read but not written

* add an additional test

* fix a couple of problems caught in review
2020-03-14 04:58:07 +01:00
Greg Landrum
a7874672bc Merge branch 'feat/github2829' of https://github.com/greglandrum/rdkit into greglandrum-feat/github2829
# Conflicts:
#	Code/GraphMol/AdjustQuery.cpp
#	Code/GraphMol/FileParsers/file_parsers_catch.cpp
#	Code/GraphMol/MolOps.h
#	Code/GraphMol/catch_graphmol.cpp
2020-02-04 02:42:31 +01:00
Greg Landrum
abadada1a2 Parse and handle the stereoCare or STBOX flags in CTABs (#2917)
* get fileparsers catch tests building faster
should use this same approach across all of the catch2 tests

* Fixes #2916

* support parsing of STBOX for atoms and bonds in v3K mol files
add molStereoCare to common_properties

STBOX is translated to the molStereoCare property

* add stereocare support to adjustQueryProperties
make building the catch2 tests faster for the GraphMol package

* copy in AdjustQueryParameters JSON parsing from adapter.cpp
(That still needs to be ported to use the new code)

* get the cartridge using the new parsing code

* update test to reflect new parser behavior

* add a v2000 test

* changes in response to review
2020-02-03 15:55:57 -05:00
Greg Landrum
a0dd56ddee remove the MRV_IMPLICIT_H groups after processing them 2020-02-02 06:12:40 +01:00
Greg Landrum
1cea3800c4 Fixes #2829 2020-01-30 16:56:18 +01:00
Greg Landrum
c873ce9535 support parsing of STBOX for atoms and bonds in v3K mol files
add molStereoCare to common_properties

STBOX is translated to the molStereoCare property
2020-01-29 09:51:23 +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
e948a06dad make "R" in CTABs an AtomNull query (#2528)
This comes out of the discussion around #2527
2019-07-15 19:53:53 -04: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
Brian Kelley
3b4326c1c7 Add tests for #1868 (#2497)
* Add tests for #1868

* Fix github bug number

* Fix #2 for correcting issue number

* Fixes #1868

The primary problem here was that when v3K reactions were being processed,
a bunch of "finalization" steps were being skipped for the reactants and products.
This remedies that.

* update the python test so that it tests the actual problem
2019-07-12 05:51:16 +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
Ric
be3170d0d5 Mem errors clean up (#2305)
* fix test leaks

* fix "invalid read" when casting Query to EqualityQuery

* fix error cleanup in SMILES/SMARTS parsers

* SMILES/SMARTS parser fix updated *.cmake

* fix error cleanup in SLN parser

* SLN parser updated *.cmake

* updated suppressions

* update loop in sln bison
2019-03-08 05:39:59 +01: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