Skip to content

Commit

Permalink
Added unit test for bug 2871303, which appears to be resolved now
Browse files Browse the repository at this point in the history
  • Loading branch information
rajarshi committed Oct 19, 2010
1 parent 74f8661 commit cc163e1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
Expand Up @@ -28,14 +28,14 @@
*/
package org.openscience.cdk.fingerprint;

import java.util.BitSet;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.smiles.SmilesParser;

import java.util.BitSet;

/**
* @cdk.module test-fingerprint
*/
Expand Down Expand Up @@ -87,5 +87,22 @@ public void testFingerprint() throws Exception {
Assert.assertTrue(fp.get(1));
Assert.assertFalse(fp.get(100));
}

/**
* @cdk.bug 2871303
*
* While this test fails, Daylight says that the
* SMARTS pattern used for vinylogous ester should
* match benzaldehyde twice. So according to the
* supplied definition this answer is actually correct.
*/
@Test
public void testVinylogousEster() throws Exception {
String benzaldehyde = "c1ccccc1C=O";
IFingerprinter fprinter = new SubstructureFingerprinter();
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
BitSet fp = fprinter.getFingerprint(sp.parseSmiles(benzaldehyde));
Assert.assertFalse("Bit 136 (vinylogous ester) is set to true", fp.get(136));
}
}

Expand Up @@ -20,9 +20,6 @@
*/
package org.openscience.cdk.smiles.smarts.parser;

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

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKTestCase;
Expand All @@ -41,6 +38,9 @@
import org.openscience.cdk.tools.LoggingToolFactory;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;

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

/**
* JUnit test routines for the SMARTS substructure search.
*
Expand All @@ -50,7 +50,7 @@
*/
public class SMARTSSearchTest extends CDKTestCase {

private static ILoggingTool logger =
private static ILoggingTool logger =
LoggingToolFactory.createLoggingTool(SMARTSSearchTest.class);

private int[] match(String smarts, String smiles) throws Exception {
Expand Down Expand Up @@ -1627,6 +1627,18 @@ public void testLeadingHydrogen() throws Exception {
Assert.assertEquals(1, results[1]);
}


/**
* @cdk.bug 2871303
* <p/>
* Note that this test passes, and really indicates that
* the SMARTS below is not a correct one for vinylogous
* esters
*/
@Test
public void testVinylogousEster() throws Exception {
int[] results = match("[#6X3](=[OX1])[#6X3]=,:[#6X3][#6;!$(C=[O,N,S])]", "c1ccccc1C=O");
Assert.assertEquals(2, results[0]);
Assert.assertEquals(2, results[1]);
}
}

0 comments on commit cc163e1

Please sign in to comment.