Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_hs function removes deuterium/tritium atoms #438

Open
markarchibald opened this issue Jan 15, 2024 · 4 comments
Open

remove_hs function removes deuterium/tritium atoms #438

markarchibald opened this issue Jan 15, 2024 · 4 comments

Comments

@markarchibald
Copy link

Using the remove_hs function to remove unnecessary explicit H atoms, I found that while it does not remove H atoms that are required to define stereochemistry, it does remove H atoms that are labelled as the isotopes deuterium or tritium – altering the chemical structure. The analogous Chem.RemoveHs function in core RDKit does not remove deuterium/tritium.

Can be reproduced on the RDKitJS demo page (https://www.rdkitjs.com/#introduction) by running this code using a mol block for D2O:

  var mol = RDKitModule.get_mol(`
  ACD/Labs04281711232D

  3  2  0  0  0  0  0  0  0  0  1 V2000
    1.1221   -0.6603    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 D   0  0  0  0  0  0  0  0  0  0  0  0
    2.3088    0.0000    0.0000 D   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  1  0  0  0  0
  1  3  1  0  0  0  0
M  END`);
  var molRemovedH = RDKitModule.get_mol(mol.remove_hs());
  var dest = document.getElementById("example-1-output");
  var svg = molRemovedH.get_svg();
  dest.innerHTML = "<div id='drawing'>" + svg + "</div>";

which produces this depiction:

image

Expected behavior
Expected behaviour is that D atoms are not removed (as they define chemical information that is otherwise lost), resulting in this depiction:

image

@ptosco
Copy link

ptosco commented Jan 15, 2024

@markarchibald You are right about deuterium and tritium - JSMol::remove_hs() calls MolOps::removeAllHs() which will remove ALL hydrogens, including isotopic ones. I will add an optional flag to enable retaining isotopic Hs, similarly to C++ and Python.

Regarding H atoms that are required to define stereochemistry, those are not actually present in the molecule graph, they are only added on-the-fly for visualization. You may avoid that those Hs are added by calling get_svg_with_highlights() or draw_to_canvas_with_highlights() and passing '{"addChiralHs":"false"}' as JSON details.

@markarchibald
Copy link
Author

@ptosco thanks for the quick reply. Do you have a guess for when the change will find its way into a release?

(Regarding Hs defining stereo, I do want these to be displayed but it's useful to understand it better.)

@ptosco
Copy link

ptosco commented Jan 15, 2024

The rdkit-js release cycle follows the main rdkit repo release cycle, which is reported here:
https://github.com/rdkit/rdkit/milestones
Alternatively, as soon as I have made the change in master and it has been reviewed and merged (which will probably happen before the end of this week), you can build your own RDKit_minimal library using the Dockerfile:
https://github.com/rdkit/rdkit/blob/master/Code/MinimalLib/docker/Dockerfile
Documentation how to build the library is provided as comments in the Dockerfile itself.

@markarchibald
Copy link
Author

That's great, thank you

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

No branches or pull requests

2 participants