Skip to content

Commit 2b1288b

Browse files
jonalvegonw
authored andcommitted
Wrote test for KlekotaRothFingerprinter
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
1 parent 84aed70 commit 2b1288b

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

src/main/org/openscience/cdk/fingerprint/KlekotaRothFingerprinter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
package org.openscience.cdk.fingerprint;
99

1010

11+
import org.openscience.cdk.annotations.TestClass;
12+
1113
/**
1214
* SMARTS based substructure fingerprint based on <emph>Chemical substructures
1315
* that enrich for biological activity</emph> {@cdk.cite Klekota01112008}.
@@ -18,6 +20,7 @@
1820
* @cdk.module fingerprint
1921
* @cdk.githash
2022
*/
23+
@TestClass("org.openscience.cdk.fingerprint.KlekotaRothFingerprinterTest")
2124
public class KlekotaRothFingerprinter extends SubstructureFingerprinter
2225
{
2326

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (C) 2011 Jonathan Alvarsson <jonalv@users.sf.net>
3+
*
4+
* Contact: cdk-devel@lists.sourceforge.net
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public License
8+
* as published by the Free Software Foundation; either version 2.1
9+
* of the License, or (at your option) any later version.
10+
* All I ask is that proper credit is given for my work, which includes
11+
* - but is not limited to - adding the above copyright notice to the beginning
12+
* of your source code files, and to any copyright notice that you may distribute
13+
* with programs based on this work.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with this program; if not, write to the Free Software
22+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23+
*/
24+
package org.openscience.cdk.fingerprint;
25+
26+
import java.util.BitSet;
27+
28+
import org.junit.Assert;
29+
import org.junit.Test;
30+
import org.openscience.cdk.silent.SilentChemObjectBuilder;
31+
import org.openscience.cdk.smiles.SmilesParser;
32+
33+
/**
34+
* @cdk.module test-fingerprint
35+
*/
36+
public class KlekotaRothFingerprinterTest extends AbstractFingerprinterTest {
37+
38+
public IFingerprinter getFingerprinter() {
39+
return new KlekotaRothFingerprinter();
40+
}
41+
42+
@Test
43+
public void testGetSize() throws Exception {
44+
IFingerprinter printer = getFingerprinter();
45+
Assert.assertEquals(4860, printer.getSize());
46+
}
47+
48+
@Test
49+
public void testFingerprint() throws Exception {
50+
SmilesParser parser = new SmilesParser(SilentChemObjectBuilder.getInstance());
51+
IFingerprinter printer = getFingerprinter();
52+
53+
BitSet bs1 = printer.getFingerprint(parser.parseSmiles("C=C-C#N"));
54+
BitSet bs2 = printer.getFingerprint(parser.parseSmiles("C=CCC(O)CC#N"));
55+
56+
Assert.assertEquals(4860,printer.getSize());
57+
58+
Assert.assertTrue(FingerprinterTool.isSubset(bs2, bs1));
59+
}
60+
}

src/test/org/openscience/cdk/modulesuites/MfingerprintTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.openscience.cdk.coverage.FingerprintCoverageTest;
2727
import org.openscience.cdk.fingerprint.EStateFingerprinterTest;
2828
import org.openscience.cdk.fingerprint.ExtendedFingerprinterTest;
29+
import org.openscience.cdk.fingerprint.KlekotaRothFingerprinterTest;
2930
import org.openscience.cdk.fingerprint.MACCSFingerprinterTest;
3031
import org.openscience.cdk.fingerprint.PubchemFingerprinterTest;
3132
import org.openscience.cdk.similarity.DistanceMomentTest;
@@ -45,6 +46,7 @@
4546
EStateFingerprinterTest.class,
4647
PubchemFingerprinterTest.class,
4748
DistanceMomentTest.class,
48-
TanimotoTest.class
49+
TanimotoTest.class,
50+
KlekotaRothFingerprinterTest.class
4951
})
5052
public class MfingerprintTests {}

0 commit comments

Comments
 (0)