Skip to content

Commit

Permalink
More unit tests for the MCSS problem in bug report 2944080.
Browse files Browse the repository at this point in the history
Signed-off-by: Rajarshi  Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Mar 1, 2010
1 parent af12e8a commit 3d18a73
Showing 1 changed file with 122 additions and 3 deletions.
Expand Up @@ -59,6 +59,7 @@
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

import java.io.InputStream;
import java.util.BitSet;
import java.util.Iterator;
import java.util.List;

Expand Down Expand Up @@ -177,10 +178,10 @@ public class UniversalIsomorphismTesterTest extends CDKTestCase
CDKHueckelAromaticityDetector.detectAromaticity(mol);
CDKHueckelAromaticityDetector.detectAromaticity(frag1);

List list = UniversalIsomorphismTester.getSubgraphAtomsMaps(mol, frag1);
List first = (List)list.get(0);
List<List<RMap>> list = UniversalIsomorphismTester.getSubgraphAtomsMaps(mol, frag1);
List<RMap> first = list.get(0);
for (int i = 0; i < first.size(); i++) {
RMap rmap = (RMap)first.get(i);
RMap rmap = first.get(i);
Assert.assertEquals(rmap.getId1(), result1[i]);
Assert.assertEquals(rmap.getId2(), result2[i]);
}
Expand Down Expand Up @@ -255,6 +256,124 @@ public class UniversalIsomorphismTesterTest extends CDKTestCase
Assert.assertEquals(9, list.get(0).getAtomCount());
}

/**
* @cdk.bug 2944080
*/
@Test public void testGetSubgraphAtomsMap_2944080() throws Exception {
SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol1 = smilesParser.parseSmiles("CCC(CC)(C(=O)NC(=O)NC(C)=O)Br");
IMolecule mol2 = smilesParser.parseSmiles("CCCC(=O)NC(N)=O");

//Test for atom mapping between the mols
List<RMap> maplist = UniversalIsomorphismTester.getSubgraphAtomsMap(mol1, mol2);
Assert.assertNotNull(maplist);
Assert.assertEquals(9, maplist.size());
}

/**
* @cdk.bug 2944080
*/
@Test public void testGetSubgraphMap_2944080() throws Exception {
SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol1 = smilesParser.parseSmiles("CCC(CC)(C(=O)NC(=O)NC(C)=O)Br");
IMolecule mol2 = smilesParser.parseSmiles("CCCC(=O)NC(N)=O");

//Test for atom mapping between the mols
List<RMap> maplist = UniversalIsomorphismTester.getSubgraphMap(mol1, mol2);
Assert.assertNotNull(maplist);
Assert.assertEquals(8, maplist.size());
}

/**
* @cdk.bug 2944080
*/
@Test public void testSearchNoConditions_2944080() throws Exception {
SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol1 = smilesParser.parseSmiles("CCC(CC)(C(=O)NC(=O)NC(C)=O)Br");
IMolecule mol2 = smilesParser.parseSmiles("CCCC(=O)NC(N)=O");

//Test for atom mapping between the mols
List<List<RMap>> maplist = UniversalIsomorphismTester.search(
mol1, mol2, new BitSet(),
UniversalIsomorphismTester.getBitSet(mol2),
false, false
);
Assert.assertNotNull(maplist);
Assert.assertEquals(1, maplist.size());
}

/**
* @cdk.bug 2944080
*/
@Test public void testSearch_2944080() throws Exception {
SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol1 = smilesParser.parseSmiles("CCC(CC)(C(=O)NC(=O)NC(C)=O)Br");
IMolecule mol2 = smilesParser.parseSmiles("CCC(=CC)C(=O)NC(N)=O");

//Test for atom mapping between the mols
List<List<RMap>> list = UniversalIsomorphismTester.
search(mol1, mol2, new BitSet(), new BitSet(), true, true);
Assert.assertEquals(3, list.size());
for (int i=0; i<list.size(); i++) {
List<RMap> first = list.get(i);
Assert.assertNotSame(0, first.size());
}

list = UniversalIsomorphismTester.
search(mol1, mol2, new BitSet(), new BitSet(), false, false);
Assert.assertEquals(1, list.size());
for (int i=0; i<list.size(); i++) {
List<RMap> first = list.get(i);
Assert.assertNotSame(0, first.size());
}
}

/**
* @cdk.bug 2944080
*/
@Test public void testGetSubgraphAtomsMaps_2944080() throws Exception {
SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IMolecule mol1 = smilesParser.parseSmiles("CCC(CC)(C(=O)NC(=O)NC(C)=O)Br");
IMolecule mol2 = smilesParser.parseSmiles("CCCC(=O)NC(N)=O");

List<List<RMap>> list = UniversalIsomorphismTester.getSubgraphAtomsMaps(mol1, mol2);
Assert.assertNotNull(list);
Assert.assertNotSame(0, list.size());
for (int i=0; i<list.size(); i++) {
List<RMap> first = list.get(i);
Assert.assertNotNull(first);
Assert.assertNotSame(0, first.size());
}
}

@Test public void testGetSubgraphAtomsMap_Butane() throws Exception {
IMolecule mol1 = MoleculeFactory.makeAlkane(4);
IMolecule mol2 = MoleculeFactory.makeAlkane(4);

// Test for atom mapping between the mols
List<RMap> maplist = UniversalIsomorphismTester.getSubgraphAtomsMap(mol2, mol1);
Assert.assertNotNull(maplist);
Assert.assertEquals(4, maplist.size());

maplist = UniversalIsomorphismTester.getSubgraphAtomsMap(mol1, mol2);
Assert.assertNotNull(maplist);
Assert.assertEquals(4, maplist.size());
}

@Test public void testGetSubgraphAtomsMaps_Butane() throws Exception {
IMolecule mol1 = MoleculeFactory.makeAlkane(4);
IMolecule mol2 = MoleculeFactory.makeAlkane(4);

List<List<RMap>> list = UniversalIsomorphismTester.getSubgraphAtomsMaps(mol1, mol2);
Assert.assertNotNull(list);
Assert.assertEquals(2, list.size());
for (int i=0; i<list.size(); i++) {
List<RMap> first = list.get(i);
Assert.assertNotNull(first);
Assert.assertEquals(4, first.size());
}
}

/**
* @cdk.bug 1208740
*/
Expand Down

0 comments on commit 3d18a73

Please sign in to comment.