Skip to content

Commit

Permalink
Added test case for bug 3513954, OOM in equivalent class partitioner
Browse files Browse the repository at this point in the history
Change-Id: Idc905aa1a60b3c8d58a3b675ec66f111422ae525
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed Apr 14, 2012
1 parent 0aa84d7 commit 7477f99
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 1 deletion.
74 changes: 74 additions & 0 deletions src/test/data/mdl/equivClassPartiOOMBug.sdf
@@ -0,0 +1,74 @@

Marvin 06130811552D

30 33 0 0 1 0 999 V2000
0.7550 -0.2220 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.3681 0.3300 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.0325 1.0837 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.5174 1.7511 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.3379 1.6649 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.6735 0.9112 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.1885 0.2438 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.2120 0.9975 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
0.0405 0.1905 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.6740 -0.2220 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.6740 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0405 -1.4595 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7550 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.4694 -1.4595 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
2.1839 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8984 -1.4595 0.0000 C 0 0 1 0 0 0 0 0 0 0 0 0
3.6128 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.3273 -1.4595 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0
5.0418 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7563 -1.4595 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.4707 -1.0470 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
7.1852 -1.4595 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.8997 -1.0470 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.6141 -1.4595 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.6141 -2.2845 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.8997 -2.6970 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.1852 -2.2845 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.8997 -0.2220 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
8.6141 0.1905 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8984 -2.2845 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 4 0 0 0 0
2 3 4 0 0 0 0
3 4 4 0 0 0 0
4 5 4 0 0 0 0
5 6 4 0 0 0 0
6 7 4 0 0 0 0
2 7 4 0 0 0 0
3 8 4 0 0 0 0
8 9 4 0 0 0 0
1 9 4 0 0 0 0
9 10 4 0 0 0 0
10 11 4 0 0 0 0
11 12 4 0 0 0 0
12 13 4 0 0 0 0
1 13 4 0 0 0 0
13 14 1 0 0 0 0
14 15 1 0 0 0 0
15 16 1 0 0 0 0
16 17 1 0 0 0 0
17 18 1 0 0 0 0
18 19 1 0 0 0 0
19 20 1 0 0 0 0
20 21 1 0 0 0 0
21 22 1 0 0 0 0
22 23 4 0 0 0 0
23 24 4 0 0 0 0
24 25 4 0 0 0 0
25 26 4 0 0 0 0
26 27 4 0 0 0 0
22 27 4 0 0 0 0
23 28 1 0 0 0 0
28 29 1 0 0 0 0
16 30 1 1 0 0 0
M STY 1 1 DAT
M SAL 1 1 8
M SDT 1 MRV_IMPLICIT_H
M SDD 1 0.0000 0.0000 DR ALL 0 0
M SED 1 IMPL_H1
M END
$$$$
Expand Up @@ -25,7 +25,14 @@
import org.openscience.cdk.Atom;
import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.PseudoAtom;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.io.MDLV2000Reader;

import java.io.InputStream;

/**
* Checks the functionality of the TopologicalEquivalentClass.
Expand Down Expand Up @@ -230,5 +237,31 @@ public class EquivalentClassPartitionerTest extends CDKTestCase
Assert.assertTrue(equivalentClass[0]==2);//number of Class
Assert.assertEquals("111111222222222222111111",strEquivalent);
}


/**
* @cdk.bug 3513954
* @throws Exception
*/
@Test
public void testPseudoAtoms() throws Exception {
String filename = "data/mdl/pseudoatoms.sdf";

InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
IAtomContainer mol = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
mol = reader.read(mol);
Assert.assertNotNull(mol);

// check that there are some pseudo-atoms
boolean hasPseudo = false;
for (IAtom atom : mol.atoms()) {
if (atom instanceof PseudoAtom) hasPseudo = true;
}
Assert.assertTrue("The molecule should have one or more pseudo atoms", hasPseudo);

EquivalentClassPartitioner partitioner = new EquivalentClassPartitioner(mol);
Assert.assertNotNull(partitioner);

int[] classes = partitioner.getTopoEquivClassbyHuXu(mol);
}
}

0 comments on commit 7477f99

Please sign in to comment.