You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parsing of hypervalent nitrogen compounds from SMILES/InChI is broken #1301
RMG no longer has atomtypes for hypervalent nitrogen
Parsing of hypervalent SMILES/InChI breaks with OpenBabel; raises AtomTypeError
RDKit's treatment of hypervalent N is now similar to RMG's treatment, however RDKit cannot handle all cases.
Examples:
O=N(=O)C
RDKit converts this to one single bonded O and one double bonded O with charge separation
OpenBabel converts this to two double bonded O's (raises AtomTypeError)
O=N(C)=N(C)=O
RDKit converts this to N-O single bonds with charge separation and N=N double bond
OpenBabel converts this to three double bonds (raises AtomTypeError)
InChI=1S/C4H10N2O2/c1-3-5(7)6(8)4-2/h3-4H2,1-2H3 (InChI of the prior molecule)
RDKit is unable to parse
OpenBabel gives the same result
Note: RDKitMol conversion doesn't work properly on current master because of an issue with the order of updateCharge and updateLonePairs. This is a straightforward issue that will be fixed in #1262.
What do we do next?
Should we re-add atomtypes for hypervalent N?
Should we add a "sanitation" method similar to RDKit to convert hypervalent N to resonance structures with charge separation?
Should we prioritize RDKit as a backend? (Currently OpenBabel is tried first for most methods, since it was previously more robust in general.)
I agree that SMILES/InChI parsing is problematic for some cases of hypervalent atoms (N and S). However, I'd like to correct the above claim: to the best of my understanding RMG does have correct atomTypes for all physical hypervalent nitrogen (and sulfur).
The structure O=N(=O)C, for example, isn't a physical molecule representation since the N has a valance of 9 (two double bonds, a single bond, no formal charge). Since in RMG we also use atomTypes to confine the feasible molecule generation space (relevant mainly to resonance structures), we do not have an N5dd atomType (though we do have N5ddc with a formal charge, which does obey the octet rule).
In other words, the three examples above aren't valid physical representations of molecules.
Out of curiosity, could you or @cgrambow elaborate on how these SMILES, which are unphysical representations IMO, were created in the first place?
Other than the examples above, we still experience parsing issues even for valid molecules, e.g., O(N=O)[N]#N, see #735.
Sorry, I wrote out the SMILES manually. As much as they are un-physical, I would argue that they are still "valid" SMILES which should be corrected to the proper resonance form.
@cgrambow was working with InChI's, which does not specify bond orders. In that case, OpenBabel still interprets these species as I described above. RDKit is capable of interpreting the InChI for O=N(=O)C, but is not able to interpret the second species, which I noted.
We could add such atomTypes to be able to parse "wrong" SMILES, then generate resonance structures and filter out the unrepresentative molecules. However, this quest might be endless. E.g., what about structures like [O-][N+][O+][N-3]#[N+2]? (this is not made up... there are many more examples like this) Where should the line of adding unphysical SMILES cross?
I agree, of course, that InChI aren't specific enough, and cause problems when parsing correct molecule representations. This is an intrinsic InChI problem. I guess that pure InChI isn't designed to represent Lewis structures of hypervalent heteroatoms. Perhaps augmented InChI could solve such cases? (BTW, is augmented InChI something invented by RMG, or is it an IUPAC thing?)
Suggestion: Perhaps we should try both RDKit and OB. If the first fails due to an atomType error, we should try the other. If both fail we could try to assign a correct "similar" atomType to the atom that triggered the error (similar in terms of closest mach of bonds and lone pairs), update nearby atoms accordingly, regenerate InChI, and see if both InChI's match.
Thinking about this more, I agree that adding atomTypes is a more practical solution than the approach I suggested of checking similarities, which probably isn't robust.
My only concern is that we'll needlessly generate structures with wrong atomTypes while applying resonance templates. I don't have a good assessment of how much longer it will take to generate these and then filter them out (keep in mind that in some cases the number of structures could get to hundreds or thousands per species even without the "wrong" atomType additions).
I think we should come up with a way to use these "wrong" atomTypes only for parsing SMILES/InChI (and then resonate to find the correct structure/s), and not when generating new structures. Should we add them as a sub-class of AtomTypes that is only functional for parsing?
A partial list of octet rule violators that were deleted (#1206) is:
This issue is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant issue, otherwise it will automatically be closed in 30 days.
Activity
alongd commentedon Feb 28, 2018
I agree that SMILES/InChI parsing is problematic for some cases of hypervalent atoms (N and S). However, I'd like to correct the above claim: to the best of my understanding RMG does have correct atomTypes for all physical hypervalent nitrogen (and sulfur).
The structure
O=N(=O)C, for example, isn't a physical molecule representation since the N has a valance of 9 (two double bonds, a single bond, no formal charge). Since in RMG we also use atomTypes to confine the feasible molecule generation space (relevant mainly to resonance structures), we do not have anN5ddatomType (though we do haveN5ddcwith a formal charge, which does obey the octet rule).In other words, the three examples above aren't valid physical representations of molecules.
Out of curiosity, could you or @cgrambow elaborate on how these SMILES, which are unphysical representations IMO, were created in the first place?
Other than the examples above, we still experience parsing issues even for valid molecules, e.g.,
O(N=O)[N]#N, see #735.mliu49 commentedon Feb 28, 2018
Sorry, I wrote out the SMILES manually. As much as they are un-physical, I would argue that they are still "valid" SMILES which should be corrected to the proper resonance form.
@cgrambow was working with InChI's, which does not specify bond orders. In that case, OpenBabel still interprets these species as I described above. RDKit is capable of interpreting the InChI for
O=N(=O)C, but is not able to interpret the second species, which I noted.alongd commentedon Feb 28, 2018
We could add such atomTypes to be able to parse "wrong" SMILES, then generate resonance structures and filter out the unrepresentative molecules. However, this quest might be endless. E.g., what about structures like
[O-][N+][O+][N-3]#[N+2]? (this is not made up... there are many more examples like this) Where should the line of adding unphysical SMILES cross?I agree, of course, that InChI aren't specific enough, and cause problems when parsing correct molecule representations. This is an intrinsic InChI problem. I guess that pure InChI isn't designed to represent Lewis structures of hypervalent heteroatoms. Perhaps augmented InChI could solve such cases? (BTW, is augmented InChI something invented by RMG, or is it an IUPAC thing?)
Suggestion: Perhaps we should try both RDKit and OB. If the first fails due to an atomType error, we should try the other. If both fail we could try to assign a correct "similar" atomType to the atom that triggered the error (similar in terms of closest mach of bonds and lone pairs), update nearby atoms accordingly, regenerate InChI, and see if both InChI's match.
alongd commentedon Feb 28, 2018
Thinking about this more, I agree that adding atomTypes is a more practical solution than the approach I suggested of checking similarities, which probably isn't robust.
My only concern is that we'll needlessly generate structures with wrong atomTypes while applying resonance templates. I don't have a good assessment of how much longer it will take to generate these and then filter them out (keep in mind that in some cases the number of structures could get to hundreds or thousands per species even without the "wrong" atomType additions).
I think we should come up with a way to use these "wrong" atomTypes only for parsing SMILES/InChI (and then resonate to find the correct structure/s), and not when generating new structures. Should we add them as a sub-class of AtomTypes that is only functional for parsing?
A partial list of octet rule violators that were deleted (#1206) is:
We'll need to add sulfur as well.
mliu49 commentedon Feb 28, 2018
Could we try to update atomtypes, but if it fails, try to generate resonance structures and take the first one that has valid atomtypes?
I don't think it's RMG necessarily needs to use these structure internally, we just need to be able to interpret OB and RDKit output.
alongd commentedon Feb 28, 2018
Sure! Can we generate a Molecule object without passing through atomTypes?
github-actions commentedon Jun 21, 2023
This issue is being automatically marked as stale because it has not received any interaction in the last 90 days. Please leave a comment if this is still a relevant issue, otherwise it will automatically be closed in 30 days.