I present -- circularly weighted #RDKit Morgan #chemformatics binary fingerprint...
Andrew Dalke @dalke@toots.nu
I present -- circularly weighted #RDKit Morgan #chemformatics binary fingerprints! r=1 terms have a weight of 4, r=2 a weight of 3, and w for r=3 of 2, when computing the Tanimoto (subject to collision.)
# Weighted Morgan fingerprints.
from collections import defaultdict
from chemfp import countops
from chemfp.rdkit_toolkit import (
morgan1_count, morgan2_count, morgan3_count)
def weighted_morgan(mol, num_bits=2048):
count_dict = defaultdict(int)
# All Morgan1 bits have a weight of 4
fp1 = dict(morgan1_count.compute_fingerprint(mol))
count_dict.update((idx, 4) for idx in fp1)
# New Morgan2 bits have a weight of 3,
fp2 = dict(morgan2_count.compute_fingerprint(mol))
for idx, count in fp2.items():
if count > fp1.get(idx, 0):
count_dict[idx] += 3
# New Morgan3 bits have a weight of 2
fp3 = dict(morgan3_count.compute_fingerprint(mol))
for idx, count in fp3.items():
if count > fp2.get(idx, 0):
count_dict[idx] += 2
count_fp = countops.CountFingerprint.from_dict(count_dict)
return countops.create_superimposed_bytes(count_fp, num_bits)
Useful? 🤷