Commit Graph

210 Commits

Author SHA1 Message Date
Brian Kelley
b417465e93 Adds MolToCDXMLBlock to FileParsers (#9291)
* Adds MolToCDXMLBlock to FileParsers

* Simplified code, removed warning

* Fix C# wrapper for MolToCDX

* Add C# test, fix cscode in swig

* Fix typo in tests

* Set default format to CDXML for MolToCDXML

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

* Add CDXML writer smoke tests

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-05-29 05:36:35 +02:00
Ricardo Rodriguez
d5aa90e18f Fix for issue #8965 (#8968)
* add a test

* change stereo bond canonicalization

* update canonicalization watch test with fixed cases

* make canonicalization test stricter (compare CIP codes)

* add reverse symmetry condition

* rewrite double bond canonicalization code

* update tests

* fix multiline comment

* update java tests

* update python test

* nix switchBondDir (unused)

* fix and rename flipBondDir

* refactor comment

* fix shadowed var name, casting

* fix neighbor sorting

* make seen_bonds a vector

* abstract setDirectionFromNeighboringBond

* handle both sides of the bond have directions

* move getNeighboringStereoBond

* check seen_bonds after popping connectedBondsQ

* use references for arguments

* add release note

* add example required by Dan

* add example requested by Dan
2026-02-26 08:58:36 +01:00
Greg Landrum
8fc241495c Fixes #9107 (#9111)
* Fixes #9107

always include std_unique_ptr.i when using modern SWIG

* allow java tests to build without chemdraw support
2026-02-13 14:11:10 -05:00
Brian Kelley
70540c2eed Add extract mol fragment api (#8811)
* Create a function to extract some specified atoms from a ROMol as a new ROMol by creating new graph (#8742)

This adds a new api, `RDKit::MolOps::ExtractMolFragment`, to allow efficient
extractions of mol fragments from large mols. Compared to the approach where
we delete "unwanted" atoms/bonds from the input mol, this api is faster for
small mols (about 2x faster) and at least 3x faster for big mols
(was 10x faster for "CCC"*1000).

* clang-format

* review comments

* cleanup

* Consolidate copying subsets of molecules

* Readd missing tests

* Update comment to restart build

* Remove missing test

* Remove debugging comment, fix warnings

* Fix warnings on gcc11

* Add docs

* Make vector<bool> dynamic_bitset<>

* Update copyright

* Add swig wrappers

* Use new designated constructor API

* Fix windows builds

* Change enum values from unsigned int to integer

* Fix unsigned int variable

* Update Code/GraphMol/Wrap/test_subset.py

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

* Update Code/GraphMol/Subset.cpp

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

* Update Code/JavaWrappers/gmwrapper/src-test/org/RDKit/ChemTransformsTests.java

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

* Reponse to review

* Fix documentation

* Remove comments

* Remove unnecessary comments

* Fix one liners

* Change assertion to be clearer (and not one-liners)

* Run clang-format

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Hussein Faara <hussein.faara@schrodinger.com>
Co-authored-by: Brian Kelley <bkelley@glysade.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-12-09 15:06:29 +01:00
tadhurst-cdd
f00a8cbb4c ScsrHbondMrvError (#8646)
* fix MRV for Hbonds

* add test file

* add test file

* enforce chirality in DistGeom catch test

* Added test for correct hbond retention

* removed debug print statement

* retrigger checks

* testing  java AromaticTests

* testing java aromaticTests

* removed testing code
2025-09-29 17:30:50 +02:00
Brian Kelley
bf35a4204e Fix non matching if(x) end(x) statement (#8769) 2025-09-12 11:08:16 -04:00
Brian Kelley
cf269aa813 Expose CDX support to FileParsers and ChemDraw to SWIG (#8681)
* Fist pass at CDX support

* Enable CDX support for reading (also) in the CDXMLParser API

* Add cdxml test files

* Update swig wrappers for CDXMLFormat and Parameters

* Add constructor to ChemDrawParserParams

* Add Java SWIG support for ChemDraw

* Add chemdraw define to rdconfig

* Add missing chemdraw deps

* Remove direct expat link

* Fix Java linkages for ChemDraw

* Remove bad merge code

* Remove bad merge code

* Fix csharp builds

* Add sniffer for the ChemDraw DataStream

* Include filesystem

* Fix test on windows

* Add more CDX tests

* Ensure streams are open in binary mode to support CDX on windows

* Fix text to show that a Block is the text input, not a file

* Fix CSharp test

* Disable CDX tests when not building chemdraw

* Turn back on chemdraw

* Response to review

* Turn off chemdraw support for the limited external test

---------

Co-authored-by: Brian Kelley <bkelley@glysade.com>
2025-08-29 04:39:22 +02:00
Paolo Tosco
42a2874045 - expose the onlyWedgeFlags parameter to SWIG ClearSingleBondDirFlags (#8600)
- exercise the flag through a unit test

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-06-25 09:24:10 +02:00
Greg Landrum
32608ae0b4 Atoms bonded to metal atoms should always have their H counts explicit in SMILES (#8318)
* refactor the code to determine whether or not an atom is in brackets

* move the definition of isMetal to QueryOps

* atoms bound to metals in SMILES should always be in square brackets

Implementation and some test updates

needs confirmation that all of tests run

* basic tests pass

* java tests pass

* update js tests

* doc updates

* Update Code/GraphMol/catch_graphmol.cpp

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

* Update Code/GraphMol/SmilesParse/test.cpp

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

* finish fixing tests

* bump yaehmop version to allow compilation to work

---------

Co-authored-by: Ricardo Rodriguez <ricrogz@users.noreply.github.com>
2025-03-29 07:26:03 +01:00
Greg Landrum
fa048eacc5 Replace GetImplicitValence() and GetExplicitValence() with GetValence() (#7926) 2025-01-28 21:09:03 +01:00
Greg Landrum
162fb9a7ec some cmake cleanups (#8171)
* Fixes #8139

* Fixes #8138
2025-01-15 16:19:48 +01:00
Paolo Tosco
fc6e37d11e fix #8019 (#8020)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-11-20 09:09:56 +01:00
Paolo Tosco
511d4d941a Fixes a regression introduced in #7582 which made all SWIG enums become type-unsafe (#7972)
* fixes a regression introduced in #7582 which made all SWIG enums become type-unsafe

* fix also PipelineStrage asserts

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-10-30 06:08:14 +01:00
Riccardo Vianello
3f7caf0147 Extend RDKit::MolStandardize with a validation and standardization Pipeline (#7582)
* Extend RDKit::MolStandardize with a validation and standardization Pipeline

* suggested changes

* apply clang-format

* apply yapf

* MolStandardize::FeaturesValidation optionally disallow dative bonds

* add allowDativeBondType to MolStandardize::PipelineOptions

* apply clang-format

* make the API of other validation classes more consistent with MolStandardize::FeaturesValidation

* apply clang-format

* PipelineStage to enum class
remove virtual functions from Pipeline class
be explicit about enums

* light refactoring to avoid what I think is an unnecessary call to `parse`

* a bit of modernization

* make the pipeline configurable

* make parse and serialize configurable too

* switch to storing pipeline stages using uints

* add a simple test for providing a pipeline

* update pointer alignment for clang-format

* test modifying the parser and serializer

* update swig requirement

* changes in response to review

* changes in response to review

* rename PipelineResult's *MolBlock members to *MolData

* upgrade swig to 4.2 in the CI environments

* add a few missing export directives

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-07-30 17:09:16 +02:00
Greg Landrum
724716b2c6 Switch to isoelectronic valence model (#7491)
* change valence model to use isolobal analogy

Remove support for five-coordinate C+ and, by analogy, five-coordinate N+2

Removes support for charge states that take atoms past the end of the periodic table
  i.e. [Lv-4] is no longer supported

* update the tests for that

* remove valence state of 6 for Al

* fix representation of phosphate in the mol2 parser

this is a correction of what was done during #5973

* cleanup the exceptions for P, S, As, and Se

* drop valence states:

Si 6, P 7, As 7

* a couple of additional changes from #7397

* update java tests

* fix an inconsistency: Rb now supports valence -1

* documentation

* - replace operator[] with at() for bounds check
- extract some code into a function to avoid duplication
- use TAB as separator throughout in the periodic table data for consistency

* removing the .at() usage

We know that these vectors aren't empty, so there's no need for the bounds check.

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-06-25 15:38:49 +02:00
Paolo Tosco
0edde326ac - Restore mol writing functions in the RDKFuncs module (#7544)
- Add a couple of tests to avoid similar regressions in the future

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-06-21 05:51:18 +02:00
Greg Landrum
18eb648d56 Expose the property pickle options to SWIG (#7448)
* support pickle params in SWIG wrappers
csharp tests need to be tested

* make that work with csharp too
2024-05-24 07:37:06 +02:00
Gareth Jones
930c7d6345 Handle query atoms and bonds in SWIG wrappers (#7431)
* Query atom information in swig

* Atom query swig wrapping working

* SWIG wrapper for queries

* Add match to QueryAtom and QueryBond

* CShart test

* Added Java test

* Replace var with type for Java test

* Apply suggestions from code review

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

* Update Code/JavaWrappers/Queries.i

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

* Apply suggestions from code review

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

* Get SWIG build working again

* Remove trailing whitespace from Queries.i

* Update Queries.i to use shared_ptr

* small simplification

* remove boost::make_iterator from ROMol.i

* further simplification

---------

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-05-23 07:18:49 +02:00
Gareth Jones
7ec4661f84 C sharp rascal mcs wrapper (#7390)
* Added Wrapper Files

* Addd interface file

* Edited interface file

* Rascal SWIG wrapper finished

* Remove from Java wrapper

* add java wrappers too

* Update GraphMolCSharp.i

* Update Code/JavaWrappers/RascalMCES.i

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

* Update Code/JavaWrappers/RascalMCES.i

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
2024-05-05 05:52:24 +02:00
Riccardo Vianello
25b7dbfb17 fix several warnings originating from the swig wrappers (#7063) 2024-01-30 04:44:43 +01:00
Greg Landrum
f797113a16 cmake cleanup (#6814)
* add RDKIT_CFFI_STATIC option
minimallib cmake cleanup

* clean up a lot of boost::iostreams nonsense

* find_package(boost cleanup

* update the swig wrappers

* updates to psql

* get the Qt demo working again

* fix? coordgen

* only use std::regex in moldraw2d test

this is consistent with the other tests

* cleanup the serialization stuff too
2023-11-10 15:32:54 +01:00
Greg Landrum
908e47cc03 support generalized substructure search in the SubstructLibrary (#6835)
* support generalized substructure search in the SubstructLibrary

* simplify namespaces

* support the new functionality in the swig wrappers

* update mac swig version in CI

* ensure swig4

* switch mac_java ci builds to conda-forge

* change in response to review

* add copy ctor to extendedquerymol

* Back to the way it was
2023-11-01 14:55:28 -04:00
Brian Kelley
cccee15a91 Add hasQueryHs (#6702) 2023-09-15 08:59:56 +02:00
Greg Landrum
a57060225f Fixes #6479 (#6482)
* make sure we don't try to access an SG which no longer exists

* Fixes #6479
updates a bunch of tests to support this

* test ring stereo too

* update expected results from the tests
2023-07-13 19:29:06 +02:00
Paolo Tosco
e9a33b0b23 Expose RDLog to SWIG wrappers (#5749)
* expose RDLog to SWIG wrappers

* - added a SetTee() overload that takes a filename as parameter to simplify redirecting from wrappers that do not have interface with C++ streams (e.g., Java and C#)
- replaced some duplicate code with ClearTee() calls
- replaced RDLogger std::shared_ptr with boost::shared_ptr to make it more easily available from SWIG wrappers
- exposed the RDLogger methods to SWIG wrappers
- added Java test for RDLogger

* this should fix the segfault

* avoid issues on case-insensitive platforms

* here's a solution keeping std:;shared_ptr

* change in response to review

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-04-14 09:26:56 +02:00
Paolo Tosco
ab980bca44 SWIG pickling improvements (and other cleanup) (#6133)
* wip

* - avoid leaking memory after instantiating UChar_Vect
- fix some indentation
- make it easier to read/write pickles as native byte arrays from Java and C#
- add tests

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-03-01 05:00:56 +01:00
Paolo Tosco
3326a620a2 Stereochemistry-related SWIG updates (#6127)
* - expose [sg]etUseLegacyStereo()
- In MolToSmiles() doIsomericSmiles should default to true as in C++ and Python
- added missing parameters to MolToSmiles() and MolToMolBlock()
- added SmilesWriteParams MolToSmiles() overload
- added and updated Java tests

* - changes in response to review
- exposed the same functionality also in MinimalLib and CFFI and added tests

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-02-28 06:44:50 +01:00
Paolo Tosco
0f1b371574 expose some stereochemistry-related functions to SWIG wrappers (#6075)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-02-16 12:28:14 +01:00
Greg Landrum
a8c8e9a8e1 Add canonicalization of stereo groups (enhanced stereo) (#6051)
* add function to canonicalize enhanced stereo representations

* use enhanced stereo in canonicalization

* Fixes #6045
enables the doc tests for EnumerateStereoisomers.py
Re-enables the BRICS tests

* some things work... tests need to be updated

* c++ and python tests pass

* update expected psql results

* run the canonicalization on SMILES generation;
c++ and python tests pass

* cartridge and java tests pass

* update doctests
2023-02-08 04:21:51 +01:00
Greg Landrum
aa336f3faf Get the wrappers working with SWIG 4.0 (#5795)
* extend the allowed valences of the alkali earths
make it possible to have preferred and arbitrary valence states (I thought this already worked)

* backup

* maybe needed

* copy in some swig3 files;
at this point the tests all work

* remove SWIG version lock

* changes in response to review
2022-12-10 07:13:55 +01:00
Greg Landrum
cfe512ea47 Fixes #5704 (#5705)
* Fixes #5704

* update expected java results
2022-11-14 16:59:26 +01:00
Paolo Tosco
b068f51e51 - expose two useful functions from SubtructUtils to SWIG wrappers (getMostSubstitutedCoreMatch, sortMatchesByDegreeOfCoreSubstitution) (#5666)
- add unit test to exercise the above

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-10-19 17:42:04 +02:00
Paolo Tosco
1ec95d2cda Update obsolete SWIG definitions (#5658)
* - updated outdated SWIG definitions of ROMol.generateDepictionMatching2DStructure
- added unit test

* - added strictParsing flag

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-10-18 15:09:29 +02:00
Paolo Tosco
177c09cd6b Expose additional functionality to SWIG wrappers (#5614)
* - setenv() should be defined also for MinGW builds, not just MSVC
- fixed getBestRMS signature (ROMol& should be const)
- expose normalizeDepiction(), straightenDepiction(), getBestRMS(), CalcRMS() and getBestAlignmentTransform() to SWIG wrappers
- expose MolFromSmiles() overload taking SmilesParserParams parameter to SWIG wrappers
- expose DoubleVector class to SWIG wrappers as it is needed by alignment functions
- replace std::string with const std::string& in several SWIG wrapper signatures
- build RDKit2DotNet.dll as a 64-bit library on MinGW 64-bit
- add Java tests for the newly exposed SWIG functions
- fixed inconsistent indentation in Chemv2Tests.java

* changes in response to review

* fix typo

* reverted file committed by mistake

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-10-04 05:04:28 +02:00
Brian Kelley
d1985caaa7 cdxml parser (#5273) 2022-09-28 05:49:27 +02:00
Gareth Jones
b50bce4ed0 Swig MolDraw2D cairo (#5128)
* MolDraw2DCairo working in SWIG

* C# test
2022-03-24 05:54:12 +01:00
Kevin Burk
7bd9f7b434 Remove extra newline from Kekulize error message. (#5022)
* Remove extra newline from Kekulize error message.

* Fix test for exception message.
2022-02-22 04:48:14 +01:00
Kazuya Ujihara
de088cd7dd add JavaGzStreamTests (#4973) 2022-02-01 17:28:36 +01:00
Kazuya Ujihara
0530d468e2 Fix i-files for RDK_USE_BOOST_IOSTREAMS=OFF (#4933)
* fix i-files for RDK_USE_BOOST_IOSTREAMS=OFF

* separate gzstream test

Co-authored-by: Kazuya Ujihara <ujihara@preferred.jp>
2022-01-23 07:06:36 +01:00
Brian Kelley
6a16d64169 Adds KeyFromPropHolder to hold user defined indices (#4571)
* Adds KeyFromPropHolder to hold user defined indices

* Add missing file

* I hate swig.  Had to move keyholder classes into main header file, yuck.
But I added tests, so yay?

* Remove removed dependency

* Fix borked test

* Make consistent getKeys function, fix constness

* Fix overloaded call

* Remove GetKey/s from SubstructLibrary
2021-10-02 08:17:50 +02:00
Paolo Tosco
9cb48cb8ad - enable building Java wrappers with MinGW compilers (#4384) 2021-08-08 05:07:54 +02:00
Paolo Tosco
f09e12765b - remove SWIG kludge on Windows (#4388)
- do not define SWIGWORDSIZE64 on Windows
2021-08-07 06:06:02 +02:00
Brian Kelley
c8aa10c80f Add tautomer query to the substructlibrary (#3808)
* Fixes #3797

* [WIP] Add tautomer queries to the substruct library

* Add TautomerQuery to CMake

* Add missing TautomerQuery functions, python wrapper and tests

* Add python wrappers for Substruct Library Tautomer Queries

* Explictly label non-const pattern function now that we have both

* Use boost::shared_ptr not std::shared_ptr

* Fix java builds

* One more try to fix java builds

* Fix Java Tests

* Run clang format

* Reenable tests

* Fix annoyingly stupid bug and annoying commit of debug code

* Fix documentation

* reenable ifdef threadsafe check

* Throw warning and perform tautomer search instead of bailing with incorrect fingerprints

* Simplfy api with templates

* Fix SubstructLibrary java issues

* minor API cleanup

* simplify the SWIG wrappers

Co-authored-by: Brian Kelley <bkelley@relaytx.com>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2021-03-05 04:56:20 +01:00
Ric
c9199cf1da Address #2753 (#3750)
* add test export heder to gitignore

* define export macros in separate file

* install new header

* patch GA with the new macros

* fix struct declarations

* fix conformerparser exports

* fix MolSGroupParsing ParseV3000Array export

* fix java wrappers

* export exceptions

* remove duplicated exports

* Build RDGeneral exceptions into lib

* export queries, only for *nix

* fix RingDecomposerLib header manipulation

* fix CIP labeler test issues
2021-02-15 14:29:04 +01:00
Steve Roughley
b1fd950eb2 Added getMessage method to exceptions (#3700)
* Added getMessage method to exceptions

* Added test cases to WrapperTests.java

* Corrected typo in test case

* Corrected test case error
2021-01-14 06:53:37 +01:00
Greg Landrum
6805789c71 add support for generating pattern fps for MolBundles (#3665)
* add support for generating pattern fps for MolBundles

* get python wrappers building
2020-12-29 07:33:09 +01:00
Greg Landrum
36dea7d737 support enumerating from lists of enumerators (#3664)
support enumerating all supported operations for a molecule
2020-12-25 05:14:46 +01:00
Eisuke Kawashima
e0b665bfe1 Clean up CMake files (#3417)
* Clean up CMake files

* bump CMake minimum required version to 3.7 to utilize
  [`VERSION_GREATER_EQUAL`](https://cmake.org/cmake/help/v3.7/release/3.7.html#index-0-command:if)
* improve catch-dependency
* fix conditionals
* use early return
* properly use CMake commands

* Apply suggestions from code review

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-11-28 08:00:39 +01:00
Greg Landrum
d2d87909de Add support for abbreviations (#3406)
* support read-only access to cstates from python

* expose GetBrackets

* expose getAttachPoints too

remove vestigial SubstanceGroupCState_VECT

* backup

* backup

* basics working

* backup

* add label_mol_abbreviations

* fix a bug in the chirality handling

* add linkers, needs more testing

* add another peptide test

* sanitize results by default

* just need rings

* getting started with the C++ form of abbreviations

* a bit of error handling

* add findApplicableMatches

* actually apply the abbreviations

* make the getDefault functions more efficient

* add labeling (creating s groups)

* docs

* basic python wrappers (maybe this is enough?)

* add _displayLabel and _displayLabelW support to MolDraw2D
update the docs for that

* use displayLabel props

* add more default abbrevs

* change default linker defns
add parseLinkers convenience function

* make sure attachment point atoms aren't aromatic

* change the color of dummies to be darker gray

* remove python implementation

* support abbreviations in the java wrappers

* add abbreviations to the csharp wrappers

* add abbreviations to the js wrappers

* add molParity to the list of atom props not written to CXSMILES

* support condensing SUP substance groups

* add that to the python wrappers

* Update testAbbreviations.py

* clear ring info if we added it

* document that the molecules with abbreviations removed have not been sanitized
2020-09-28 17:09:46 -04:00
jones-gareth
9a864f4238 Sgroup (#3390)
* Changes to use SubstanceGroups in Java

* Forgot to add SWIG file

* Java test for SubstanceGroup wrappers

* Added RDKit boilerplate
2020-09-09 04:59:08 +02:00