feat: skip implicit H addition for metal atoms#228
Conversation
Collapse the MolecularInorganicsArray periodic-table entries from the multi-line valence layout to one aligned entry per line, mirroring the ElData table in util.c. Purely cosmetic -- all element data is unchanged.
Set bSkipAddingH for the main-group metals (Li, Na, K, Rb, Cs, Fr, Be, Mg, Ca, Sr, Ba, Ra, Al, Ga, In, Tl, Sn, Pb, Bi, Po) in both default valence tables (ElData in util.c and the mirrored MolecularInorganicsArray in strutil.c). A bare metal atom now yields just the element (e.g. Na -> InChI=1S/Na) instead of being saturated to its normal valence with hydrogen (previously Na -> InChI=1S/Na.H). Only non-metals, metalloids and noble gases still receive implicit H. Add test_implicitHydrogen.cpp covering main-group metals, transition metals, non-metals/metalloids and noble gases.
|
Unit Test Coverage ReportCoverage Regression Summary
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-27815793724 and opening html/index.html |
|
@fbaensch-beilstein The landing page lists Openeye in InChI's Board of Trustees - is this is a close collaboration, i.e. OpenEye both implements this in their products / services quickly? The reason for this question is a related question about why
Not convinced the original url to the user forum about "Biovia Draw, analysis and name of a compound" is accessible without a login, I add a print-to-pdf here and ping Mr Hornig about your pull request here. |
|
@nbehrnd I can't say anything about the generation of the incorrect chemical name. For clarification: Until now, the standard InChI itself also generated InChI=1S/Na.H for a lone sodium. It filled the atom's assumed "default valence" with a hydrogen and disconnected it afterwards. After this PR a lone sodiume produces InChI=1S/Na, matching how other metals (e.g. Fe -> InChI=1S/Fe) have been handled. This is independent of any vendor. So far it is a test run and I will prepare a version for this in the InChI WebDemo. So I can not say anything about how soon it will be part of the standard InChI and nothing about when, or indeed whether, BIOVIA/OpenEye will adopt this behaviour and the corresponding InchI version. |
What
InChI no longer adds implicit hydrogens to metal atoms. Previously a bare
main-group metal was saturated to its normal valence with hydrogen, so a lone
sodium became
InChI=1S/Na.H; it now yields justInChI=1S/Na, consistent withhow transition metals (e.g.
InChI=1S/Fe) have always been handled.Closes #99
Why
Adding hydrogen to a bare metal atom to fill an assumed "normal valence" is not
chemically meaningful for metals. Transition metals were already flagged to skip
H addition; this extends the same treatment to the main-group metals, leaving
only non-metals, metalloids and noble gases to receive implicit H.
How
The behaviour is governed by the per-element
bSkipAddingHflag in the defaultvalence tables. The flag is now set for the main-group metals (Li, Na, K, Rb,
Cs, Fr, Be, Mg, Ca, Sr, Ba, Ra, Al, Ga, In, Tl, Sn, Pb, Bi, Po) in both
tables that drive H addition:
ElDatainINCHI_BASE/src/util.c(standard InChI path)MolecularInorganicsArrayinINCHI_BASE/src/strutil.c(-MolecularInorganicspath)Only non-metals, metalloids and noble gases keep
bSkipAddingH == 0. Noblegases keep it but have zero normal valence, so they never gain H regardless.
Commits
style:reformatMolecularInorganicsArrayto the aligned one-entry-per-lineElDatalayout — purely cosmetic, all element data unchanged.feat:setbSkipAddingHfor the main-group metals in both tables and addtest_implicitHydrogen.cpp.Tests
INCHI-1-TEST/tests/test_unit/test_implicitHydrogen.cpppins the behaviourend-to-end across main-group metals, transition metals, non-metals/metalloids
and noble gases (48 elements).
ctestunit suite: 16/16 pass.test_executable): pass (no regressions).