Skip to content

Commit

Permalink
Various fixes to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gilleain authored and egonw committed Jun 23, 2010
1 parent 850fd1a commit 592b920
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 116 deletions.
87 changes: 31 additions & 56 deletions src/test/org/openscience/cdk/signature/AtomSignatureTest.java
Expand Up @@ -25,8 +25,7 @@
import java.util.HashMap;
import java.util.Map;

import junit.framework.Assert;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtom;
Expand Down Expand Up @@ -54,7 +53,6 @@ public void setUp() {
atomSignature = new AtomSignature(0, atomContainer);
}


@Test
public void getIntLabelTest() {
atomContainer.getAtom(0).setMassNumber(12);
Expand All @@ -76,46 +74,36 @@ public void getVertexSymbolTest() {
Assert.assertEquals("C", atomSignature.getVertexSymbol(0));
}

@Test
public void integerInvariantsTest() {
IMolecule isotopeChiralMol = builder.newInstance(IMolecule.class);
isotopeChiralMol.addAtom(builder.newInstance(IAtom.class, "C"));

IAtom s32 = builder.newInstance(IAtom.class, "S");
s32.setMassNumber(32);
isotopeChiralMol.addAtom(s32);

IAtom s33 = builder.newInstance(IAtom.class, "S");
s33.setMassNumber(33);
isotopeChiralMol.addAtom(s33);

IAtom s34 = builder.newInstance(IAtom.class, "S");
s34.setMassNumber(34);
isotopeChiralMol.addAtom(s34);

IAtom s36 = builder.newInstance(IAtom.class, "S");
s36.setMassNumber(36);
isotopeChiralMol.addAtom(s36);


}

@Test
public void heightTest() {
IMolecule benzene = makeBenzene();
AtomSignature atomSignature = new AtomSignature(0, 1, benzene);
System.out.println(atomSignature.toCanonicalString());
}

@Test
public void cubaneHeightTest() {
IMolecule cubane = AbstractSignatureTest.makeCubane();
moleculeIsCarbon3Regular(cubane);
int height = 3;
AtomSignature atomSignature = new AtomSignature(0, height, cubane);
String canonicalString = atomSignature.toCanonicalString();
System.out.println(canonicalString);
}
// @Test
// public void integerInvariantsTest() {
// IMolecule isotopeChiralMol = builder.newInstance(IMolecule.class);
// isotopeChiralMol.addAtom(builder.newInstance(IAtom.class, "C"));
//
// IAtom s32 = builder.newInstance(IAtom.class, "S");
// s32.setMassNumber(32);
//
// IAtom s33 = builder.newInstance(IAtom.class, "S");
// s33.setMassNumber(33);
//
// IAtom s34 = builder.newInstance(IAtom.class, "S");
// s34.setMassNumber(34);
//
// IAtom s36 = builder.newInstance(IAtom.class, "S");
// s36.setMassNumber(36);
//
// isotopeChiralMol.addAtom(s36);
// isotopeChiralMol.addAtom(s34);
// isotopeChiralMol.addAtom(s33);
// isotopeChiralMol.addAtom(s32);
//
// isotopeChiralMol.addBond(0, 1, IBond.Order.SINGLE);
// isotopeChiralMol.addBond(0, 2, IBond.Order.SINGLE);
// isotopeChiralMol.addBond(0, 3, IBond.Order.SINGLE);
// isotopeChiralMol.addBond(0, 4, IBond.Order.SINGLE);
//
// MoleculeSignature molSig = new MoleculeSignature(isotopeChiralMol);
// System.out.println(molSig.toCanonicalString());
// }

@Test
public void cuneaneCubaneHeightTest() {
Expand All @@ -126,8 +114,6 @@ public void cuneaneCubaneHeightTest() {
AtomSignature cubaneSignature = new AtomSignature(0, height, cubane);
String cuneaneSigString = cuneaneSignature.toCanonicalString();
String cubaneSigString = cubaneSignature.toCanonicalString();
System.out.println(cuneaneSigString);
System.out.println(cubaneSigString);
Assert.assertEquals(cuneaneSigString, cubaneSigString);
}

Expand Down Expand Up @@ -174,18 +160,7 @@ public void allEqualAtHeightTest(IMolecule molecule, int height) {
} else {
sigfreq.put(canonicalSignature, 1);
}
// System.out.println(i + " " + canonicalSignature);
}
// for (String key : sigfreq.keySet()) { System.out.println(key + " " + sigfreq.get(key));}
Assert.assertEquals(1, sigfreq.keySet().size());
}

@Test
public void testNonZeroRootForSubsignature() {
IMolecule cubane = makeCubane();
AtomSignature atomSignature = new AtomSignature(1, 2, cubane);
String canonicalSignature = atomSignature.toCanonicalString();
System.out.println(canonicalSignature);
}

}
Expand Up @@ -22,8 +22,7 @@
*/
package org.openscience.cdk.signature;

