Skip to content

fix: restrict the MI charge-separated bond pass to Group 1/2 metals - #306

Merged
nnuk merged 6 commits into
devfrom
fix/mi-charge-separated-group12
Nov 7, 2026
Merged

nnuk merged 6 commits into
devfrom
fix/mi-charge-separated-group12

Conversation

@fbaensch-beilstein

@fbaensch-beilstein fbaensch-beilstein commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Restricts the MolecularInorganics charge-separated bond pass (7837660, #219) to Group 1/2 metals. On other metals opposite formal charges usually depict oxidation states on a covalent complex, so the pass split H₂PtCl₆ (SID 71150), AlH₄⁻ drawn as Al³⁺/4 H⁻, and charged ZnCl₂/FeCl₃/SnCl₄/CuCl, which now match their neutral drawings. Na/Ca salts and the #219 unit tests are unchanged.

Where the bond table cuts the element pair (Ag(+)-F(-), likewise Cu/Hg/Tl-F), neither keeping nor cutting the charged bond is right, so MI now rejects the structure with Error 99 (Charge-separated bond to a non-Group 1/2 metal) and no InChI (agreed with @gblanke02 in the review). The neutral Ag-F drawing is still cut; -LegacyMetalHandling is unchanged.

Intended output change: 26 structures in inchi.sdf (Sb ylides from the technical-manual tables; Cu, Co, Ru, Fe complexes that stay connected; repeated cobalamin and ferrocenyl components that now come out identical); the reference is regenerated in the second commit, mcule is unchanged. Related but separate: #305.

Closes #304

The pass added in 7837660 disconnected every single or coordinative
metal-ligand bond whose atoms carry opposite formal charges. On metals
outside Groups 1 and 2 such charges usually depict oxidation states on a
covalent complex, so the pass split complexes that the neutral drawing
keeps connected: H2PtCl6 drawn as Pt(4+) with four Cl(-) (PubChem SID
71150) lost four of six equivalent ligands, AlH4(-) drawn as Al(3+) with
four H(-) fell apart into ions, and charged ZnCl2, FeCl3, SnCl4 and CuCl
gave a different InChI from their neutral drawings.

Apply the pass to Group 1 and Group 2 metals only and leave all other
metal-ligand bonds to the decision tree. The chelate-ring check in the
pass and the ring perception it needed are removed: the ring count is
always zero for Group 1/2 metals, so the check could no longer fire.

Adds unit tests for H2PtCl6, AlH4(-) and ZnCl2 drawn with charges.

Refs #304
…arated pass change

Restricting the charge-separated bond pass to Group 1/2 metals produces
26 intended diffs in inchi.sdf, all metal or metalloid structures whose
charged metal-ligand bonds now stay connected: Sb ylides from the
technical-manual tables, Cu, Co, Ru and Fe complexes, and repeated
components (cobalamin, ferrocenyl phosphonium) that now come out
identical. mcule.sdf is unchanged.

Refs #304
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Unit Test Coverage Report

Coverage Regression Summary

Metric PR (%) Base (%) Difference (pp)
Lines 34.3 34.2 +0.10
Branches 22.3 22.2 +0.10

Find details on the base coverage at https://iupac-inchi.github.io/InChI/coverage/index.html

Find details on this PR's coverage by downloading coverage-reports-42350061202 and opening html/index.html

@nnuk nnuk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@fbaensch-beilstein this means that currently the criteria for a metal atom in a ring system with at least C, N and O atoms will not be disconnected? I am asking this because we have this decision in the decision tree and most importantly in the MI paper. So, should we change that also?

@fbaensch-beilstein

Copy link
Copy Markdown
Collaborator Author

No, the chelate criterion is unchanged. The decision tree still keeps all metal bonds when the metal's ring system contains at least three C, N or O atoms, so the paper's rule stands. The PR only removes the duplicate of that check from the charge-separated pass: the pass now runs for Group 1/2 metals only, and MolecularInorganicsCountRingCNOAtoms returns 0 for those, so the duplicate could no longer fire. Charged chelates of other metals now skip the pass and reach the decision tree, where the chelate rule keeps them connected (e.g. NSC-103019, the ferrocenes in the regression diff). One caveat that predates this PR: ring perception only covers the component containing atom 0, so the rule can miss metals in later components. That is #305.

@gblanke02

Copy link
Copy Markdown
Contributor

As discussed this morning, you find some more examples from the 3 bug lists in the attached excel sheet. They incude a depiction of the structure, the mofie, and the inChIs of 1.07.5, mol. inorganics, and the InChI of 1.07.5 with the recmet parameter. The issue is caused in case the "ligand atom" (atom of the ligand that is directly linked to the metal atom) is negatively charged. In most of the cases the InChIs of 1.07.5 /recmet are as expected.
Bug examples.xlsx

@fbaensch-beilstein

Copy link
Copy Markdown
Collaborator Author

As discussed this morning, you find some more examples from the 3 bug lists in the attached excel sheet. They incude a depiction of the structure, the mofie, and the inChIs of 1.07.5, mol. inorganics, and the InChI of 1.07.5 with the recmet parameter. The issue is caused in case the "ligand atom" (atom of the ligand that is directly linked to the metal atom) is negatively charged. In most of the cases the InChIs of 1.07.5 /recmet are as expected. Bug examples.xlsx

@gblanke02 The MI InChIs are not what the latest dev head will generate as their prefix is 1B/ not 1BB/

@fbaensch-beilstein

fbaensch-beilstein commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

@gblanke02 Thanks for the sheet. I ran all 13 molfiles through current dev (69f31d1) and this PR (c34ec11), and reproduced your 1.07.5 -RecMet column exactly. Apart from the 1B/ → 1BB/ prefix, your Molecular Inorganics column matches current dev for 12 of 13 rows. The exception is the Ni/Cp* row, where the sheet keeps the dummy atom as Zz. The attached PDF shows each structure with every metal bond marked as cut or kept on dev and on this PR.

Your diagnosis holds: dev cuts a metal–ligand bond whenever the ligand atom is negative and the metal positive. This PR restricts that rule to Group 1/2 metals. Summary:

  1. Fixed by this PR, now matching 1.07.5 -RecMet: 5 examples (Al hydride, Zn bis-oxalate, Ru–Cl, [PtCl₄]²⁻, Sb₂S₅).
  2. Bonds fixed, H written differently: 4 examples (SID 7820840, 232692818, 385974045, 518789771). The connectivity now matches, but an H bonded to the metal appears as an atom in /c instead of in /h. This is intended since Explicit bonds between metal and hydrogen atoms must be kept #168: current InChI writes it the same way with -RecMet too. The 1.07.5 reference predates Explicit bonds between metal and hydrogen atoms must be kept #168.
  3. SID 420393 (ferrocenyl amine + PdCl₂): the ferrocene is fixed. PdCl₂ stays connected because the MI bond table has Pd–Cl as a bond to keep. PdCl₂ on its own gives the same result. 1.07.5 splits PdCl₂ even in /r, so this difference is a design choice of Molecular Inorganics. Note that the deposited molfile has no Pd–N bond.
  4. SID 37370460 (Ti butoxide isopropoxide): not touched by this PR. Ti is drawn neutral, so the charge rule never applies. The decision tree cuts all four Ti–O bonds because the bond table lists Ti–O as cut. Once cut, the drawn O⁻ become oxo O²⁻ and Ti becomes Ti⁴⁺, which is consistent bookkeeping. The open question is whether Ti–O should be cut at all, since Ti alkoxides are covalent and 1.07.5 -RecMet keeps this one connected. That needs a rule decision with @nnuk.
  5. Ni/Cp (SID 482307869):* no expected value in the sheet. Both builds expand the η⁵ dummy bond into five Ni–C bonds.

Related: #309 (stacked on this PR, fixes #305) decides metal-bond disconnection per fragment. It gives the same InChI as this PR for all 13 examples.

mi-bug-examples.pdf

@fbaensch-beilstein

Copy link
Copy Markdown
Collaborator Author

@gblanke02 A review of this PR found a side effect where I need your decision before I push a follow-up.

Situation. With this PR the charge-separated pass only cuts bonds of Group 1/2 metals. For every other metal a charged bond goes to the decision tree. The tree checks whether the metal has a "normal" valence for its drawn charge, and Ag(+) with one bond does not, so the bond is kept. As a result, a charged and a neutral drawing of the same simple salt now differ:

Input dev this PR
Ag(+)–F(−) cut kept (InChI=1BB/AgF/c1-2)
Ag–F (no charges) cut cut (InChI=1BB/Ag.FH/h;1H/q+1;/p-1)

The same happens for CuF, HgF and TlF. For CuCl it is the other way round: the bond table keeps Cu–Cl, so on this PR charged and neutral CuCl now agree (both connected), while on dev the charged one was cut.

Proposed follow-up (implemented locally, not pushed). Group 1/2 metals are still always cut. For other metals, the charged pass cuts the bond only when the MI bond table cuts that element pair, as it would for the neutral drawing:

  • Ag(+)F(−), Cu(+)F(−), Hg(+)F(−), Tl(+)F(−): cut, the same as the neutral drawing
  • H₂PtCl₆, AlH₄⁻ drawn as Al³⁺/4 H⁻, charged ZnCl₂/FeCl₃/SnCl₄/CuCl: still connected, because the table keeps Pt–Cl, Al–H, Zn–Cl, Fe–Cl, Sn–Cl and Cu–Cl
  • all unit, executable and invariance tests pass; the regression corpus does not change (no record has such a charged pair)

One limit: for a pair the table cuts, the charged drawing is decided by the table alone, while the neutral drawing also goes through the rest of the decision tree (valence, chelate ring, link to another metal). For example, a charged Ag(+)–F(−) inside a chelate would be cut, while the neutral one would be kept.

Question. Should charged metal–ligand bonds on metals outside Group 1/2 be cut when the bond table cuts that pair (the proposal), or stay connected as in the current PR?

@gblanke02

Copy link
Copy Markdown
Contributor

This implementation is a good way for the current release. A few more comments about the examples described in the PDF:
Titanium butoxide isopropoxide, Ti neutral (SID 37370460): The break of Ti-O bonds has been questioned bythe moecular workinggroups and may be defined more precise y the working group for the next release (current release beta3)
Tetrapentylantimony oxide (SID 232692818): While the metal bond disconnection is handled correctly, the connectivty strings are not identical. The 306 version handes the explicit H atom (=23) correctly that does not exist in the other 2 InChIs. The 306 version delivers the most correct InChI string
Ni(Cp*) triphenylphosphine hydride (SID 482307869) with its *atom seems to be haptic bond system that is correctly transferred into the InChI.
The test results of 306 hadnles the addressed issues and it is preferred for theimplementation.

@gblanke02 gblanke02 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Outside group 1 and 2 structures like Ag+-F- are handled but let InChI return an error message.

A metal outside Group 1/2 drawn with opposite charges across a bond whose
element pair the bond table cuts (Ag(+)-F(-), likewise Cu/Hg/Tl-F) can be
neither kept (the neutral drawing is cut) nor cut (the drawing would then
disagree with the covalent reading). MI now rejects such a structure with
"Error 99 (Charge-separated bond to a non-Group 1/2 metal)" and no InChI;
the CLI continues with the next structure. Pairs the table keeps (Pt-Cl,
Al-H, Zn-Cl, Fe-Cl, Sn-Cl, Cu-Cl) are unchanged and still left to the
decision tree; the neutral Ag-F drawing is still cut.

Refs #304
@fbaensch-beilstein

fbaensch-beilstein commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator Author

Outside group 1 and 2 structures like Ag+-F- are handled but let InChI return an error message.

Just to be sure which output you want for a bonded Ag(+)-F(-) (the same applies to Cu/Hg/Tl-F, i.e. pairs the bond table cuts):

  1. Error, no InChI. The whole structure is rejected, including any other fragments in the molfile (Ag(+)-F(-) plus methanol gives no InChI at all).
    Error 99 (no InChI; Charge-separated bond to a non-Group 1/2 metal)
  2. Warning, bond cut. Same InChI as neutral Ag-F, the unbonded ions Ag(+) F(-), and -LegacyMetalHandling:
    InChI=1BB/Ag.FH/h;1H/q+1;/p-1
    Warning (Charge-separated bond to a non-Group 1/2 metal was disconnected; Proton(s) added/removed)
  3. Warning, bond kept. What fix: restrict the MI charge-separated bond pass to Group 1/2 metals #306 currently returns (without a warning so far):
    InChI=1BB/AgF/c1-2

Pairs the bond table keeps (Pt-Cl, Al-H, Zn-Cl, Cu-Cl, ...) are not affected by any of these.

@gblanke02

gblanke02 commented Nov 5, 2026 via email

Copy link
Copy Markdown
Contributor

@nnuk nnuk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me.

@nnuk
nnuk merged commit 6aba5f6 into dev Nov 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MI: charge-separated pass breaks covalent complexes drawn with oxidation-state charges

3 participants