19.3 Clique Search

Clique detection is a bounded common structure search. It is a useful search method in cases where common substructure(s) other than the maximum common substructure(s) need to be identified. The following example demonstrates a clique search.

 1 import openeye.oechem.*;
 2
 3 public class CliqueSearch
 4 {
 5   public static void main(String argv[])
 6   {
 7     OEGraphMol pattern = new OEGraphMol();
 8     OEGraphMol target  = new OEGraphMol();
 9     oechem.OEParseSmiles(pattern,"c1cc(O)c(O)cc1CCN");
10     oechem.OEParseSmiles(target, "c1c(O)c(O)c(Cl)cc1CCCBr");
11     /* create clique earch object */
12     OECliqueSearch cs = new OECliqueSearch(pattern, OEExprOpts.DefaultAtoms,
13         OEExprOpts.DefaultBonds);
14     /* ignore cliques that differ by more than 5 atoms from MCS */
15     cs.SetSaveRange(5);
16
17     int count = 1;
18     /* loop over matches */
19     for (OEMatchBaseIter match = cs.Match(target); match.hasNext();)
20     {
21       System.out.println("Match "+count+ " :");
22       System.out.println("pattern atoms: ");
23       OEMatchPairAtomIter ma = match.next().GetAtoms();
24       for( ;ma.hasNext(); )
25         System.out.print(ma.next().getPattern().GetIdx()+" ");
26       System.out.println();
27       ma.ToFirst();
28       System.out.println("target atoms:  ");
29       for( ;ma.hasNext(); )
30         System.out.print(ma.next().getTarget().GetIdx()+" ");
31       System.out.println();
32       count++;
33     }
34   }
35 }

Listing:19.4 Clique search example

The same molecules and expression options are used as in Listing 19.3, however, an iterator over all identified cliques is returned by the OECliqueSearch.Match method. The OECliqueSearch.SetSaveRange method bounds the search. In this case, cliques returned will only differ by five nodes relative to the maximum common substructure. The atom correspondences for each of the returned cliques are printed in the example program.