Hello,
I am trying to run reactions using RunReactants.
I want to define a general reaבtion involving braking bond in a chain of
one-single bonded carbons: '[#6:1][#6:2][#6:3][#6:4] >>
([#6:1][#6:2].[#6:3][#6:4])'.
When the reaction does not involve any aromatic carbons all works fine, bun
when I hava a reactant with aromatic carbons I get strange things..
For example - if I use the following structure as reactant - 'Cc1ccccc1C' I
expect to get after the reaction only one product - 'CC=CC=CC=CC'.
But it seems that any chain in the aromatic ring recognized as one-single
bonded carbons and I get many other fragments( - after converting the
pruducts to smiles format using Chem.MolToSmiles):
['CccccccC',
 'ccccc(C)cC',
 'C',
 'Cc1ccccc-1',
 'ccccc(C)CC',
 'cccc(C)c(C)C',
 'C',
 'Cc1ccccc-1',
 'ccccc(C)CC',
 'cccc(C)c(C)C',
 'CccccccC',
 'ccccc(C)cC',
 'CcccccCC',
 'C',
 'Cc1c-cccc1',
 'ccc(C)c(C)cC',
 'Ccccc(C)cC',
 'cc(C)c(C)ccC',
 'cc(C)c(C)ccC',
 'Ccccc(C)cC',
 'ccc(C)c(C)cC',
 'C',
 'Cc1c-cccc1',
 'CcccccCC']
 More over, atoms are marked as aromatic eventhough they are not anymore.
 When I try to change it back to mol object (using Chem.MolFromSmiles) I
get an error message:
 "non-ring atom 1 marked aromatic"

I will be greatfull if anyone has an idea for solving this problem without
specifing the aromatic ring in the reaction (I want to keep the reaction
general so it could happen in any place in the molecule that has a chain of
3 single bonds).

Thank you!
Michal

my code:

def flatten(lst):  # take list of lists and convert them to one list.
    return sum(([x] if not isinstance(x, list) else flatten(x)
                for x in lst), [])

def flat_children(children):
    return flatten(children)

def mol_to_smile(MolList):  # convert mol to smiles
    smiles = []
    for x in range(len(MolList)):
        new_smile = Chem.MolToSmiles(MolList[x])
        new_smiles = split_smile(new_smile)
        for n_s in new_smiles:
            smiles.append(n_s)
    return smiles

def split_smile(smile):
    """The function split two fragments in one smile into two smiles"""
    smile = smile.split(".")
    return(smile)

smile = 'CC1=CC=CC=C1C'
mol = Chem.MolFromSmiles(smile)
rxn = AllChem.ReactionFromSmarts('[#6:1][#6:2][#6:3] >>
([#6:1][#6:2].[#6:3])')
products = rxn.RunReactants((mol,))
mols = []
for product in products:
    mols.append([x for x in product]) # converts the products from tuples
(products) to list (mols)
    mols = flat_children(mols)        # return [Mol, Mol, ..]
smiles = mol_to_smile(mols)
print(smiles)

for smile in smiles:
    m = Chem.MolFromSmiles(smile)
    img = Draw.MolToImage(m)
    img.show()


output:

['CccccccC',
 'ccccc(C)cC',
 'C',
 'Cc1ccccc-1',
 'ccccc(C)CC',
 'cccc(C)c(C)C',
 'C',
 'Cc1ccccc-1',
 'ccccc(C)CC',
 'cccc(C)c(C)C',
 'CccccccC',
 'ccccc(C)cC',
 'CcccccCC',
 'C',
 'Cc1c-cccc1',
 'ccc(C)c(C)cC',
 'Ccccc(C)cC',
 'cc(C)c(C)ccC',
 'cc(C)c(C)ccC',
 'Ccccc(C)cC',
 'ccc(C)c(C)cC',
 'C',
 'Cc1c-cccc1',
 'CcccccCC']

 [12:06:11] non-ring atom 1 marked aromatic
_______________________________________________
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss

Reply via email to