Commit Graph

60 Commits

Author SHA1 Message Date
Desmond Gilmour
295ade0fd4 fixes #6119 (#6183)
* fixes #6119

* fixed comments and made the logic more readable

* modified test cases

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-04-16 05:38:06 +02:00
Calvin Josenhans
b6345a816b Using Chiral Tag instead of CIPCode to ensure preservation of chirality in addHs (#6259)
* Changing flags if doIsomericSmiles is false

* Ignoring cis-trans bonds as well

* Tests for removing enhanced stereo

* Fix #6237 by checking chiral tag instead of CIP

* Remove unnecesary calls to fabs

* Modify AddHs

* Tets for #6237

* Rerun Checks
2023-04-14 09:03:35 +02:00
Greg Landrum
7c93c02205 remove cleanupOrganometallics() from the default sanitization (#6292)
* remove cleanupOrganometallics() from the default sanitization

* doc update
2023-04-14 08:49:26 +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
7153918af4 Fixes #4642 (#6115)
* Fixes #4642

We should consider whether or not it's right to remove stereo from atoms which were in stereo groups but are not any longer.

* split stereogroups across fragments

* cleanup

* Changes in response to review
2023-03-02 19:01:45 +01:00
Greg Landrum
72286f5ddd Fixes #6100 (#6105)
* fixes #6100

* cleanup commented line
2023-02-18 21:17:45 +01:00
Greg Landrum
4d4b927651 Fixes #6049 (#6061)
* backup

* backup

* Fixes #6049

Bump version of NumBridgeheadAtoms descriptor

* add a specific test for the issue
2023-02-09 08:31:39 +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
David Cosgrove
42782d31cf Change IUPAC metal->non-metal single bonds to dative (#6038)
* Change atom to metal bonds from single to dative if appropriate.

* Pedantic change whilst I was in the area.

* Reinstate all tests, leave in debugging writes to see failing tests.

* Re-did it.  Failing tests now pass.

* Move any positive charge from the non-metal to the metal.
Fix expected test results.

* Write dative bond to JSON.

* Bump currentRDKitJSONVersion to 11, but allow parser to still read 10.

* Only move 1 unit of charge at a time from non-metal to metal.

* Greg's hack to not do it for O+ and N+ etc.
Explicitly exclude H, He, F, Ne from dative bonds.
Fix tests.

* Update expected PostGres json version to 11.

* suggestions for PR

* Correct comment.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-02-06 04:37:32 +01:00
Greg Landrum
82dd73d079 Fix a problem with pickling molecules with more than 255 rings (#5992)
* Fix a problem with pickling molecules with more than 255 rings

* fix doctest
2023-01-30 23:24:00 -05:00
Greg Landrum
d883803a4b stop caching ring-finding results (#5955)
* stop caching ring-rinding results

* add backwards incompatibility note

* changes in response to review
2023-01-11 09:32:54 -05:00
Greg Landrum
fd44d72fb7 Fixes #5849 (#5861)
* Fixes #5849
This may not be the best fix since it adds another step to canonicalization

* more test cases

* update docs
2022-12-28 20:10:13 +00:00
Greg Landrum
b817f29eb8 extend the allowed valences of the alkali earths (#5786)
make it possible to have preferred and arbitrary valence states (I thought this already worked)
2022-11-25 04:50:36 +01:00
Greg Landrum
c1f68ea574 Fixes #5505: problems when kekulizing molecules with query bonds (#5550)
* Fixes #5505

* Switch to using hasBondTypeQuery()

* update the docs

* ensure we still fail with non-ring aromatic atoms

* changes in response to review
2022-09-13 14:49:45 +02:00
Greg Landrum
edb542097b Fixes #5462 (#5463) 2022-08-03 04:46:17 +02:00
Greg Landrum
9fa1df1cf6 Drop usage of CIP information from the canonicalization code (#5385)
* stop using CIP codes in the atomic canonicalization

this will change results in some cases, so lots of tests need to be updated.

* stop breaking string literals... ARGH

* tests now pass

* update double bond canonicalization

* update a python test

* some cleanup

* update expected results for cartridge
2022-07-13 05:40:23 +02:00
Greg Landrum
cd74dc2207 Initial support for non-tetrahedral stereochemistry (#5084)
* very basics: actually parsing the new atom stereochem features

* add some input verification for the chiral permutations

* fix a typo
add quadruple bond SMILES/SMARTS extension

* add forgotten files

* patch from Roger

* add Roger's parsing examples

* typo

* new tests

* adjusted version of next PR from Roger:
- add SP2D hybridization for square planar (this may change)
- some modernizationof Chirality.cpp
- stop using < HybridizationType in Chirality.cpp (should probably do this elsewhere too)
- improved handling of hybridization assignment for new stereochem
- handle new stereo/hybridization in UFF
- tests for the above

* perception of non-tetrahedral stereo from 3D (from Roger S)
Basic testing of SP and TB based on opensmiles docs

* potential fixes for octahedral assignment
more tests

* docs update
need way more!

* map the TH tags directly to @ tags

* very basics of SMILES writing
this does not work with anything that changes the permutation order
like canonicalization or writing things in rings.

* start to support the getChiralAcross API

* more testing

* consistency

* add hasNonTetrahedralStereo() and getIdealAngleBetweenLigands()

* assignStereochemistry should only remove non-tetrahedral stereo

* re-simplify those tests

* cleanup matrix stream output

* initial pass at supporting nontet stereo in distgeom

* backup

* start on the reference docs

* TBP reference

* first pass at Oh finished

* update SP section

* more doc updates

* fix a typo

* add param to not remove Hs connected to non-tetrahedral atoms

* VERY basic coord generation for square planar

* TBP basics

* basic OH depiction

* start testing missing ligands
allow non-tet stereo in rings (ugly, but correct)

* add new TBP functions from Roger

* update depiction code for new API

* backup, the new tests work so far

* Finish the TB tests

* OH tests pass too

* cleanup

* first pass at getting correct SMILES with reordering
need way more testing than this

* ensure permutation 0 is correctly preserved

* some progress towards adding non-tetrahedral stereo to StereoInfo

* doc update

* add non-tet chiral classes to python wrappers

* make sure removeAllHs also gets neighbors of non-tetrahedral centers
more testing

* a bit of depictor cleanup

* make the assignment from 3D more tolerant
more testing

* improve the bulk testing

* cleanup

* remove a bit of redundant code

* ensure we don't write bogus permutation values to SMILES

* fix some rebase problems

* allow assignStereochemistryFrom3D() to be called without sanitization

* allow disabling the non-tetrahedral stereo when it's not explicit

* get that working on windows too
2022-05-20 09:07:16 +02:00
Ric
918f0221b9 Make atom, bond iterators usable in STL algorithms (#5204)
* add fwditerator features

* add a test
2022-04-15 06:57:57 +02:00
Greg Landrum
8559ef7526 Fix #5055 (#5071)
* Fixes #5055
The problem was a hash collision with the invariants

* switch to using a bitset for the invariant instead of a hash
2022-03-09 13:55:37 +01:00
Greg Landrum
96ee054c71 resolves bad input in one of the tests (#5002) 2022-02-10 08:02:33 +01:00
Greg Landrum
555ab6f1fe Start adding move constructors and move-assignment operators (#4909)
* some initial work...
Still some real questions here about what should be done with dp_mol data members

* add some tests for move semantics of Dict and Props
remove extraneous clear()

* more in-depth testing of the molecule results

* test refactoring

* improve the molecule move test

* fix some leaks found by valgrind
the new tests are now all clean in valgrind

* additional classes
QueryAtom, QueryBond, RingInfo, Conformer

* get swig working again.
Not sure why this is necessary, but SWIG is a mysterious beast

* fixes in response to review

* updates in response to review
2022-02-09 14:20:49 +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
Paolo Tosco
9ed1fecc3a Fixes #4681 and a few Windows PgSQL build problems (#4692)
* fixes #4681

* fixes a few Windows build problems

* added comments to adapter.cpp to explain the changes

* get PostgreSQL to build on Windows with both MSVC and MinGW compilers

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2021-11-20 04:28:49 +01:00
Greg Landrum
092552349c Fixes #4535: support operator<< for AtomPDBResidueInfo (#4564)
* Fixes #4535

First pass, not sure what the best fields are here

* update output format
2021-09-28 13:40:43 -04:00
Greg Landrum
e970148830 Allow applying single-reactant/single-product reactions in place (#4511)
* minor preparatory refactor

* add test

* add reaction literals

* tests for the new literals

* add runReactant
first steps to making things work

* remove works

* backup

* all current tests passing except bond-order changes
some atom-property copying fixed

* bond changes now work

* handle atomic stereo

* some cleanup and more tests

* docs

* not-working

* add KekulizeIfPossible()

* return a value from KekulizeIfPossible

* Revert "not-working"

This reverts commit 2ebd8a5519.

* add in-place reactions to python wrapper

* simplify deprotection wrapper code

* support in-place deprotection

* changes in response to review

* forgotten change
2021-09-26 14:35:23 -04:00
Greg Landrum
df72c241c5 Improve test coverage and some bug fixes (#4536)
* test getIdOfEntryWithBitId()

* remove unused functions

* improve bv tests in python wrapper

* more UniformGrid tests

* improve deprotect coverage

* improve abbreviations coverage

* add operator!= to DeprotectData

* more testing for adjustQueryProperties

* fix a copy-paste bug

* copy-paste bug

* more testing

* more testing

* more testing

* fix an edge case bug in getValenceContrib

* more bond tests

* add operator!= to StereoInfo
tests StereoInfo::operator==

* make some internal functions testable

* more testing

* minor code cleanup

* fix some bad caching behavior in getDistanceMat() and get3DDistanceMat()

testing

* test FixeMolSizeMolBundle() copy ctor

* deprecate BalabanJ

* more testing

* testing

* mods to get things working for windows DLL builds
(don't bother running some of the tests there)

* fix a typo
2021-09-26 07:45:06 +02:00
Greg Landrum
824f124e0e be more tolerant when sanitizing (#4492)
patch from Roger S
2021-09-20 16:17:55 +02:00
Greg Landrum
3193b76d8c cleanup some compiler warnings (#4521)
* cleanup some clang warnings

* get rid of some VC++ warnings
2021-09-16 04:34:40 +02:00
Paolo Tosco
788f3ce02c Fixes #4496 (#4497)
* wip

* fixes #4496

* reverted file committed by mistake

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-09-13 04:54:26 +02:00
Greg Landrum
4c2a580ad1 Fixes github #4311 (#4312)
* a bit of simple refactoring

* Fixes #4311

- adds getValenceContrib() to QueryBond
- adds hasBondTypeQuery() and hasComplexBondTypeQuery() to QueryOps namespace
- atoms with complex bond type queries now have explict and implicit valences of 0
- adds tests for the above

* add a test
2021-07-09 15:06:54 +02:00
Greg Landrum
93b1c3b8dd Fixes #4266 (#4270) 2021-07-01 15:19:16 +02:00
Greg Landrum
1702a227e2 Fixes #3998 (#4248)
* add KekulizeFragment()

more testing wouldn't be bad

* oversight

* Fixes #3998
2021-06-19 06:00:45 +02:00
Greg Landrum
0b78f8d48c fixes #4128 (#4178) 2021-05-27 19:18:32 +02:00
Greg Landrum
caaa7406be Fixes #4127 (#4129)
Also adds fixes for some related problems I noticed while fixing this one.
2021-05-18 15:39:15 +02:00
Greg Landrum
92b52f1988 Fixes #4122 (#4123) 2021-05-10 08:45:06 -04:00
Greg Landrum
75033fb6ac Fix #4071 (#4080)
* add test

* Fixes #4071
2021-04-23 16:45:54 -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
487b1c9d51 Fix definition of bridgehead stereo (#3968)
* support ring stereo from Ns

* modify the definition of bridgehead from #3958

* changes in response to review
2021-03-24 14:45:35 +01:00
Greg Landrum
f0896508f3 Fixes #3932 (#3933) 2021-03-15 17:21:50 +01:00
Greg Landrum
fa6de7b423 Fixes #3912 (#3914) 2021-03-11 17:15:08 +01:00
Greg Landrum
2e3f31990d Allow batch editing of molecules: removal only (#3875)
* backup

* simple first pass, passes all tests

* cleanup a bunch of existing uses

* ensure that we can safely add atoms/bonds while in edit mode

* add context manager on python side

* handle exceptions properly in those

* changes in response to review
2021-03-11 05:10:43 +01:00
Greg Landrum
9277bd56a7 Fixes 3879: bad placement of Hs with fused rings (#3899)
* backup

* Fixes #3879
also simplifies the code to place Hs

* switch to bisecting the angle

* reapply the fix for #3854
2021-03-10 05:38:36 +01:00
Greg Landrum
6fbe4f788d Fixes #3330 (#3869) 2021-03-05 19:59:37 -05:00
Greg Landrum
3b79156697 Fixes #3805 (#3838) 2021-02-23 14:25:39 +01:00
Greg Landrum
5747c4f283 Issue a warning when embedding a molecule with no Hs (#3807)
* add "needsHs()" query

* add warning for embedding without Hs

* add H checks to UFF and MMFF as well;
a small amount of cleanup in the MMFF atom typing
2021-02-22 06:57:50 +01:00
Ric
2afb4fbac4 Mem checkup & fixes (#3510)
* fix leak in testConformerParser

* fix leaks in testMultithreadedMolSupplier

* fix leak in catch_graphmol

* pass build type to YAEHMOP

* cleanup fragments in CoordGen minimizeOnly

* fix leaking ConjElectrons stack in res mol supplier

* avoid double delete

* do not delete 'this'; clean ce not added to map

* delete mol if Multithreaded SD readMolProps throws

* fix typo

* fix typo in comment
2020-11-09 12:08:36 -05:00
Greg Landrum
f1bbc319b5 Fixes #3531 (#3545)
* Fixes #3531

* remove the new Br valences too
2020-11-08 07:17:37 +01:00
Greg Landrum
bba71631b8 fix problem with H+ caused by #3473 (#3503)
* fix problem with H+ caused by #3473

* changes in response to review
2020-10-19 12:45:00 -04:00
Greg Landrum
b86b2364c2 add new oxidation states for Cl, Br, I, Xe, Po, At (#3486)
* add new oxidation states for Br, I, Xe, Po, At

Changes the allowed value 2->3 for I

* add Cl too

* update expected test results
2020-10-12 15:26:18 +02:00
Greg Landrum
acf318c188 Fixes #3470 (#3473) 2020-10-11 08:44:52 -04:00