Chem: Molecular Graph-Based Similarity
Tags: Substructure, Chemoinformatics, Chemistry, Algorithms

This post will explain how Molecular Graph-Based Similarity is calculated to find subgraph/substructure. There are many algorithms for this purpose but we are going to get through 3 algorithms.

Subgraph/Substructure Search

We need to define what is a subgraph and what is a subgraph search. First of all, the subgraph is part of the chemical structure. You can check it with the above graph. We want to search for every chemical that has exactly the same substructure. We have a compound database and a small query fragment(substructure).

This is an example of a query. We put a query to the algorithm and the algorithm gets through the database and find the chemicals that have exactly the same substructure.

This is an example of a subgraph. If the subgraph has a different edge, it is not a subgraph anymore. Every node and edge has to be in the graph.

Brute Force Approach

Unfortunately, the subgraph search is an NP-complete problem because it causes exponential time increase with the number of graph nodes. Therefore, we should use heuristics with improved efficiency.

Back-Tracking Method

It is based on a connection table, we need to have every connection table for a query structure and database molecule. The heuristics are backtracking, it reduces the search space of the subgraph isomorphism problem.

Initialization

We arbitrarily choose the start atom in a query, hetero-atom is usually picked because it occurs less frequently than carbon. Then, we match the selected atom to the database compound.

2. Recursion/ Back-Tracking

We search the neighboring atoms by connection tables. If we met the different atom during searching, it uses the back-tracking heuristics, it goes back to the previous step and searches other branches. If there is no option left, then we change the starting point. To sum up, atom a and atom b are considered to match, if and only if for each element in molecule A, a match exists in molecule B. If the condition is not matched, then it uses back-tracking.

This is a complete algorithm.

3. Termination

It terminates the algorithm with a complete match or report of failure.

Ullmann Algorithm

This algorithm is based on adjacency matrices, we need every compound to have adjacency matrices. This algorithm searches the substructure by constructing a matching matrix. It identifies a mapping of a query structure to the database compound from the matching matrix.

Adjacency Matrix

This is an adjacency matrix. Rows and columns correspond to atoms. If they are connected to each other, then the corresponding position in the matrix are set to 1 else to 0. Therefore, adjacency matrices are always symmetrical.

It builds the matching matrix, this is the adjacency matrix. Its rows and columns will be query compound nodes and database compound nodes respectively. Therefore, we can search for the substructure. The target matching matrix is that each row has exactly one “1” and each column has at most one “1”. The database compound entirely contains the query compound when this condition is met.

It also uses heuristics. It considers local information. An atom in a query is not allowed to match an atom in a database compound unless each neighbor also matches. This is a new version of backtracking in the adjacency matrix.

Initialization

The first atom is corresponding to the first row in a query compound. It finds the first possible match in the database compound. We change the corresponding matching matrix position to 1.

2. Heuristic/Refinement

It shows the process and back-tracking. 3 position in a query compound does not match with 3 positions in the database compound. Therefore, it goes back to another branch. However, we cannot match this because the neighbor of 3 in S is 2, and the neighbor of 4 in M is 3. Therefore, we need to match 2 in S and 3 in M but it was not. We track back further.

We chose 2 in S and 1 in M and we went back and we choose 2 in S and 3 in M. We can finish the algorithm with a new path.

3. Termination

It recurses until a complete match is found or all possible matching matrix is tested an failed.

MCS

What we are trying to do is finding the compound that has the query compound. Now, we change the query to finding the MCS between two compounds. MCS is the largest set of atoms that are shared by two structures.

This is also an NP-complete problem. Thus, we need heuristics to solve this problem.

McGregor Algorithm

Initialization

We build the MCS graph and if it finds the bigger one than the previous one, we update the MCS graph. The starting point can be anywhere.

2. Recursion/ Back-Tracking

The recursion part is the same as the Back-tracking methods.

3. Termination

It is terminated when a given structure is completely contained in another one and all back-tracking paths are explored. It returns the currently stored MCS.

This post is published on 9/29/2020

Gain Access to Expert View — Subscribe to DDI Intel