Hi,
I'm not quite sure why you want to do that, but once you call AddHs you
need to re-calculate the CIP Ranks (they aren't valid anymore once you've
changed the number of atoms). This is easy enough to do:
In [2]: m = Chem.AddHs(Chem.MolFromSmiles('O[C@H](F)Cl'))
...: Chem.AssignStereochemistry(m,force=True,cleanIt=True)
...: for i,at in enumerate(m.GetAtoms()):
...: print(i,at.GetSymbol(),at.GetProp('_CIPRank'))
...:
0 O 3
1 C 2
2 F 4
3 Cl 5
4 H 1
5 H 0
Note that the H atoms are the lowest ranks, as you would expect.
-greg
On Fri, Apr 12, 2019 at 11:51 PM Phuong Chau <[email protected]> wrote:
> To whom it may concern,
>
> I am trying to assign a priority score to each atom of a chemical by its
> CIP values. However, it showed error if the molecule is added with H. Is
> there any ways that I can assign like '-1' value to H atom?
> My main purpose was as the following example:
> Given:
> mol=Chem.MolFromSmiles('CCC')
> molH=Chem.AddHs(mol)
> AtomId Symbol
> 0 C
> 1 C
> 2 C
> 3 H
> CIP(0,molH) = 0
> CIP(3,molH) = -1
>
> I tried to have a function defining the CIP rank for H:
>
> def CIP(atomId,mol):
> if mol.GetAtomWithIdx(atomId).GetSymbol()=='H':
> CIP='-1'
> else:
> mol=Chem.RemoveHs(mol)
> CIP=mol.GetAtomWithIdx(atomId).GetProp('_CIPRank')
> return CIP
>
> However, it gave me the KeyError f I do CIP(0,molH) even though I included
> RemoveHs to molecule if the atom is not "H".
>
> Could you please show me how to solve this?
>
> Thank you so much for your help.
> Phuong Chau
> Smith College '20
> Engineering and Data Science Major
> _______________________________________________
> Rdkit-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss
>
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss