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

bad inchi for chiral S when the molecule is sanitized #296

Closed
greglandrum opened this issue Jul 21, 2014 · 3 comments
Closed

bad inchi for chiral S when the molecule is sanitized #296

greglandrum opened this issue Jul 21, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@greglandrum
Copy link
Member

[18]>>> print mb

  Mrv0541 07211416442D          

  7  6  0  0  1  0            999 V2000
    2.1434    0.4125    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.0164    0.7145    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.8414   -0.7145    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    1.4289   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000   -0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.7145   -1.2375    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0
    0.7145   -0.4125    0.0000 S   0  0  1  0  0  0  0  0  0  0  0  0
  4  1  1  0  0  0  0
  4  2  1  0  0  0  0
  4  3  1  0  0  0  0
  7  4  1  0  0  0  0
  7  5  1  6  0  0  0
  7  6  2  0  0  0  0
M  END


[19]>>> print Chem.MolToInchi(Chem.MolFromMolBlock(mb,sanitize=False))
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m1/s1

[20]>>> print Chem.MolToInchi(Chem.MolFromMolBlock(mb,sanitize=True))
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m0/s1

[21]>>> print Chem.MolToSmiles(Chem.MolFromMolBlock(mb,sanitize=True),True)
C[S@@](=O)C(C)(C)C

[22]>>> print Chem.MolToSmiles(Chem.MolFromMolBlock(mb,sanitize=False),True)
C[S@@](=O)C(C)(C)C

[23]>>> m1 = Chem.MolFromMolBlock(mb,sanitize=True)

[24]>>> m2 = Chem.MolFromMolBlock(mb,sanitize=False)

[25]>>> m1.Debug()
Atoms:
    0 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    1 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    2 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    3 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
    4 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    5 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 3 arom?: 0 chi: 0
    6 16 S chg: 0  deg: 3 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 1
Bonds:
    0 3->0 order: 1 conj?: 0 aromatic?: 0
    1 3->1 order: 1 conj?: 0 aromatic?: 0
    2 3->2 order: 1 conj?: 0 aromatic?: 0
    3 6->3 order: 1 conj?: 0 aromatic?: 0
    4 6->4 order: 1 conj?: 0 aromatic?: 0
    5 6->5 order: 2 conj?: 0 aromatic?: 0

[26]>>> m2.Debug()
Atoms:
    0 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 0 arom?: 0 chi: 0
    1 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 0 arom?: 0 chi: 0
    2 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 0 arom?: 0 chi: 0
    3 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 0 arom?: 0 chi: 0
    4 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 0 arom?: 0 chi: 0
    5 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 0 arom?: 0 chi: 0
    6 16 S chg: 0  deg: 3 exp: 4 imp: 0 hyb: 0 arom?: 0 chi: 1
Bonds:
    0 3->0 order: 1 conj?: 0 aromatic?: 0
    1 3->1 order: 1 conj?: 0 aromatic?: 0
    2 3->2 order: 1 conj?: 0 aromatic?: 0
    3 6->3 order: 1 conj?: 0 aromatic?: 0
    4 6->4 order: 1 dir: 2 conj?: 0 aromatic?: 0
    5 6->5 order: 2 conj?: 0 aromatic?: 0
@greglandrum greglandrum added this to the 2014_09_1 milestone Jul 21, 2014
@greglandrum greglandrum self-assigned this Jul 21, 2014
@greglandrum
Copy link
Member Author

It's not purely sanitization; it's one of the cleanup operations that the molfile parser does when it sanitizes:

In [17]: m3 = Chem.MolFromMolBlock(mb,sanitize=False)

In [18]: Chem.SanitizeMol(m3)
Out[18]: rdkit.Chem.rdmolops.SanitizeFlags.SANITIZE_NONE

In [19]: print Chem.MolToInchi(m3)
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m1/s1

In [20]: m3.Debug()
Atoms:
    0 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    1 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    2 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    3 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
    4 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    5 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 3 arom?: 0 chi: 0
    6 16 S chg: 0  deg: 3 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 1
Bonds:
    0 3->0 order: 1 conj?: 0 aromatic?: 0
    1 3->1 order: 1 conj?: 0 aromatic?: 0
    2 3->2 order: 1 conj?: 0 aromatic?: 0
    3 6->3 order: 1 conj?: 0 aromatic?: 0
    4 6->4 order: 1 dir: 2 conj?: 0 aromatic?: 0
    5 6->5 order: 2 conj?: 0 aromatic?: 0

@greglandrum
Copy link
Member Author

Can be traced back to the bond direction:

In [21]: b=m3.GetBondWithIdx(4)

In [22]: b.SetBondDir(Chem.BondDir.NONE)

In [23]: print Chem.MolToInchi(m3)
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m0/s1

@greglandrum
Copy link
Member Author

further proof of this, adding bond wedging fixes the problem:

In [35]: Chem.WedgeMolBonds(m1,m1.GetConformer())

In [37]: m1.Debug()
Atoms:
    0 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    1 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    2 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    3 6 C chg: 0  deg: 4 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 0
    4 6 C chg: 0  deg: 1 exp: 1 imp: 3 hyb: 4 arom?: 0 chi: 0
    5 8 O chg: 0  deg: 1 exp: 2 imp: 0 hyb: 3 arom?: 0 chi: 0
    6 16 S chg: 0  deg: 3 exp: 4 imp: 0 hyb: 4 arom?: 0 chi: 1
Bonds:
    0 3->0 order: 1 conj?: 0 aromatic?: 0
    1 3->1 order: 1 conj?: 0 aromatic?: 0
    2 3->2 order: 1 conj?: 0 aromatic?: 0
    3 6->3 order: 1 dir: 2 conj?: 0 aromatic?: 0
    4 6->4 order: 1 conj?: 0 aromatic?: 0
    5 6->5 order: 2 conj?: 0 aromatic?: 0

In [38]: print Chem.MolToInchi(m1)
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m1/s1

But this wouldn't be a general fix because molecules built from SMILES still won't have the correct InChI:

In [41]: print Chem.MolToSmiles(m2,True)
C[S@@](=O)C(C)(C)C

In [42]: print Chem.MolToInchi(Chem.MolFromSmiles('C[S@@](=O)C(C)(C)C'))
InChI=1S/C5H12OS/c1-5(2,3)7(4)6/h1-4H3/t7-/m0/s1

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

1 participant