<jupyter_start><jupyter_text>Similarity<jupyter_code># tanemoto koeficient, jaccard index: pocet bitu co maji nastaveny stejne vs pocet vsech bitu
# pokud sdili vsechno = 1, jsou totozne, z hlediska fingerpritnu
# stejne struktury, neznamenaji stejne struktury
# smyslem je mit ciselne vyjadreni podobnosti dvou struktur
# sar princip, podobne molekuly maji vetsi sanci, ze budou mit podobnou aktivitu, pozor na sar paradox ( i mala zmena zpusobi jinou funkci)
def tanimotoSimilarity(fp1, fp2):
    fp1onBits = set((i for i, bit in enumerate (fp1) if bit))
    fp2onBits = set((i for i, bit in enumerate (fp2) if bit))
    allBits = fp1onBits.union(fp2onBits)
    sharedBits = fp1onBits.intersection(fp2onBits)
    if not allBits:
        return None
    return len(sharedBits) / len(allBits)
tanimotoSimilarity((True, True, True), (True, False, True))
salicylA = Chem.MolFromSmiles("c1ccc(c(c1)C(=O)O)O")
salicylAkey = customkey(salicylA)
salicylAkey
salicylAsimilarities = [tanimotoSimilarity(salicylAkey, fp) for fp in drugbankAwesomeFPS]
salicylAsimilarities[666]
completeHits = [i for i, similarity in enumerate(salicylAsimilarities) if similarity == 1]
len(completeHits)
Draw.MolsToGridImage([drugbank[i] for i in completeHits[:9]], subImgSize = (300, 300))
salicylAmaccs = MACCSkeys.GenMACCSKeys(salicylA)
from rdkit import DataStructs
salicylAmaccsSim = DataStructs.FingerprintSimilarity(salicylAmaccs)

goodMatches<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.088093599449415, 'fraction_numerical': 0.016517549896765314, 'mean_word_length': 6.27, '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': '299706', 'license': 'MIT', 'n_tokens_mistral': 585, 'n_tokens_neox': 567, 'n_words': 141, 'path': 'kamclar/Untitled.ipynb', 'repo_name': 'lich-uct/cdd2018', 'size': '1453'}