import junit.framework.Assert;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down
Expand Up @@ -22,14 +22,11 @@
*/
package org.openscience.cdk.signature;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import junit.framework.Assert;

import org.junit.Assume;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.CDKTestCase;
Expand All @@ -41,7 +38,6 @@
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.io.MDLWriter;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.templates.MoleculeFactory;

Expand Down Expand Up @@ -109,21 +105,9 @@ public void toCanonicalSignatureStringTest() {
Assert.assertEquals("[C]", molSig.toCanonicalSignatureString(0));
}

public void toMolfileString(IMolecule mol) {
MDLWriter writer = new MDLWriter(System.out);
try {
writer.writeMolecule(mol);
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}

public void fullPermutationTest(IMolecule mol) {
AtomContainerAtomPermutor permutor = new AtomContainerAtomPermutor(mol);
String expected = new MoleculeSignature(mol).toCanonicalString();
System.out.println("canonical = " + expected);
int numberOfPermutationsTried = 0;
while (permutor.hasNext()) {
IAtomContainer permutation = permutor.next();
Expand All @@ -135,22 +119,6 @@ public void fullPermutationTest(IMolecule mol) {
}
}

public void randomPermutationTest(IMolecule mol) {
AtomContainerAtomPermutor permutor = new AtomContainerAtomPermutor(mol);
String expected = new MoleculeSignature(mol).toCanonicalString();
int numberOfPermutationsTried = 0;
while (permutor.hasNext()) {
// IAtomContainer permutation = permutor.randomNext();
// String actual =
// new MoleculeSignature(permutation).toCanonicalString();
numberOfPermutationsTried++;
// String msg = "Failed on permutation " + numberOfPermutationsTried;
// Assert.assertEquals(msg, expected, actual);
}
System.out.println(expected);
System.out.println("Tried " + numberOfPermutationsTried);
}

public String canonicalStringFromSmiles(String smiles)
throws InvalidSmilesException {
IMolecule mol = parser.parseSmiles(smiles);
Expand All @@ -160,7 +128,6 @@ public String canonicalStringFromSmiles(String smiles)

public String canonicalStringFromMolecule(IMolecule molecule) {
MoleculeSignature signature = new MoleculeSignature(molecule);
// return signature.toCanonicalString();
return signature.getGraphSignature();
}

Expand Down Expand Up @@ -301,9 +268,6 @@ public void testBridgedCycloButane() {
String expected = "[C]([C]([C,0])[C]([C,0])[C,0])";
IMolecule mol = AbstractSignatureTest.makeBridgedCyclobutane();
String signature = this.canonicalStringFromMolecule(mol);
for (String atomicSignature : this.getAtomicSignatures(mol)) {
System.out.println(atomicSignature);
}
Assert.assertEquals(expected, signature);
}

Expand Down Expand Up @@ -411,23 +375,6 @@ public int findFirstAtomIndexForSymbol(
return -1;
}

// XXX commented out this test for now, as it takes a long time - this
// is a known weakness of the current implementation
@Test
public void testPolyPhenylMolecule() throws Exception {
Assume.assumeTrue(runSlowTests());
String smiles = "C1=CC=C(C=C1)P(C2=CC=CC=C2)(C3=CC=CC=C3)[RhH]" +
"(P(C4=CC=CC=C4)(C5=CC=CC=C5)C6=CC=CC=C6)(P(C7=CC=CC=C7)" +
"(C8=CC=CC=C8)C9=CC=CC=C9)P(C%10=CC=CC=C%10)" +
"(C%11=CC=CC=C%11)C%12=CC=CC=C%12";
IMolecule mol = parser.parseSmiles(smiles);
int rhIndex = findFirstAtomIndexForSymbol(mol, "Rh");

MoleculeSignature molSig = new MoleculeSignature(mol);
String signatureForRh = molSig.signatureStringForVertex(rhIndex);
System.out.println(signatureForRh);
}

@Test
public void methylFerroceneTest() throws Exception {
String smiles = "CC12C3C4C5C1[Fe]23456789C%10C6C7C8C9%10";
Expand Down
3 changes: 1 addition & 2 deletions src/test/org/openscience/cdk/signature/OrbitTest.java
Expand Up @@ -25,8 +25,7 @@
import java.util.ArrayList;
import java.util.List;

import junit.framework.Assert;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

Expand Down
Expand Up @@ -22,8 +22,8 @@
*/
package org.openscience.cdk.signature;

import junit.framework.Assert;

import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
Expand Down Expand Up @@ -52,7 +52,6 @@ public void checkParameters(SignatureQuotientGraph qGraph,
int expectedVertexCount,
int expectedEdgeCount,
int expectedLoopEdgeCount) {
System.out.println(qGraph);
Assert.assertEquals(expectedVertexCount, qGraph.getVertexCount());
Assert.assertEquals(expectedEdgeCount, qGraph.getEdgeCount());
Assert.assertEquals(expectedLoopEdgeCount, qGraph.numberOfLoopEdges());
Expand Down

0 comments on commit 592b920

Please sign in to comment.