<jupyter_start><jupyter_text>----------------- DecomposeNot used in final calculations<jupyter_code>import os, shutil

shutil.rmtree('frags')
os.mkdir('frags')

from rdkit import Chem
from rdkit.Chem import BRICS, AllChem
from IPython.display import display
import re
from fragmenstein.mpro import MProVictor
from scipy.special import comb


hit_names = [file for file in os.listdir('input') if '.mol' in file]

#max_combinations = 20_000
minFragmentSize = 8
frags = []
letter = 'αβγδεζηθικλμνξοπρστυφχψω'
for name in hit_names:
    mol = Chem.MolFromMolFile(os.path.join('input', name))
    # protect
    for atom in mol.GetAtoms():
        if atom.GetAtomicNum() == 0:
            atom.SetAtomicNum(117)
    deco = BRICS.BRICSDecompose(mol,
                                returnMols=True, minFragmentSize=minFragmentSize, keepNonLeafNodes=False)
    for i, dmol in enumerate(deco):
        mod = AllChem.DeleteSubstructs(dmol, Chem.MolFromSmiles('*'))
        # deprotect
        for atom in mod.GetAtoms():
            if atom.GetAtomicNum() == 117:
                atom.SetAtomicNum(0)
        mod.SetProp('_Name', f"{name.replace('.mol', '')}_{letter[i]}")
        frags.append(mod)
    shutil.copy(os.path.join('input', name), os.path.join('frags', name))

for mol in frags:
    print(mol.GetProp('_Name'))
    try:
        Chem.MolToMolFile(mol, f"frags/{mol.GetProp('_Name')}.mol")
    except Exception as error:
        print(error)
print('DONE.')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13718897108271688, 'fraction_numerical': 0.00941492938802959, 'mean_word_length': 3.215297450424929, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '469653', 'license': 'MIT', 'n_tokens_mistral': 555, 'n_tokens_neox': 519, 'n_words': 110, 'path': 'scripts/cluster_calculations.ipynb', 'repo_name': 'matteoferla/NSP3-macrodomain', 'size': '1487'}