19 Commits

Author SHA1 Message Date
Paolo Tosco
23ffd85f60 - fix #8481 (#8808)
- implement get_v2Kmolblock() in MinimalLib
- add the possibility to specify the MDL version preference as a get_molblock() forceMDLVersion JSON parameter, which is ignored by get_v3Kmolblock() and get_v2Kmolblock()
- changes in response to review

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-09-29 17:33:02 +02:00
Paolo Tosco
9c7ffb33e9 Expose reading/writing PNG metadata to CFFI and MinimalLib (#8381)
* get SynthonSpace.cpp to build also when RDK_USE_BOOST_SERIALIZATION is
not defined

* test should not fail when RDK_USE_BOOST_SERIALIZATION is not defined

* - expose reading/writing PNG metadata to CFFI and MinimalLib
- add relevant CFFI and MinimalLib unit tests
- add RDK_USE_BOOST_PROGRAM_OPTIONS CMake option
- enable using standalone zlib in the absence of boost::iostreams for parsing PNG files
- enable linking against maeparser in the absence of boost::iostreams also on Windows
- enable building RDKit in the absence of boost::program_options

* add check for boost::program_options

* change size_t into std::uint64_t in SearchResults for consistency with doTheSearch() which uses std::uint64_t

* change size_t into std::uint64_t in SearchResults for consistency with
SynthonSpaceSearcher::doTheSearch()

* set CMake policy to allow YAeHMOP to require a version which is not
actually supported

* reverted External/YAeHMOP/CMakeLists.txt to master version

* check if Windows build will work

* fix build

* configure zlib install location

* build zlib dependency

* include zlib header directory

* explicitly set PropertyFlags.AllProps so the test does not fail on
static builds

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-07-23 17:10:38 +02:00
Paolo Tosco
1cd5b24e43 - str_to_c() should initialize len to 0 even if memory allocation fails (#8112)
- str_to_c() should check the ptr returned by malloc for non-nullness before using it
- change has_coords() mol_pkl parameter to const
- use assert.equal in JS tests where possible

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-19 06:04:00 +01:00
Paolo Tosco
a6654c4f8f Make sure that loggers can be enabled, disabled, captured and tee'd from MinimalLib (#7962)
* make sure that loggers can be enabled, disabled, captured and tee'd from MinimalLib without issues

* changes in response to review

* change in response to review

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-12 13:44:33 +01:00
Paolo Tosco
8c1bf34ed7 implemented JSON parsers for SanitizeFlags and RemoveHsParameters for CFFI and MinimalLib (#8000)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-11-16 05:16:25 +01:00
Paolo Tosco
b1d322555b Expose propertyFlags to CFFI and MinimalLib (#7960)
* - added property support to CFFI library
- added propertyFlags JSON parser
- added support for setting propertyFlags to MinimalLib

* added missing files

* fix SWIG builds

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-11-07 06:08:27 +01:00
Andrew Kane
5771d9c181 Add support for building the CFFI lib without InChI (#7698) 2024-08-10 21:16:58 +02:00
Paolo Tosco
2bb8952d7b Added JSON parameters to MinimalLib get_(cx)?sm(ile|art)s() functions (#7194)
* - renamed getParamsFromJSON() to updateSmilesWriteParamsFromJSON() and moved it from the anonymous namespace to the RDKit namespace such that it is publicly available
- implemented updateCXSmilesFieldsAndRestoreBondDirOptionFromJSON()
- added CFFI and JS tests
- get_smiles(), get_smarts(), get_cxsmiles() and get_cxsmarts() are now available in MinimalLib in both CFFI and JS layers and they can be passed JSON parameters
- CFFI get_qmol() now returns NULL if it fails to generate a RWMol rather than returning the "Error!" const char[] string, for consistency with what get_mol() and get_rxn() do. This was documented in release notes

* suggestions

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-04-18 06:28:36 +02:00
Paolo Tosco
80eca32b76 - exposed to CFFI and JS MinimalLib functionality to capture RDKit logs with two modalities: (#6628)
1. tee: the log is captured in a buffer but also sent to the native output channel
  2. capture: the log is captured in a buffer without being sent to the native output channel
- removed duplicate logging_needs_init and needs_init atomic bool variables from cffiwrapper.cpp and consolidated them into a static LoggingFlag d_loggingNeedsInit class variable
- added relevant C and JS tests

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2023-08-22 17:06:43 +02: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
af8c5a0e76 Expose getMolFrags in CFFI and MinimalLib (#5774) 2022-11-25 18:59:09 +01:00
Paolo Tosco
e319617243 - added missing #include that caused the emscripten build to break (#5729)
- removed details from get_maccs_fp calls since there are no adjustable parameters
- exposed get_maccs_fp to JS
- added tests and adjusted existing ones since some deprecated functions were removed and do not need testing anymore

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-11-07 04:41:58 +01:00
Eloy Félix
72e524c775 add MACCS fp to the MinimalLib (#5707)
* add maccs fp to the minilib

* maccs fit in 21 bytes
2022-10-31 06:46:07 +01:00
Paolo Tosco
97bb4a7f37 Improvements to 2D depiction and alignment/RMSD calculation (#5598)
* update AvalonTools to version 2.0.1

* Improvements to 2D depiction and alignment/RMSD calculation
- Refactored the straightenDepiction code which is now much simpler and more readable and supports a minimizeRotation parameter
- added C++, Python and JS tests for the new minimizeRotation parameter
- refactored tests to use CalcRMS rather than an internal implementation to compute RMS deviations
- Removed duplicated code in CalcRMS() and getBestRMS() and made their APIs consistent with respect to supported parameters
  IMPORTANT NOTE: for backwards compatibility I set the CalcRMS() default for the  new symmetrizeConjugatedTerminalGroups
  to false as this parameter was not originally supported. @greg: I would be very much in favor of setting this to true instead
  if you agree, even though it might change results for existing scripts, as I think it is a much more sensible default.
- Improved documentation to clarify the difference between CalcRMS() and getBestRMS()
- Added unit tests for CalcRMS() as there was none previously
- Added tests for the additional CalcRMS() and getBestRMS() parameters
- Added a new getBestAlignmentTransform() function
- The CFFI function set_2d_coords_aligned() now returns the matching atoms similarly to the C++, Python and JS counterparts
  IMPORTANT NOTE: this required an API change for the additional char ** parameter used to return the match.
  Existing code using set_2d_coords_aligned() will fail to compile and will require a last NULL parameter to be added to compile again
- Removed duplicated code between CFFI set_2d_coords_aligned() and JS generate_aligned_coords()
- Added has_2d_coords() to the CFFI library
- generate_aligned_coords() now supports JSON parameters and the previous versions are deprecated
- set_2d_coords_aligned() and generate_aligned_coords() both support an alignOnly parameter (which defaults to false).
  If set to true, rather than re-generating a fresh 2D layout around templateMol, the existing coordinates (if any) are simply aligned
  to the provided templateMol. If the molecule has no coordinates, a set of 2D coordinates is generated independently of templateMol
  and then aligned to the provided templateMol
- avoid that when acceptFailure is false set_2d_coords_aligned() and generate_aligned_coords() overwrite existing coordinates

* - explicitly link testDepictor to MolAlign library

* - add MolAlign dependency to testDepictor (rather than to the catch test as in the previous commit)
- add a couple of tweaks

* suppress compiler warnings (1st pass)

* warnings: 2nd pass

* warnings: 3rd pass

* - alignOnly mode should also support allowRGroups

* - fixed C++ build
- added tests for allowRGroups+alignOnly combination

* changes in response to review

* added an entry to backward incompatible changes regarding set_2d_coords_aligned()

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-10-02 06:24:01 +02:00
Paolo Tosco
948f7d231a Expose reaction drawing and additional FPs in MinimalLib (#5277)
* - exposed reaction drawing in MinimalLib
- fixed a typo in the error message "JSON doesn't contain 'atoms' field, or it is not an array"
- replaced RapidJson HasMember() with FindMember() to avoid a duplicate lookup in case the member exists and can be accessed
- some cosmetic style changes (avoid multiple variable declarations on a single line, use curly bracket also for one-liner if clauses, use auto where possible)
- capitalized "greg Landrum" to "Greg Landrum" (well deserved)
- exposed other FPs in addition to Morgan and Pattern FPs in MinimalLib
- added relevant tests

* - update CXSMARTS test in MinimalLib

* Changes in response to review:
- exposed reaction drawing functionality to CFFI and added relevant tests
- refactored fingerprint code to use JSON details and deprecated the Morgan/pattern fingerprint functions that used multiple parameters
- all fingerprints are now exposed to both JS and CFFI with no code duplication
- fixed a potential crash bug in the CFFI library where calling get_morgan_fp(), get_rdkit_fp() or get_pattern_fp with a NULL mol_pkl would result in dereferencing a nullptr

* removed debugging printouts committed accidentally

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-09-06 14:27:10 +02:00
Eisuke Kawashima
b9a5be5a2d miscellaneous updates (#4284)
* Remove accidentally tracked files and unset x flag

* Ignore ComicNeue

* Unify test tag to `reader`

* Trivial destructors

* Bump CMAKE_CXX_STANDARD to 14 (#4165)
2021-07-13 06:57:29 +02:00
Paolo Tosco
106e9f7c37 Normalize line endings in source code files (#4104)
* set all source code files to have native line endings

* normalized all source code line endings

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-05-13 14:31:39 +02:00
Greg Landrum
158fe71ff2 Add some MolStandardize functionality to the CFFI library (#4062)
* support CleanupParameters from JSON

* add standardization to cffi

* remove a bunch of repeated code from the new stuff
2021-04-22 05:23:25 +02:00
Greg Landrum
f829c877d8 MinimalLib: add CFFI interface (#4018)
* hello world works

* more

* more
minimallib needs to be tested

* parse substructure parameters from JSON

* add substruct search and parameters

* add descriptors

* register more descriptors

* fingerprints, first pass

* stop outputting tiny coord vals

* support generating 2d coords

* coordgen testing

* return nulls

* initial 3d support; add/removeHs; cleanup

* Embedding parameters from JSON

* update

* pattern fp, fps as bytes

* use json to configure MFP

* use json to configure rdkit and pattern fps

* aligned 2d coords

* parsing options

* options for writers

* rename remove_hs

* get this working on windows (kind of)

* silence some msvc warnings

* cmake updates

* update python tests

* add the CFFI code to CI builds

* cleanup line ending mess?

* a couple small fixes

* make this work with URF

* support coordMap in the 3D coordinate generation

* updates in response to review
2021-04-15 21:33:52 +02:00