Ejemplo n.º 1
0
def get_product_smiles(rmol, edits, tatoms):
    smiles = edit_mol(rmol, edits, tatoms)
    if len(smiles) != 0: return smiles
    try:
        Chem.Kekulize(rmol)
    except Exception as e:
        return smiles
    return edit_mol(rmol, edits, tatoms)
Ejemplo n.º 2
0
                    x, y = gedit.split('-')
                    x, y = int(x), int(y)
                    if (x, y) in pbonds:
                        t = pbonds[(x, y)]
                    else:
                        t = 0
                    cbonds.append((x, y, t))

            # Generate products by modifying reactants with predicted edits.
            pred_smiles = edit_mol(rmol, cbonds)
            pred_smiles_sani = set(sanitize_smiles(smi) for smi in pred_smiles)
            pred_smiles = set(pred_smiles)
            if not psmiles <= pred_smiles:

                # Try again with kekulized form
                Chem.Kekulize(rmol)
                pred_smiles_kek = edit_mol(rmol, cbonds)
                pred_smiles_kek = set(pred_smiles_kek)
                if not psmiles <= pred_smiles_kek:
                    if psmiles_sani <= pred_smiles_sani:
                        print(
                            '\nwarn: mismatch, but only due to standardization'
                        )
                        gfound_sani += 1

                    else:
                        print('\nwarn: could not regenerate product {}'.format(
                            psmiles))
                        print('sani product: {}'.format(psmiles_sani))
                        print(r)
                        print(p)