* - When depictions are made using the useMolBlockWedging flag, make sure that kekulization is done after original wedging has been applied to reduce the odds that bond wedges are placed on double bonds
- Refactored MinimalLib code to avoid code duplication
- get_molblock() should reapplyMolBlockWedging on a copy of the passed molecule rather than on the original
- Added unit tests
* Update Code/MinimalLib/jswrapper.cpp
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
---------
Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
* - 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>
* - fix#7157
- add the assignCIPLabels flag to MinimalLib's mol_from_input()
- added cffi and JS tests
- refactored process_details(), process_mol_details() and process_rxn_details() to take a struct reference as parameter rather than a long list of parameters
- this also allowed to get rid of one of the ugly GET_JSON macros
- exposed panelWidth, panelHeight and noFreetype (the latter is useful for testing)
- made width and height to default to -1 in mol_to_svg since we now support flexicanvas
* added a bunch of assignments I'd forgotten in the deprecated process_mol_details() overload
* MSVC does not like inner functions
* updated docstrings
---------
Co-authored-by: ptosco <paolo.tosco@novartis.com>
* MMPA functions exposure
* Minilib exposure: mmp
* minilib: mmpa - test added
* minilib: mmpa - failing test added
* - MolList should return null when the corresponding ROMOL_SPTR is a nullptr
- changed first into cores
- changed second into sidechains
- renamed some functions and constants
* - made JSMolList::at() and JSMolList::pop() robust against attempting to dereference null ROMOL_SPTR
- added tests for the above
* Update Code/MinimalLib/minilib.h
Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
* changes after review
* Update Code/MinimalLib/minilib.cpp
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
---------
Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
* - added a convenience function to relabel R-groups in a chemist-friendly fashion
- exposed functionality to MinimalLib through a JSON option at molecule creation time
- added relevant unit tests
* changes in response to review
* added missing library
* fixed Python test
---------
Co-authored-by: ptosco <paolo.tosco@novartis.com>
* - added StoreAll to parseMCSParametersJSON()
- added get_mcs() to MinimalLib which returns results as JSON
- added tests for get_mcs()
* added test
* changes in response to review
---------
Co-authored-by: ptosco <paolo.tosco@novartis.com>
* Revert "Revert "Removed some code duplication between Depictor.cpp and common.h (#6368)" (#6797)"
This reverts commit 824616c5b9.
* security blanket: add back tests of the current usage pattern
* - fixed bug in get_sss_json() (#6806)
- added unit test for the above
Co-authored-by: ptosco <paolo.tosco@novartis.com>
---------
Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true) to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications
* Fix chirality handling when the chiral atom is the first one in a SMARTS (#6730)
* Set _SmilesStart when parsing SMARTS.
* SmartsWriter should also invert first atoms, like SMILES.
* Update test cases now these SMILES match themselves as SMARTS.
* rerun bison
* cleanup a possible repeated define
* When an atom moves from the first to second position winding should flip in SMARTS (i.e. same as SMILES).
---------
Co-authored-by: greg landrum <greg.landrum@gmail.com>
* Some small cleanups from the UGM Hackathon (#6744)
* move definition of a couple global constants from a .h to a .cpp
* careful removal of some redundant atom PRECONDITIONS
* careful remove of some redundant ROMol PRECONDITIONS
a bit of additional cleanup
* optimization masquerading as modernization
* some more tidying
* a bit more atom cleanup
* change in response to review
* Fixes#6756 (#6780)
* update release notes and cmakelists for beta (#6788)
* move problematic functions to Chirality namespace
* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true) to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications
* move problematic functions to Chirality namespace
* added missing dependency
* let's check what is going wrong
* CoordGen tests should not run if CoordGen support is not available in the build
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
Co-authored-by: John Mayfield <john@nextmovesoftware.com>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
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>
- setAromaticity (defaults to true)
- fastFindRings (defaults to true; only used when sanitize=false)
- assignStereo (defaults to true)
These options avoid doing unnecessary work when the molecule is only used for specific purposes (e.g., computing FPs or doing substructure searches)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - deprecate JSMol::is_valid() and JSReaction::is_valid()
- methods returning JSMol and JSReaction objects now return nullptr upon failure rather than an invalid object
* changes in response to review
* unexposed JSReaction::is_valid given it was not exposed before this PR
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* reverted all changes that did not really belong to this PR
* I had forgotten ChemReactions_static
* changes in response to review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - enable using JSSubstructLibrary with no fp by passing num_bits 0
- get rid of dynamic_cast which never looks great
- add unit tests for no-fingerprint JSSubstructLibrary
* change in response to review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - implemented in-place aromatisation/kekulisation
- avoid that attempting to aromatise a query mol throws an exception due calcImplicitValence() not having been called
- add unit tests for the above
* change in response to review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* Fixes some issues in the SubstructLibrary JS implementation
- FastFindRings() was not being called
- a count_matches() overload was missing
- count_matches() was ignoring the numThreads parameter
- adding a PatternFingerprintMol created with a certain number of bits to the PatternHolder will *not* work: one needs to create the PatternHolder with the desired number of bits, and then call makeFingerprint
- improved tests to make sure the library actually behaves as expected
* added functionality to serialize/deserialize a JSSubstructLibrary and get matches as UInt32Array
* I had forgotten to run clang-format
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* straightenDepiction should not consider 0-degree rotations as multiples of 60
* improved JS straightenDepiction test which was a bit silly
* changes in response to review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* avoid that assignStereochemistry() fails when removeHs=true
* changes in response to review
* Remove unused variable declarations
As suggested in the code review
---------
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
* - 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>
* - fix indentation
- fix regex check (which currently always fails)
* wip
* - added clearMolBlockWedgingInfo()
- added invertMolBlockWedgingInfo()
- MinimalLib::generate_aligned_coords() now inverts stereochemistry if a rigid-body alignment transformation caused chiality inversion
- MinimalLib::generate_aligned_coords() now clears stereochemistry if coordinates changed
- added JSMol::clear_prop() to the already existing JSMol::get_prop() and JSMol::set_prop()
- renamed commonchem to rdkitjson in JS unit test
- added relevant unit tests
* fixed mistake in logic
* - added add_hs_in_place() and remove_hs_in_place() to the JS MinmalLib
- added relevant tests
* - removed check for existence of a property ahead of clearing it as it is not necessary; updated the clearProp docstring to reflect this
- updated the MolFileStereochem.h docstrings based on review comments and fixed a typo
- fixed two (legitimate) compiler warnings as get_molblock() and get_v3kmolblock() should return nullptr and not a pointer to an empty string; added tests for this as there was none
- in MinimalLib/common.h, moved the check of whether a molecule has undergone a flip around the Z axis to a function in the anonymous namespace
- in MinimalLib/common.h, added logic to preserve original wedging (and eventually invert it) also when alignOnly is set to false, in case the wedging is all within the constrained scaffold
- added thourough testing of the wedging logic on both CFFI and JS sides
* - added equality operator to CXXAtomIter and CXXBondIter classes such that they can used with implicit loop STL algorithms
- added relevant unit tests
* fix Windows build
* - enable building MinimalLib as a plain JS file for usage in legacy/headless browsers
- support alternative way to draw an ellipse on legacy canvas without ellipse support
- update tests.js to test both the standard and the legacy version of MinimalLib
- update demo.html to work with both versions of the library and automatically select one based on browser support of WebAssembly
- fix a regression in demo.html caused by a change in signature of generate_aligned_coords
* reverted most changes
* changes in response to review
* restored demo.html
added a comment to Dockerfile_legacy_browsers explaining how to test in a legacy browser
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - fix indentation
- fix regex check (which currently always fails)
* wip
* - added clearMolBlockWedgingInfo()
- added invertMolBlockWedgingInfo()
- MinimalLib::generate_aligned_coords() now inverts stereochemistry if a rigid-body alignment transformation caused chiality inversion
- MinimalLib::generate_aligned_coords() now clears stereochemistry if coordinates changed
- added JSMol::clear_prop() to the already existing JSMol::get_prop() and JSMol::set_prop()
- renamed commonchem to rdkitjson in JS unit test
- added relevant unit tests
* fixed mistake in logic
* - added add_hs_in_place() and remove_hs_in_place() to the JS MinmalLib
- added relevant tests
* - removed check for existence of a property ahead of clearing it as it is not necessary; updated the clearProp docstring to reflect this
- updated the MolFileStereochem.h docstrings based on review comments and fixed a typo
- fixed two (legitimate) compiler warnings as get_molblock() and get_v3kmolblock() should return nullptr and not a pointer to an empty string; added tests for this as there was none
- in MinimalLib/common.h, moved the check of whether a molecule has undergone a flip around the Z axis to a function in the anonymous namespace
- in MinimalLib/common.h, added logic to preserve original wedging (and eventually invert it) also when alignOnly is set to false, in case the wedging is all within the constrained scaffold
- added thourough testing of the wedging logic on both CFFI and JS sides
* - added equality operator to CXXAtomIter and CXXBondIter classes such that they can used with implicit loop STL algorithms
- added relevant unit tests
* fix Windows build
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - added add_hs_in_place() and remove_hs_in_place() to the JS MinmalLib
- added relevant tests
* changes in response to review
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - enable get_molblock(details_json) from MinimalLib as it is already enabled in CFFI
- enable useMolBlockWedging on get_molblock() in both CFFI and JS MinimalLib
- add tests
* - expose also addChiralHs
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - extend prepareAndDrawMolecule() with missing optional parameters already supported by prepareMolForDrawing()
- enable useMolBlockWedging, wedgeBonds, addChiralHs, forceCoords, wavyBonds in CFFI/MinimalLib
- add relevant CFFI and JS unit tests
* Replace AllProps with a smaller subset
* make sure we pickle properties Python-side
* changes in response to review
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
- 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>
* expose highlighAtomColors, highlighBondColors and highlightAtomRadii to CFFI and JS
* removed comment
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* 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>
* - 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>
* Add JSMol::get_prop() and JSMol::set_prop()
* Remove trailing space in MinimalLib test code
* Add JSMol::has_prop()
* Add JSMol::get_prop_list()
* Add test_prop to MinimalLib test case
* add a global feature flag to control use of the new chirality code
* expose that flag to minimallib
* add getters for allowNontetrahedralChilrality and useLegacyStereoPerception
* switch to using environment variables to store the values
* document that
correct the documentation about nontetrahedral stereo
* yay visual c++
* in response to review
* - Abbreviations::applyMatches() sets the _abbreviationMapping molecule property to relate the atom indices in the molecule with abbreviations to the atom indices in the original molecule
* added support for bond index mappings
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
* - 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>