thomas0809 / MolScribe

Robust Molecular Structure Recognition with Image-to-Graph Generation
MIT License
153 stars 31 forks source link

bond angle(?) issue #31

Closed sistar2020 closed 2 months ago

sistar2020 commented 2 months ago

The following two images are seemingly almost identical:   Image1:

image-1

Image2:

image-2

  Image1 gives a correct SMILES, but Image2 gives a wrong one.

Image1: Cn1c(=O)c(=O)n(C)c2cc(S(=O)(=O)N3CCC4(CC3)Nc3ccccc3-n3cccc34)ccc21
Image2: Cn1c(=O)c(=O)n(C)c2cc([S@TB13](=O)(=O)N3CCC4(CC3)Nc3ccccc3-n3cccc34)ccc21

I thought this is a bit weird since there are no elements like T and B in Image2.

LingjieBao1998 commented 2 months ago

This is special chirality in rdkit for S or P and other multi-electron elements, you can refer to the link:"https://www.rdkit.org/docs/RDKit_Book.html". image You can insert the below code in line 549 of MolScribe/molscribe/chemistry.py to reassure the removal of special chirality in other elements.

for atom in mol.GetAtoms():
    if atom.GetSymbol() != "C":
        atom.SetChiralTag(Chem.rdchem.ChiralType.CHI_UNSPECIFIED)
sistar2020 commented 2 months ago

Gotcha! Thank you very much.