Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added test case to check for UIT failure when matching symmetric query

  • Loading branch information...
commit 8e67dca6df3c7b8880811b97773a0851021ec12b 1 parent a23d689
Rajarshi Guha authored March 30, 2012
62  src/test/org/openscience/cdk/isomorphism/UniversalIsomorphismTesterTest.java
@@ -37,6 +37,7 @@
37 37
 import org.junit.Test;
38 38
 import org.openscience.cdk.Atom;
39 39
 import org.openscience.cdk.AtomContainer;
  40
+import org.openscience.cdk.Bond;
40 41
 import org.openscience.cdk.CDKTestCase;
41 42
 import org.openscience.cdk.ChemFile;
42 43
 import org.openscience.cdk.DefaultChemObjectBuilder;
@@ -58,6 +59,7 @@
58 59
 import org.openscience.cdk.isomorphism.matchers.QueryAtomContainer;
59 60
 import org.openscience.cdk.isomorphism.matchers.QueryAtomContainerCreator;
60 61
 import org.openscience.cdk.isomorphism.matchers.SymbolQueryAtom;
  62
+import org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom;
61 63
 import org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom;
62 64
 import org.openscience.cdk.isomorphism.mcss.RMap;
63 65
 import org.openscience.cdk.smiles.SmilesParser;
@@ -595,6 +597,66 @@ public void testUITTimeoutFix() throws Exception {
595 597
    		Assert.assertTrue(duration < 2000);
596 598
    	}
597 599
 
  600
+    /**
  601
+     * @cdk.bug 3513335
  602
+     * @throws Exception
  603
+     */
  604
+    @Test
  605
+    public void testUITSymmetricMatch() throws Exception {
  606
+        QueryAtomContainer q = new QueryAtomContainer();
  607
+        //setting atoms
  608
+        IQueryAtom a0 = new AliphaticSymbolAtom("C");
  609
+        q.addAtom(a0);
  610
+        IQueryAtom a1 = new AnyAtom();
  611
+        q.addAtom(a1);
  612
+        IQueryAtom a2 = new AnyAtom();
  613
+        q.addAtom(a2);
  614
+        IQueryAtom a3 = new AliphaticSymbolAtom("C");
  615
+        q.addAtom(a3);
  616
+        //setting bonds
  617
+        org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond b0 = new org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond(IBond.Order.SINGLE);
  618
+        b0.setAtoms(new IAtom[]{a0, a1});
  619
+        q.addBond(b0);
  620
+        org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond b1 = new org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond(IBond.Order.SINGLE);
  621
+        b1.setAtoms(new IAtom[]{a1, a2});
  622
+        q.addBond(b1);
  623
+        org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond b2 = new org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond(IBond.Order.SINGLE);
  624
+        b2.setAtoms(new IAtom[]{a2, a3});
  625
+        q.addBond(b2);
  626
+
  627
+
  628
+        //Creating 'SCCS' target molecule
  629
+        AtomContainer target = new AtomContainer();
  630
+        //atoms
  631
+        IAtom ta0 = new Atom("S");
  632
+        target.addAtom(ta0);
  633
+        IAtom ta1 = new Atom("C");
  634
+        target.addAtom(ta1);
  635
+        IAtom ta2 = new Atom("C");
  636
+        target.addAtom(ta2);
  637
+        IAtom ta3 = new Atom("S");
  638
+        target.addAtom(ta3);
  639
+        //bonds
  640
+        IBond tb0 = new Bond();
  641
+        tb0.setAtoms(new IAtom[]{ta0, ta1});
  642
+        tb0.setOrder(IBond.Order.SINGLE);
  643
+        target.addBond(tb0);
  644
+
  645
+        IBond tb1 = new Bond();
  646
+        tb1.setAtoms(new IAtom[]{ta1, ta2});
  647
+        tb1.setOrder(IBond.Order.SINGLE);
  648
+        target.addBond(tb1);
  649
+
  650
+        IBond tb2 = new Bond();
  651
+        tb2.setAtoms(new IAtom[]{ta2, ta3});
  652
+        tb2.setOrder(IBond.Order.SINGLE);
  653
+        target.addBond(tb2);
  654
+
  655
+
  656
+        //Isomorphism check
  657
+        boolean res = UniversalIsomorphismTester.isSubgraph(target, q);
  658
+        Assert.assertFalse("C**C should not match SCCS", res);
  659
+    }
598 660
 
599 661
 }
600 662
 

0 notes on commit 8e67dca

Please sign in to comment.
Something went wrong with that request. Please try again.