Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rdkit has a complicated system for including Hydrogen atoms. It is discussed here: https://sourceforge.net/p/rdkit/mailman/message/36699970/ In brief, there are three levels of hydrogen inclusion: Explicit and in graph, explicit, and implicit. This is meant to model the difference between hydrogens that are explicit in a SMILES string, and those that are inferred by the toolkit, but it unfortunately goes even further than that. For instance, if hydrogens are removed from a molecule with the rdkit.Chem.rdmolops.RemoveHs() function, which is the recommended way to make explicit hydrogens implicit for visualization, RdKit can then imply the existence of hydrogens using its valence model. This can, for example, convert a radical to the stable species of equivalent charge, even if this means adding hydrogens. In fact, before this commit, simply calling the OFFTK Molecule.to_rdkit method could convert, for example, the hydroxyl radical to water: >>> from openff.toolkit.topology import Molecule >>> from rdkit import Chem >>> >>> radical = Molecule.from_smiles("[O][H]") >>> rd_radical = radical.to_rdkit() >>> Chem.MolToSmiles(rd_radical) '[H]O' Visualizing rd_radical clearly demonstrates that this is water; the oxygen atom has an implicit hydrogen. This can also be seen by building the radical up from individual atoms and bonds. OFFTK has a different philosophy: all the hydrogens are either provided or inferred when the Molecule is created, and then they are explicitly represented in the molecular graph forever. This commit sets the `NoImplicit` property for all atoms in a rdkit molecule created by to_rdkit to True. Since all the hydrogens in a Molecule are already explicitly represented, this more faithfully represents the desired molecule in the rdkit ecosystem. The molecular species is even now stable over sanitization: >>> radical = Molecule.from_smiles("[O][H]") >>> rd_hydroxyl_rad = radical.to_rdkit() >>> Chem.SanitizeMol(rd_hydroxyl_rad) # Modifies in place >>> Chem.MolToSmiles(rd_hydroxyl_rad) [H][O] Visualization even includes the radical dot!
- Loading branch information