Skip to content

Commit

Permalink
Four unit tests that test if the fingerprint calculation is affected …
Browse files Browse the repository at this point in the history
…by atom or bond permutation

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 5, 2010
1 parent 714c51e commit d3bea1a
Showing 1 changed file with 63 additions and 5 deletions.
68 changes: 63 additions & 5 deletions src/test/org/openscience/cdk/fingerprint/FingerprinterTest.java
Expand Up @@ -24,12 +24,18 @@
*/
package org.openscience.cdk.fingerprint;

import java.io.InputStream;
import java.math.BigInteger;
import java.util.BitSet;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.Atom;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.Reaction;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.AtomContainerAtomPermutor;
import org.openscience.cdk.graph.AtomContainerBondPermutor;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
Expand All @@ -40,10 +46,6 @@
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;

import java.io.InputStream;
import java.math.BigInteger;
import java.util.BitSet;

/**
* @cdk.module test-standard
*/
Expand Down Expand Up @@ -172,7 +174,63 @@ public void testBug2819557() throws CDKException {
Assert.assertFalse("butane should not be a substructure of propylamine", FingerprinterTool.isSubset(b2, b1));
}

public static Molecule makeFragment1()
@Test
public void testBondPermutation() throws CDKException {
IMolecule pamine = makePropylAmine();
Fingerprinter fp = new Fingerprinter();
BitSet bs1 = fp.getFingerprint(pamine);

AtomContainerBondPermutor acp = new AtomContainerBondPermutor(pamine);
while (acp.hasNext()) {
IAtomContainer container = acp.next();
BitSet bs2 = fp.getFingerprint(container);
Assert.assertTrue(bs1.equals(bs2));
}
}

@Test
public void testAtomPermutation() throws CDKException {
IMolecule pamine = makePropylAmine();
Fingerprinter fp = new Fingerprinter();
BitSet bs1 = fp.getFingerprint(pamine);

AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);
while (acp.hasNext()) {
IAtomContainer container = acp.next();
BitSet bs2 = fp.getFingerprint(container);
Assert.assertTrue(bs1.equals(bs2));
}
}

@Test
public void testBondPermutation2() throws CDKException {
IMolecule pamine = MoleculeFactory.makeCyclopentane();
Fingerprinter fp = new Fingerprinter();
BitSet bs1 = fp.getFingerprint(pamine);

AtomContainerBondPermutor acp = new AtomContainerBondPermutor(pamine);
while (acp.hasNext()) {
IAtomContainer container = acp.next();
BitSet bs2 = fp.getFingerprint(container);
Assert.assertTrue(bs1.equals(bs2));
}
}

@Test
public void testAtomPermutation2() throws CDKException {
IMolecule pamine = MoleculeFactory.makeCyclopentane();
Fingerprinter fp = new Fingerprinter();
BitSet bs1 = fp.getFingerprint(pamine);

AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);
while (acp.hasNext()) {
IAtomContainer container = acp.next();
BitSet bs2 = fp.getFingerprint(container);
Assert.assertTrue(bs1.equals(bs2));
}
}

public static Molecule makeFragment1()
{
Molecule mol = new Molecule();
mol.addAtom(new Atom("C")); // 0
Expand Down

0 comments on commit d3bea1a

Please sign in to comment.