The Dice similarity coefficient compares two molecular fingerprints: binary feature representations of molecules. It divides twice the number of shared nonzero features by the total number of nonzero features in both fingerprints. Scores range from 0, meaning no shared features, to 1, meaning complete fingerprint similarity; a score of 1 does not prove that two molecules are identical. section 2.5.1
Use Dice similarity in ligand-based screening to rank molecules against a query fingerprint. Compared with Tanimoto similarity, Dice usually produces higher scores for the same pair, so the similarity threshold must match the metric. section 2.5.1 section 2.5.2
A practical Dice-based search follows this workflow:
- Generate fingerprints for the query molecules and the searchable compound library. section 2.5.2
- Compute bulk Dice similarities between each query fingerprint and the library fingerprints. section 2.5.2
- Retain compounds meeting a chosen threshold, then rank or limit the matches for downstream screening. section 2.5.2
Malaria Box similarity search
A query compound from the Malaria Box can be compared with a filtered compound library using bulk Dice similarity. With a threshold of 0.65, more compounds may qualify as hits than under Tanimoto similarity; the selected matches can then be reduced to a fixed budget and saved for further screening. section 2.5.2
Listing 2.10 Computing Similarity against a Query
malaria_box = pd.read_excel(
"data/MalariaBox400compoundsDec2014.xls",
usecols=["HEOS_COMPOUND_ID", "Smiles"]
)
PandasTools.AddMoleculeColumnToFrame(malaria_box, 'Smiles', 'mol')
malaria_box, malaria_fp_col = generate_morgan_fingerprints(malaria_box)
query_idx = 236 #A
query_fp = malaria_box[malaria_fp_col].iloc[query_idx]
query_mol = malaria_box.mol.iloc[query_idx]
library_fps = specs_filtered[fp_col_name].tolist()
specs_filtered["tanimoto_sim"] = DataStructs.BulkTanimotoSimilarity(
query_fp, library_fps
) #B
specs_filtered["dice_sim"] = DataStructs.BulkDiceSimilarity(
query_fp,
library_fps
)
def visualize_similarity_extremes(df, sim_col, n=3):
df_ordered = df.sort_values([sim_col], ascending=False).reset_index()
extremes = pd.concat([df_ordered[:n], df_ordered.dropna()[-n:]])
legend_text=[f"{x:.2f}" for x in extremes[sim_col]]
return Draw.MolsToGridImage(
extremes.mol, molsPerRow=3, legends=legend_text
)
visualize_similarity_extremes(specs_filtered, "tanimoto_sim")
sns.pairplot(specs_filtered[["tanimoto_sim", "dice_sim"]])Inspect the runnable query-comparison pattern using fingerprint columns, BulkDiceSimilarity, and similarity-extreme visualization. section 2.5.2
