19 Commits

Author SHA1 Message Date
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
9d26fc229d Fixes #7642 (#7643) 2024-07-25 04:48:00 +02:00
Greg Landrum
c7c9ad3328 Add in place and multithread support for more of the MolStandardize code (#6970) 2023-12-12 17:21:18 +01:00
Greg Landrum
15751b3651 Add multi-threaded versions of some MolStandardize operations (#6909)
* initial addition of MT support to MolStandardize

* do the other inplace functions

* add mt ops to python wrappers
including tests

* release the GIL

* remove exploratory code added during dev

* make normalizer thread safe

* refactor some repeated code
2023-11-24 18:36:17 -05:00
Greg Landrum
ac54eb3209 Add an in place version of most of the MolStandardize functionality (#6491)
* reionizer and uncharger and normalizer can now operate in place

* add removeUnmatchedAtoms argument to in-place version of runReactant

When set to false atoms which are not explicitly removed by the reaction are preserved

* Fix a case where transforms were incorrectly updating atomic numbers

* add more inplace operations to MolStandardize

* support those in the Python layer

* support inplace for the rest of the python wrappers

* move a few more functions over to the inplace code
2023-07-21 08:44:41 +02:00
David Cosgrove
5fe20d270f Improved handling of organometallics (#6139)
* First stab at disconnecting organometallics the Syngenta way.

* Add support for Li and Na compounds, with tests.

* Correct docstrings.

* Add -1 valence to sodium.

* Add changes from PR 5997.

* Move declaration of disconnectOrganometallics.

* Re-factor tests for disconnectOrganometallics to read V3000 files rather than hard-code in file.

* Add optional options to constructor.

* Python wrapping for disconnectOrganometallics.

* Python tests.

* Correct docString.

* Test using in place overload of disconnect free function.

* options_ should not be a reference.

* Re-work the wrappers.

* Added test MOL files.

* Correct charge on iron atoms.

* Fix tests for charged iron.

* Added some more test complexes.

* Port Marco's oxidation number Python to C++ Descriptor.

* Rename functions.

* Another test.

* Python wrappers.

* Comment in test.

* Throws exception if atom-based function called with non-kekulized parent.

* Fix typo.

* Allow potassium as well.

* Whole molecule calculations for oxidation number only.
Rename prop to OxidationNumber.

* Add OxidationNumber to common_properties.

* Extra comment.

* When deleting atom, update any ENDPTS props on bonds.
Copied in from stale PR ExtraDoc.

* Added hapticBondsToDative with python wrapper.

* Extra test.

* Re-factor endpts parsing.

* Typo.

* Add function for haptic end points inc. Python wrapper.

* Add dative bonds in separate step.

* C++ version of dativeBondstoHaptic.

* Update test mols.

* Python wrapper.

* Fix indents in Python test script.

* Corrected expected test result.

* Only do non-metal to metal conversion of single bond to dative if the explicit valence of the non-metal allows it.

* Fix test broken in a non-material way by previous change.

* Export for DLL.

* Remove redundant function declaration.

* Dave hates Windows.

* Move hapticBondEndpoints to Molops::details.

* And take it out of the Python wrappers.

* Run yapf on reformatted test script.

* Get the DLL builds going.

* addDativeBond -> addHapticBond.

* Batch edits.

* Position arithmetic.

* setQuery.

* Dummy positions for all confs.

* Fix tests for dummy positions for all confs.

* Move tests to catch_organometallics.cpp.

* Modern docString.

* Change member variable names.

* sProp length, bonus batchEdit.

* Add options object to disconnectOrganometallics.

* Tidied license.
Atom precondition.

* GetIntProp.

* Test opts aren't defaults.

* Python wrapper for disconnectOrganometallics with options.

* Minor edit.

* Slightly random attempt to fix Java build.

* Response to review.

* Another stab at the doc strings.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-03-18 04:36:38 +01:00
Greg Landrum
fb49a33b5a Fix a couple of problems with MolStandardize (#5319)
* Fixes #5317

* Fixes #5318

* Fixes #5320

* Update Code/GraphMol/MolStandardize/Charge.cpp

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

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
2022-05-30 06:00:09 +02:00
Greg Landrum
f5a54af475 A collection of MolStandardize improvements (#4118)
* Swap to using a data structure for default normalization parameters

* bring the default fragment data into the code too

* cleanup

* add reionizer parameters via data

change fragment parse failures to ValueErrorExceptions

* tautomer parameters in the code

* got a little over-enthusiastic in that last cleanup

* use boost::flyweight to cache normalization and charge data params

* a bit more cleanup

* support reading params from JSON

* fragments from JSON
single-call for fragment removal

* add a one-liner for the canonical tautomer

* quick refactor

* Fixes #4115

* complete the parents

* docs

* move the definitions to a namespace and make them const

* see if switching to c++14 fixes the CI compile problems with g++ 5.5

* somewhat uglier way of solving the initalizer list problem
2021-05-19 09:11:23 +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
Paolo Tosco
bc4d547847 - MolStandardize::chargeParent() does not need to call cleanup because it calls fragmentParent() which already does (#3454)
- MolStandardize::reionize() should pass params.acidbaseFile to the Reionizer constructor
2020-10-02 05:20:26 +02:00
Paolo Tosco
527a7adf99 Some work on TautomerEnumerator (#3327)
* - Added a TautomerEnumerator constructor which allows passing CleanupParameters
- Added three configurable parameters to CleanupParameters
- Added a callback to TautomerEnumerator
- Fixed a bug where the same tautomer could be mapped by both isomeric and non-isomeric SMILES
- TautomerEnumerator::enumerate() now returns a TautomerEnumeratorResult and does not take
  dynamic_bitset pointers as optional parameters
- Added a missing transform from the Sitzmann paper
- General code cleanup and optimization

* - TautomerEnumeratorResult is now iterable in both C++ and Python
- further optimizations
- implemented a TautomerEnumerator.PickCanonical() Python wrapper
- added C++ and Python accessors to SMILES and SmilesTautomerMap

* - make sure the number of tautomers reported by rdLogger is correct and definitive

* make sure that if N maxTautomers are requested, N tautomers are returned if the theoretical number of tautomers is M>N

* avoid that sulfonic acids hit the formamidinesulfinic acid tautomerisation rule

* offer an option to allow the old API to still be used.

* Changes in response to review and following discussion with Gareth and Greg

* - made TautomerEnumeratorResult an enum class (was a plain C enum)
- made TautomerEnumeratorResult::const_iterator a bidirectional_iterator
- added tests to fully probe the TautomerEnumeratorResult::const_iterator functionality

* - change the difference_type definition
- added tests for the above

* - cosmetic change to improve code readability

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2020-09-24 17:00:03 -04:00
Manan Goel
f3a6db2a02 This commit fixes the bug "segmenation fault/core dump when chargePar… (#3029)
* This commit fixes the bug "segmenation fault/core dump when chargeParent is run with skip_standardize set to true" mentioned in #2970

* Fixed memory leaks in MolStandardize and deleted variables which aren't required
2020-03-24 07:48:38 +01:00
shrey183
00c6a7e370 Possible fix for issue #2965 (#3001)
* fixed issue #2965

* added test case for issue #2965

* fixed formatting and added comment.
2020-03-14 14:28:17 +01:00
Greg Landrum
f8a4020789 Add MolVS tautomer canonicalization (#2886)
* first pass at implementing molvs-style tautomer scoring
This isn't optimal in terms of performance, but all the MolVS tests pass.

* clang format

* A bit of refactoring of the tautomer stuff

* first pass at python wrappers

* allow specifying the tautomer scoring function from C++

* EFF: use boost::flyweight so SMARTS is only parsed once

* improve the python API

* switch to boost::function instead of using function pointers

* allow user-provided tautomer scoring functions

* documentation and scorer version

* change in response to review
2020-01-17 15:25:17 -05: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
4361e9932d optimization of the MolStandardize code (#2621) 2019-08-28 18:08:29 -04:00
Greg Landrum
9f103a9913 Allow components of the MolStandardize code to be initialized from streams (#2385)
* Fixes #2383 (tests coming in the next commit)
Minor typo fix
Fixes a "bug" in one of the default transforms

* Adds support for directly providing normalization parameter data
instead of requiring the use of a text file.

* allow fragment removers to be initialized with string data

* remove unicode

* allow the reionizer to be initialized from a stream
2019-04-03 04:48:05 +02:00
Greg Landrum
1d01874678 improvements to the Uncharge functionality (#2374)
* modify the uncharger to be use a canonical atom ordering

* add doCanonical cleanup parameter
make canonical ordering the default
document the change

* Add neutralization of additonal negative groups (not just acids).
This may not be the right thing to do.

* expose the new parameter to python

* changes in response to review
2019-03-29 21:02:55 -04:00
Susan Leung
956fdf268c Dev/GSOC2018_MolVS_Integration (#2002)
* short test file for MolVS standardize_sm

* short test file for MolVS fragment

* short test file for MolVS metals

* short test file for MolVS normalize

* short test file for MolVS reionize

* short test file for MolVS tautomer

* short test file for MolVS validate

* long test file for MolVS standardize smiles

* long test file for MolVS fragment

* long test file for MolVS metals

* long test file for MolVS normalize

* long test file for MolVS reionize

* long test file for MolVS tautomer

* long test file for MolVS validate

* Unit tests for MolVS steps

* dropping support for Python2

* molvs/__init__.py

* molvs/charge.py

* molvs/errors.py

* molvs/fragment.py

* molvs/metal.py

* molvs/normalize.py

* molvs/resonance.py

* molvs/standardize.py

* molvs/tautomer.py

* molvs/utils.py

* molvs/validate.py

* molvs/validations.py

* molvs/cli.py

* adapted and renamed molvs/cli.py to work within $RDBASE/Contrib/MolVS/

* setup MolStandardize directories, source with empty cleanup function, header, CMake files

* corrections to empty source, header and test1.cpp

* adding empty functions and initializers to MolStandardize

* empty Metal source, header and added test

* added most of Metal.cpp functionality and made some more tests

* empty functions and initializers to Normalize

* empty functions and initializers to Validate

* added most code for RDKitDefault mode, along with some tests

* restructure for abstract base class ValidateMethod

* written in isNoneValidation for MolVSValidation

* took out isNoneValidation, put in noAtomValidation, neutralValidation, isotopeValidation for MolVSValidation

* added in AllowedAtoms

* added in disallowedAtoms

* corrections to Validate

* added code for FragmentRemover

* extended fragment functionality to include choose largest fragment, added in tests for fragment catalog, fragment remover. Also added fragmentValidation method in MolStandardize

* added another test to testValidate test_fragment

* corrections to fragment

* corrections to Metal

* added code for Normalize

* added normalize member function to MolStandardize and added tests

* added multi fragment functionality to Normalize.cpp and additional tests

* TransformCatalog

* tests for Normalize.cpp

* first bit of cleanup

* added most of Charge functionality and some tests

* some corrections to Charge.cpp and some more tests to testCharge.cpp

* corrections to Charge.cpp

* start of Tautomer Enumerate with some tests

* added BondType option to Tautomer Enumeration

* correcting for some memory leakage

* a few alterations to formatting

* sorting out some memory leaks

* sorting out some memory leaks

* some corrections for PCS test set

* redo tests with updated RDKit

* fixing memory leak

* more fixes after 100kPCS set testing

* using tab as delimiter in CSVs rather than comma

* tutorial for MolStandardize

* still working on Tautomer enumeration

* deleted some empty tests

* starting writing tautomer canonicalize

* rename test_data -> data (the source still needs to be updated)

* automatic source reformatting

* adjust to directory rename

* move the fragment catalog test into the MolStandardize directory
do not create separate library for FragmentCatalog

* stop building separate libraries for the catalogs

* move the CleanupParameters into the MolStandardize namespace

* first pass at python wrapper

* move the py module to the correct dir;
add some python tests;
add standardizeSmiles to python wrapper

* disabling the compareMolVSTest since that requires command line arguments to run

* get this building on windows

* put the python lib in the right place

* further work on python wrapper for rdMolStandardize

* added get and set functions to Metal and wrapped them

* added get and set functions to Metal and wrapped them

* changed construstor of Reionizer class and input args for reionize, wrapped this default

* overload Reionizer constructor so user can input own AcidBaseFile from python

* added Uncharger class to Charge and added test for Uncharger

* wrapped Fragment, fixed some memory leakage, changed some args and return types, added some tests

* wrapped Normalized and changed how Normalizer class is initiated

* changing MolVSValidation structure so user can choose which MolVS submethod they want

* starting to write Wrap for Validate

* now it compiles with Wrap/Validate.cpp

* a couple refactorings around validate

* move the validate code into the rdMolStandardize module

* make sure a valid pointer is returned for standardizeSmiles

* rdMolStandardize.MolVSValidation done and tests added

* half way through AllowedAtomsValidation

* finished AllowedAtomsValidation and DisallowedAtomsValidation

* moved charge, fragment, metal, normalize into the rdMolStandardize module

* changed tutorial to use wrapped code

* added copyrights

* added copyrights

* move the data files

* modify source files to adjust to the move

* added validateSmiles functionality

* removed std::cout

* redid some of the 100k PCS tests

* working on the tutorial

* adding some documentation

* deleting some comment lines

* some changes after pull review

* More changes after pull review

* start of trying to make java wrap

* remove some warnings, add some questions

* additional warning removals, a bit more reporting

* some test cleanups

* enable testing of the java code
2018-09-28 11:24:25 +02:00