Finding the Maximum Common Substructure (MCS) of two molecules is a problem with many applications in the field of cheminformatics. It can be used for similarity search, hierarchical clustering, molecule alignment, and automated reaction mapping. An example is presented in Fig. 1.
ChemAxon provides powerful heuristic algorithms for MCS search, which typically find large common substructures in a short time. However, they do not always provide the exact optimal result due to the complexity of the MCS problem (especially for large molecules).
Fig. 1. Maximum Common Substructure (MCS) of two molecules
From a graph theoretical point of view, the MCS of two molecules is defined as the maximum common edge subgraph (MCES) of the two molecule graphs. That is, MCS and MCES mean exactly the same in ChemAxon's terminology.
Even though the roles of the two molecules in MCS search are generally the same, we distinguish a query and a target molecule. The reason for this is that some special query features are only allowed in the query molecule (see details below).
MCS search can be customized using various search options:
Furthermore, two search modes are provided with different speed/accuracy trade-off. Consider to use the FAST mode if you prefer search speed rather than more accurate MCS results.
Formal charges of the atoms need not match.
Formal charges of the atoms should match.
The MCS can consist of multiple fragments.
The MCS should consist of only one fragment.
Table 2. Connected mode
|Ring handling mode||Query||Target|
Ring/chain property is ignored.
Two bonds match only if both are in rings or both are in chains.
Rings should not be broken.
Table 3. Ring handling mode
Note that the latter two options only consider rings within a given size limit. The default maximum size is eight, i.e. rings of nine or more atoms may be broken even if KEEP_RINGS option is used. (However, this limit can also be changed.)
The following query features are supported in MCS search, but only in the query molecule:
generic query atoms (any, halogen, metal, etc.)
atoms lists, not lists;
generic bonds (any, single or double, etc.)
However, complex features such as stereochemistry, tautomers and Markush structures are not supported.
JChem also provides a simple command line application for MCS search (mainly for evaluation and demonstration purposes).
The program can be used as:
-h, --help print this help message
-v, --verbose verbose mode
-q, --query <string> query structure string or file name (multiple queries are allowed)
-t, --target <string> target structure string or file name (multiple targets are allowed)
-o, --output <file> output file path and name
-f, --format CSV output format (only CSV is supported)
-w, --view display the molecules with the MCS highlighted
-g, --grid display common substructures in a grid view (for multiple queries and/or targets)
-a, --atommaps mark matching atoms with map numbers (only in -w mode)
-m, --match ( a[tomtype] | b[ondtype] | c[harge] | i[sotopes] | r[adical] | m[apnumber] ) atom and bond matching mode A + or - sign after each property indicates if it should match or not.
By default, only atom and bond types are considered.
-c, --connected search for a connected common substructure
-s, --minsize <bonds> minimum required size of extra fragments (the default is 1)
-x, --mode ( f[ast] | n[ormal] ) search mode (controls speed and accuracy)
-r, --keeprings small rings should not be broken
Example 1. Search MCS of the given query (-q) and target (-t) molecules.
mcs -q "C12CCC(O)C1(C)CCC1C2CCC2=CC(=O)CCC12C" -t "CC(=O)C1CCC2C3CCC4=CC(=O)CCC4(C)C3CCC12C"
Query: CC12CCC3C(CCC4=CC(=O)CCC34C)C1CCC2O Target: CC(=O)C1CCC2C3CCC4=CC(=O)CCC4(C)C3CCC12C MCS: CC12CCCC1C1CCC3=CC(=O)CCC3(C)C1CC2 Atom count: 20 Bond count: 23 Fragment count: 1 Similarity score: 0.8519
Example 2. Search MCS of the given two molecules (-q, -t) and display the results (-w).
mcs -w -q "CN(O)C1=CC(=CC=C1)C(O)=O" -t "OC(=O)CC1=CC=C(C=C1)[N+]([O-])=O"
Example 3. Search connected MCS (-c) of the given two molecules (-q, -t) using charge matching (-m c+) and display the results (-w) including atom mapping numbers (-a).
mcs -c -m c+ -w -a -q "CN(O)C1=CC(=CC=C1)C(O)=O" -t "OC(=O)CC1=CC=C(C=C1)[N+]([O-])=O"
Example 4. Search pairwise MCS of the molecules in the given two input files (-q, -t) and display the results in a grid view (-g).
mcs -g -q queries.mrv -t targets.smiles
com.chemaxon.search.mcs package contains classes that provide an API for MCS search. Here is a simple example demonstrating the usage of these classes:
You can specify search options like this: