Preserve atom mapping when generating a molecule from a SMILES with H atoms mapped #3787
Answered
by
bp-kelley
xiaoruiDong
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You'll want to use the SmilesParseParams to block the removing of
hydrogens, by default, hydrogens are merge into the connecting atoms.
>>
Chem.MolToSmiles(Chem.MolFromSmiles("[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]"))
'[C+:1]#[C:2][C:3]1=[CH:7][N-:6][O:5][CH2:4]1'
>> params = Chem.SmilesParserParams()
>> params.removeHs = False
>>
Chem.MolToSmiles(Chem.MolFromSmiles("[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]",
params))
'[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]'
Cheers,
Brian
…On Thu, Feb 4, 2021 at 3:58 PM Xiaorui Dong ***@***.***> wrote:
Hi everyone,
I am trying to import molecules from SMILES strings with all-atom mapped.
Here is an example
[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]
The most important thing to me is that *I also want to preserve the
mapping of H atoms*. However, a typical workflow won't work:
from rdkit import Chem
mol = Chem.MolFromSmiles("[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]")
mol
[image: image]
<https://user-images.githubusercontent.com/35771233/106953672-41651c00-66f8-11eb-9dcb-82d988227116.png>
mol=Chem.AddHs(mol)
mol
[image: image]
<https://user-images.githubusercontent.com/35771233/106953759-5e015400-66f8-11eb-85bc-717c880a6ef8.png>
It is obvious that atom mappings of H atoms are completely lost. (look at
those 0s).
print([atom.GetAtomMapNum() for atom in mol.GetAtoms()])
>>> [1, 2, 3, 7, 6, 5, 4, 0, 0, 0]
Is there any workaround or options that I can use to achieve the goal?
Thanks for the help!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3787>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACLOFIGJYPNWDSOPNRXIUPTS5MC6NANCNFSM4XDRIRLA>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
xiaoruiDong
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I am trying to import molecules from SMILES strings with all-atom mapped. Here is an example
[C+:1]#[C:2][C:3]1=[C:7]([H:10])[N-:6][O:5][C:4]1([H:8])[H:9]
The most important thing to me is that I also want to preserve the mapping of H atoms. However, a typical workflow won't work:
It is obvious that atom mappings of H atoms are completely lost. (look at those 0s).
Is there any workaround or options that I can use to achieve the goal? Thanks for the help!
Beta Was this translation helpful? Give feedback.
All reactions