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

RemoveHs() removes H atom attached to dummy if it came from AddHs() #1439

Closed
DrrDom opened this issue May 31, 2017 · 1 comment
Closed

RemoveHs() removes H atom attached to dummy if it came from AddHs() #1439

DrrDom opened this issue May 31, 2017 · 1 comment
Labels
Milestone

Comments

@DrrDom
Copy link
Contributor

DrrDom commented May 31, 2017

I discovered some strange behavior of removeHs function applied for '[H][*:1]' molecule.

If I create that mol from smiles, RemoveHs does not remove a single H from the mol:

mmm = Chem.MolFromSmiles('[H][*:1]')
Chem.MolToSmiles(Chem.RemoveHs(mmm))

output:

'[H][*:1]'

If I apply RemoveHs to fragments obtained after MMPA cuts it removes H and keeps only '[*:1]'

mmm = Chem.MolFromSmiles('c1ccccc1C')
mmm = Chem.AddHs(mmm)
fr = rdMMPA.FragmentMol(mmm, pattern="[*]!@!=!#[!#1]", maxCuts=1, resultsAsMols=True)
for f in fr:
    ff = Chem.GetMolFrags(f[1], asMols=True)
    print(Chem.MolToSmiles(ff[0]), Chem.MolToSmiles(Chem.RemoveHs(ff[0])))
    print(Chem.MolToSmiles(ff[1]), Chem.MolToSmiles(Chem.RemoveHs(ff[1])))

output:

[H]c1c([H])c([H])c([*:1])c([H])c1[H] c1ccc([*:1])cc1
[H]C([H])([H])[*:1] C[*:1]
[H]c1c([H])c([H])c([*:1])c(C([H])([H])[H])c1[H] Cc1ccccc1[*:1]
[H][*:1] [*:1]
[H]c1c([H])c(C([H])([H])[H])c([H])c([*:1])c1[H] Cc1cccc([*:1])c1
[H][*:1] [*:1]
[H]c1c([H])c([*:1])c([H])c([H])c1C([H])([H])[H] Cc1ccc([*:1])cc1
[H][*:1] [*:1]
[H]c1c([H])c([H])c(C([H])([H])[*:1])c([H])c1[H] c1ccc(C[*:1])cc1
[H][*:1] [*:1]
@greglandrum greglandrum changed the title RemoveHs and [H][*:1] mol RemoveHs() removes H atom attached to dummy if it came from AddHs() Jun 1, 2017
@greglandrum greglandrum added the bug label Jun 1, 2017
@greglandrum
Copy link
Member

What's going on here: AddHs() tags the Hs that it adds as implicit.
This ends up taking priority over the check for Hs that are attached to non-heavy atoms:
https://github.com/rdkit/rdkit/blob/master/Code/GraphMol/AddHs.cpp#L451

@greglandrum greglandrum added this to the 2017_09_1 milestone Aug 15, 2017
greglandrum added a commit to greglandrum/rdkit that referenced this issue Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants