Permalink
Browse files

Move test resources to be local to the test that requires them. These…

… files in particularly have been reused in pcore/io so the originals have been left in place for the moment.

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
1 parent 17b5f5b commit 55e30c698a6e31768d201c8e5649c7341b1521f2 @johnmay johnmay committed with egonw Feb 18, 2014
View
@@ -124,13 +124,6 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>cdk-testdata</artifactId>
- <version>${project.parent.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
</dependencies>
@@ -383,8 +383,8 @@ public void match(String smarts, String smiles) throws Exception {
@Test public void testBasicAmineOnDrugs_cdkAromaticModel() throws Exception {
- String filename = "data/smiles/drugs.smi";
- InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
+ String filename = "drugs.smi";
+ InputStream ins = this.getClass().getResourceAsStream(filename);
IteratingSMILESReader reader = new IteratingSMILESReader(
ins, DefaultChemObjectBuilder.getInstance()
);
@@ -418,8 +418,8 @@ public void match(String smarts, String smiles) throws Exception {
}
@Test public void testBasicAmineOnDrugs() throws Exception {
- String filename = "data/smiles/drugs.smi";
- InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
+ String filename = "drugs.smi";
+ InputStream ins = this.getClass().getResourceAsStream(filename);
SMARTSQueryTool sqt = new SMARTSQueryTool("[NX3;H2,H1;!$(NC=O)]", DefaultChemObjectBuilder.getInstance());
@@ -25,21 +25,21 @@
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
+import org.junit.Ignore;
import org.junit.Test;
-import org.openscience.cdk.CDKConstants;
+import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.CDKTestCase;
import org.openscience.cdk.ChemFile;
import org.openscience.cdk.ChemObject;
import org.openscience.cdk.DefaultChemObjectBuilder;
-import org.openscience.cdk.aromaticity.Aromaticity;
-import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
-import org.openscience.cdk.aromaticity.ElectronDonation;
+import org.openscience.cdk.aromaticity.Aromaticity;
+import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
+import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
-import org.openscience.cdk.graph.Cycles;
+import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.interfaces.IAtomContainer;
-import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.io.DefaultChemObjectReader;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.isomorphism.UniversalIsomorphismTester;
@@ -48,7 +48,7 @@
import org.openscience.cdk.smiles.smarts.SMARTSQueryTool;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
-import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
+import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;
import static org.hamcrest.CoreMatchers.is;
@@ -77,20 +77,20 @@ static IAtomContainer smiles(String smiles) throws
InvalidSmilesException {
return smiles(smiles, false);
}
-
- static IAtomContainer smilesAtomTyped(String smiles) throws
- CDKException {
- IAtomContainer molecule = smiles(smiles, false);
- AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
- return molecule;
- }
+
+ static IAtomContainer smilesAtomTyped(String smiles) throws
+ CDKException {
+ IAtomContainer molecule = smiles(smiles, false);
+ AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
+ return molecule;
+ }
static IAtomContainer smiles(String smiles,
boolean perserveAromaticity) throws
InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder
.getInstance());
- sp.kekulise(!perserveAromaticity);
+ sp.kekulise(!perserveAromaticity);
return sp.parseSmiles(smiles);
}
@@ -112,13 +112,13 @@ static SMARTSQueryTool smarts(String smarts) {
}
}
- static int[] match(String smarts, String smiles) throws Exception {
+ static int[] match(String smarts, String smiles) throws Exception {
return match(smarts(smarts), smiles(smiles));
}
@Test public void testMoleculeFromSDF() throws CDKException {
- String filename = "data/mdl/cnssmarts.sdf";
- InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
+ String filename = "cnssmarts.sdf";
+ InputStream ins = this.getClass().getResourceAsStream(filename);
DefaultChemObjectReader reader = new MDLV2000Reader(ins);
ChemFile content;
content = (ChemFile) reader.read((ChemObject) new ChemFile());
@@ -154,7 +154,7 @@ static SMARTSQueryTool smarts(String smarts) {
QueryAtomContainer query = SMARTSParser.parse("c:c", DefaultChemObjectBuilder.getInstance());
logger.debug("Query c:c: " + query.toString());
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- sp.kekulise(false);
+ sp.kekulise(false);
IAtomContainer atomContainer = sp.parseSmiles("c1ccccc1"); // benzene, aromatic
Assert.assertTrue(uiTester.isSubgraph(atomContainer, query));
@@ -257,7 +257,7 @@ static SMARTSQueryTool smarts(String smarts) {
QueryAtomContainer query = SMARTSParser.parse("aaa", DefaultChemObjectBuilder.getInstance());
logger.debug("Query CaC: " + query.toString());
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
- sp.kekulise(false);
+ sp.kekulise(false);
IAtomContainer atomContainer = sp.parseSmiles("CCC");
Assert.assertFalse(uiTester.isSubgraph(atomContainer, query));
@@ -476,7 +476,7 @@ public void testPropertyR2() throws Exception {
}
- @Ignore("This feature was removed - essential rings aren't useful really")
+ @Ignore("This feature was removed - essential rings aren't useful really")
@Test
public void testPropertyR2_essentialRings() throws Exception {
SMARTSQueryTool sqt = smarts("[R2]");
@@ -486,8 +486,8 @@ public void testPropertyR2_essentialRings() throws Exception {
Assert.assertEquals(2, results[1]);
}
- @Ignore("This feature is pending but will be the combinded in an 'OpenSMARTS'" +
- " configuration which uses the relevant rings.")
+ @Ignore("This feature is pending but will be the combinded in an 'OpenSMARTS'" +
+ " configuration which uses the relevant rings.")
@Test
public void testPropertyR2_relevantRings() throws Exception {
SMARTSQueryTool sqt = smarts("[R2]");
@@ -1012,13 +1012,13 @@ public void testPropertyAtomicMass7() throws Exception {
Assert.assertEquals(1, results[0]);
Assert.assertEquals(1, results[1]);
}
-
+
@Test public void testBondStereo3() throws Exception {
int[] results = match("F/?C=C/Cl", "FC=CCl");
Assert.assertEquals(1, results[0]);
Assert.assertEquals(1, results[1]);
}
-
+
@Test public void testBondStereo4() throws Exception {
int[] results = match("F/?C=C/Cl", "F\\C=C/Cl");
Assert.assertEquals(0, results[0]);
@@ -1221,17 +1221,17 @@ public void testPropertyAtomicMass7() throws Exception {
* aromaticity from the SMILES we can match correctly. */
@Test public void testLogicalOrLowAnd6() throws Exception {
SMARTSQueryTool sqt = smarts("[#7,C;+0,+1]");
- IAtomContainer smi = smiles("[Na+].[Na+].[O-]C(=O)c1ccccc1c2c3ccc([O-])cc3oc4cc(=O)ccc24");
+ IAtomContainer smi = smiles("[Na+].[Na+].[O-]C(=O)c1ccccc1c2c3ccc([O-])cc3oc4cc(=O)ccc24");
int[] results = match(sqt, smi);
Assert.assertEquals(1, results[0]);
}
@Test public void testLogicalOrLowAnd6_cdkAromaticity() throws Exception {
SMARTSQueryTool sqt = smarts("[#7,C;+0,+1]");
- IAtomContainer smi = smiles("[Na+].[Na+].[O-]C(=O)c1ccccc1c2c3ccc([O-])cc3oc4cc(=O)ccc24");
- sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(),
- Cycles.cdkAromaticSet()));
- AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
+ IAtomContainer smi = smiles("[Na+].[Na+].[O-]C(=O)c1ccccc1c2c3ccc([O-])cc3oc4cc(=O)ccc24");
+ sqt.setAromaticity(new Aromaticity(ElectronDonation.cdk(),
+ Cycles.cdkAromaticSet()));
+ AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(smi);
int[] results = match(sqt, smi);
Assert.assertEquals(8, results[0]);
}
@@ -1274,24 +1274,24 @@ public void testPropertyAtomicMass7() throws Exception {
Assert.assertEquals(0, results[1]);
}
- @Test public void testRing_large() throws Exception {
- int[] results = match("C%10CCCCC%10", "C1CCCCC1O");
- Assert.assertEquals(12, results[0]);
- Assert.assertEquals(1, results[1]);
- }
-
- @Test public void testRing_large2() throws Exception {
- int[] results = match("C%99CCCCC%99", "C1CCCCC1O");
- Assert.assertEquals(12, results[0]);
- Assert.assertEquals(1, results[1]);
- }
-
- @Test public void testRing_large3() throws Exception {
- int[] results = match("C%991CCCCC%99CCCC1", "C12CCCCC2CCCC1");
- Assert.assertEquals(4, results[0]);
- Assert.assertEquals(1, results[1]);
- }
-
+ @Test public void testRing_large() throws Exception {
+ int[] results = match("C%10CCCCC%10", "C1CCCCC1O");
+ Assert.assertEquals(12, results[0]);
+ Assert.assertEquals(1, results[1]);
+ }
+
+ @Test public void testRing_large2() throws Exception {
+ int[] results = match("C%99CCCCC%99", "C1CCCCC1O");
+ Assert.assertEquals(12, results[0]);
+ Assert.assertEquals(1, results[1]);
+ }
+
+ @Test public void testRing_large3() throws Exception {
+ int[] results = match("C%991CCCCC%99CCCC1", "C12CCCCC2CCCC1");
+ Assert.assertEquals(4, results[0]);
+ Assert.assertEquals(1, results[1]);
+ }
+
@Test public void testRing6() throws Exception {
int[] results = match("C1CCCCC1", "CCCCCC");
Assert.assertEquals(0, results[0]);
@@ -1566,28 +1566,28 @@ public void testPropertyAtomicMass7() throws Exception {
}
@Test public void testHybridizationNumber() throws Exception {
- int[] results = match(smarts("[^1]"),
- smilesAtomTyped("CCN"));
+ int[] results = match(smarts("[^1]"),
+ smilesAtomTyped("CCN"));
Assert.assertEquals(0, results[0]);
Assert.assertEquals(0, results[1]);
- results = match(smarts("[^1]"),
- smilesAtomTyped("N#N"));
+ results = match(smarts("[^1]"),
+ smilesAtomTyped("N#N"));
Assert.assertEquals(2, results[0]);
Assert.assertEquals(2, results[1]);
- results = match(smarts("[^1&N]"),
- smilesAtomTyped("CC#C"));
+ results = match(smarts("[^1&N]"),
+ smilesAtomTyped("CC#C"));
Assert.assertEquals(0, results[0]);
Assert.assertEquals(0, results[1]);
- results = match(smarts("[^1&N]"),
- smilesAtomTyped("CC#N"));
+ results = match(smarts("[^1&N]"),
+ smilesAtomTyped("CC#N"));
Assert.assertEquals(1, results[0]);
Assert.assertEquals(1, results[1]);
- results = match(smarts("[^1&N,^2&C]"),
- smilesAtomTyped("CC(=O)CC(=O)CC#N"));
+ results = match(smarts("[^1&N,^2&C]"),
+ smilesAtomTyped("CC(=O)CC(=O)CC#N"));
Assert.assertEquals(3, results[0]);
Assert.assertEquals(3, results[1]);
@@ -1634,18 +1634,18 @@ public void testAromAliArom() throws Exception {
Assert.assertEquals(0, results[0]);
Assert.assertEquals(0, results[1]);
- IAtomContainer m = smiles("c1ccccc1c2ccccc2");
-
- // note - missing explicit single bond, SMILES preserves the
- // aromatic specification but in this case we want the single
- // bond. as the molecule as assigned bond orders we can easily
- // remove the flags and reassign them correctly
- for (IBond bond : m.bonds())
- bond.setFlag(CDKConstants.ISAROMATIC, false);
- AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(m);
- CDKHueckelAromaticityDetector.detectAromaticity(m);
-
- results = match(smarts("c-c"), m);
+ IAtomContainer m = smiles("c1ccccc1c2ccccc2");
+
+ // note - missing explicit single bond, SMILES preserves the
+ // aromatic specification but in this case we want the single
+ // bond. as the molecule as assigned bond orders we can easily
+ // remove the flags and reassign them correctly
+ for (IBond bond : m.bonds())
+ bond.setFlag(CDKConstants.ISAROMATIC, false);
+ AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(m);
+ CDKHueckelAromaticityDetector.detectAromaticity(m);
+
+ results = match(smarts("c-c"), m);
Assert.assertEquals(2, results[0]);
Assert.assertEquals(1, results[1]);
@@ -1689,7 +1689,7 @@ public void testUnspecifiedBond() throws Exception {
Assert.assertEquals(0, results[1]);
results = match("c-C", "CCc1ccccc1");
- Assert.assertEquals(1, results[0]);
+ Assert.assertEquals(1, results[0]);
Assert.assertEquals(1, results[1]);
}
@@ -1790,28 +1790,28 @@ public void testBondOrderQueryKekuleVsSmiles() throws Exception {
@Test public void cyclopropane() throws Exception {
assertThat(match("**(*)*", "C1CC1"),
- is(new int[]{0, 0}));
- }
-
- @Test public void componentGrouping1() throws Exception {
- assertThat(match("[#8].[#8]", "O"), is(new int[]{0, 0}));
- assertThat(match("[#8].[#8]", "O=O"), is(new int[]{2, 1}));
- assertThat(match("[#8].[#8]", "OCCO"), is(new int[]{2, 1}));
- assertThat(match("[#8].[#8]", "O.CCO"), is(new int[]{2, 1}));
- }
-
- @Test public void componentGrouping2() throws Exception {
- assertThat(match("([#8].[#8])", "O"), is(new int[]{0, 0}));
- assertThat(match("([#8].[#8])", "O=O"), is(new int[]{2, 1}));
- assertThat(match("([#8].[#8])", "OCCO"), is(new int[]{2, 1}));
- assertThat(match("([#8].[#8])", "O.CCO"), is(new int[]{0, 0}));
- }
-
- @Test public void componentGrouping3() throws Exception {
- assertThat(match("([#8]).([#8])", "O"), is(new int[]{0, 0}));
- assertThat(match("([#8]).([#8])", "O=O"), is(new int[]{0, 0}));
- assertThat(match("([#8]).([#8])", "OCCO"), is(new int[]{0, 0}));
- assertThat(match("([#8]).([#8])", "O.CCO"), is(new int[]{2, 1}));
+ is(new int[]{0, 0}));
+ }
+
+ @Test public void componentGrouping1() throws Exception {
+ assertThat(match("[#8].[#8]", "O"), is(new int[]{0, 0}));
+ assertThat(match("[#8].[#8]", "O=O"), is(new int[]{2, 1}));
+ assertThat(match("[#8].[#8]", "OCCO"), is(new int[]{2, 1}));
+ assertThat(match("[#8].[#8]", "O.CCO"), is(new int[]{2, 1}));
+ }
+
+ @Test public void componentGrouping2() throws Exception {
+ assertThat(match("([#8].[#8])", "O"), is(new int[]{0, 0}));
+ assertThat(match("([#8].[#8])", "O=O"), is(new int[]{2, 1}));
+ assertThat(match("([#8].[#8])", "OCCO"), is(new int[]{2, 1}));
+ assertThat(match("([#8].[#8])", "O.CCO"), is(new int[]{0, 0}));
+ }
+
+ @Test public void componentGrouping3() throws Exception {
+ assertThat(match("([#8]).([#8])", "O"), is(new int[]{0, 0}));
+ assertThat(match("([#8]).([#8])", "O=O"), is(new int[]{0, 0}));
+ assertThat(match("([#8]).([#8])", "OCCO"), is(new int[]{0, 0}));
+ assertThat(match("([#8]).([#8])", "O.CCO"), is(new int[]{2, 1}));
}
}
Oops, something went wrong.

0 comments on commit 55e30c6

Please sign in to comment.