aspuru-guzik-group / group-selfies

Apache License 2.0
51 stars 9 forks source link

Custom groups did not join liked expected #6

Closed tkella47 closed 11 months ago

tkella47 commented 1 year ago

In an attempt to bind an ion to histidine using custom groups, I encountered an unexpected issue.

from rdkit import Chem
from rdkit.Chem import AllChem
from group_selfies import (
    fragment_mols, 
    Group, 
    MolecularGraph, 
    GroupGrammar, 
    group_encoder
)

from rdkit.Chem.Draw import IPythonConsole

from IPython.display import display
from test_utils import *
from rdkit import RDLogger

RDLogger.DisableLog('rdApp.*') 

g = Group('ion', 'CCCCCCCCCCCCS(=O)(=O)(*1)') # create the ion group
amino = Group("histidine", "O=C([C@H](CC1=CN(*1)C=N1)N)O") # create the histidine group

grammar = GroupGrammar([g, amino])

new_selfies = "[:0histidine][:0ion]"

display(grammar.decoder(new_selfies)) # This may be a silent error and just displays histidine

new_selfies = "[:0histidine][:0ion][:0ion][:0histidine]"

display(grammar.decoder(new_selfies)) # This displays the desired molecule.