Skip to content

Change IUPAC metal->non-metal single bonds to dative#6038

Merged
greglandrum merged 14 commits into
rdkit:masterfrom
DavidACosgrove:IUPACMetalBonds
Feb 6, 2023
Merged

Change IUPAC metal->non-metal single bonds to dative#6038
greglandrum merged 14 commits into
rdkit:masterfrom
DavidACosgrove:IUPACMetalBonds

Conversation

@DavidACosgrove
Copy link
Copy Markdown
Collaborator

@DavidACosgrove DavidACosgrove commented Feb 1, 2023

Reference Issue

Addresses #6019

What does this implement/fix? Explain your changes.

As suggested by @greglandrum, this changes surplus single bonds to metals to dative in MolOps.cc::cleanUp.

Any other comments?

@DavidACosgrove DavidACosgrove changed the title WIP - Not for review : Iupac metal bonds Change IUPAC metal->non-metal single bonds to dative Feb 1, 2023
@greglandrum greglandrum added this to the 2023_03_1 milestone Feb 5, 2023
Copy link
Copy Markdown
Member

@greglandrum greglandrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments here, most of which are addressed by the PR I just did against your branch.

Comment thread Code/GraphMol/MolInterchange/Parser.cpp Outdated
Comment on lines +930 to +935
// Version 10 files can be read by 11, but not vice versa.
if (doc["rdkitjson"]["version"].GetInt() != currentRDKitJSONVersion) {
throw FileParseException("Bad Format: bad version in JSON");
if (!(doc["rdkitjson"]["version"].GetInt() == 10 &&
currentRDKitJSONVersion == 11)) {
throw FileParseException("Bad Format: bad version in JSON");
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just commit to backwards compatibility here - we'll continue to read previous versions of the JSON format in the future. I don't think we want to do this for versions below 10 though, so how about making the check here:

if (int jsonVersion=doc["rdkitjson"]["version"].GetInt(); jsonVersion > currentRDKitJSONVersion || jsonVersion<10)

Comment thread Code/GraphMol/MolOps.cpp Outdated
Comment thread Code/GraphMol/MolOps.cpp
// from the non-metal to the metal.

auto isMetal = [](const Atom *a) -> bool {
// This is the list of not metal atoms from QueryOps.cpp
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a request for a change, but I suspect that we're going to want to adjust this list to make it less permissive.

Comment thread Code/GraphMol/MolOps.cpp Outdated
Comment thread Code/GraphMol/MolOps.cpp
Copy link
Copy Markdown
Member

@greglandrum greglandrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@greglandrum greglandrum merged commit 42782d3 into rdkit:master Feb 6, 2023
@greglandrum greglandrum mentioned this pull request Feb 7, 2023
ricrogz pushed a commit to ricrogz/rdkit that referenced this pull request Feb 7, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants