liveBook · Manning

Similarity search

As explained in Build AI Drug Discovery Pipelines

Similarity search retrieves or ranks molecules according to their structural similarity to one or more query molecules.

Similarity search ranks library molecules by how closely they resemble one or more query molecules. In ligand-based virtual screening, a known active compound can serve as the query even when the target’s 3D structure is unavailable. Similar structures may share biological activity, but similarity does not guarantee it; promising hits still need experimental validation. section 2.1.1 section 2.1.3

A practical search involves three linked choices:

  • Representation: convert molecules into features a computer can compare. A molecular fingerprint encodes structural features in a fixed-length bit vector; different fingerprints capture different aspects of structure. section 2.4
  • Similarity metric: measure shared features between pairs of molecules. Tanimoto and Dice coefficients are common choices for binary fingerprints. section 2.5.1
  • Search strategy: rank library molecules and retain the top candidates. With multiple queries, decide how to prioritize a candidate across its similarities to the references. section 2.1.3 section 2.6
Listing 2.8 Featurizing molecules with Morgan fingerprints
from rdkit import DataStructs
from rdkit.Chem import AllChem
from rdkit.Chem.rdFingerprintGenerator import GetMorganGenerator
 
def generate_morgan_fingerprints(    #A
    df, mol_col='mol', radius=2, n_bits=2048    #A
):    #A
    df_copy = df.copy()
    fp_col_name = f"morgan_fp_r{radius}_b{n_bits}"
    morgan_generator = GetMorganGenerator(radius=radius, fpSize=n_bits)
    
    def compute_fingerprint(mol):
        if mol is None: return None
        return morgan_generator.GetFingerprint(mol)
    
    df_copy.loc[:,fp_col_name] = \
        df_copy[mol_col].apply(compute_fingerprint)
    return df_copy, fp_col_name
 
specs_filtered, fp_col_name = generate_morgan_fingerprints(
    specs_filtered
)

This RDKit listing generates Morgan fingerprints for molecules in a dataframe, using a radius of 2 and 2,048 bits by default. section 2.4.3

For fingerprints, Tanimoto similarity divides the number of shared set bits by the number of bits set in either fingerprint. Dice similarity divides twice the number of shared set bits by the sum of the set-bit counts in both fingerprints. Both range from 0 to 1; the score describes similarity in the chosen representation, not a measured biological effect. section 2.5.1 section 2.1.3

Finding antimalarial candidates

Use the 400 known active compounds in the Malaria Box as queries against a diverse chemical library. Fingerprint the molecules, compare each library compound with the queries, and prioritize highly similar candidates for further investigation. Document the fingerprint, metric, and multi-query ranking strategy so others can review and reproduce the search. section 2.1.2 section 2.4 section 2.6

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains fingerprint representation, similarity coefficients, and ranking choices, including the limitations of structural similarity as a proxy for activity.
Examples
Uses the Malaria Box’s 400 active compounds as queries against a diverse library to identify antimalarial candidates.
What you can do after
Evaluate and understand similarity searches by inspecting their representations, metrics, ranking strategies, and need for experimental validation.
How it connects
Connects molecular fingerprints, Tanimoto similarity, Dice similarity, and ligand-based virtual screening.

Also explained in

Compare how 37 books explain similarity search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.