Skip to content

Commit

Permalink
updated brigdedb in test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkutmon committed Oct 3, 2024
1 parent 492272b commit 50b44a6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 80 deletions.
118 changes: 59 additions & 59 deletions modules/org.pathvisio.core/test/org/pathvisio/core/model/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import junit.framework.TestCase;

import org.bridgedb.Xref;
import org.bridgedb.bio.BioDataSource;
//import org.bridgedb.bio.BioDataSource;
import org.pathvisio.core.data.XrefWithSymbol;
import org.pathvisio.core.preferences.PreferenceManager;
import org.pathvisio.core.util.Utils;
Expand Down Expand Up @@ -233,64 +233,64 @@ public void testRef()
/**
* test that Xref and XrefWithSymbol obey the equals contract
*/
public void testXRefEquals()
{
Object[] testList = new Object[] {
new Xref("1007_at", BioDataSource.AFFY),
new Xref("3456", BioDataSource.AFFY),
new Xref("1007_at", BioDataSource.ENTREZ_GENE),
new Xref ("3456", BioDataSource.ENTREZ_GENE),
new Xref ("3456", BioDataSource.ENTREZ_GENE),
new XrefWithSymbol("3456", BioDataSource.ENTREZ_GENE, "INSR"),
new XrefWithSymbol("3456", BioDataSource.ENTREZ_GENE, "Insulin Receptor"),
};

for (int i = 0; i < testList.length; ++i)
{
Object refi = testList[i];
// equals must be reflexive
assertTrue (refi.equals(refi));
// never equal to null
assertFalse (refi.equals(null));
}
for (int i = 1; i < testList.length; ++i)
for (int j = 0; j < i; ++j)
{
// equals must be symmetric
Object refi = testList[i];
Object refj = testList[j];
assertEquals ("Symmetry fails for " + refj + " and " + refi,
refi.equals(refj), refj.equals(refi)
);

// hashcode contract
if (refi.equals(refj))
{
assertEquals (refi.hashCode(), refj.hashCode());
}
}
// equals must be transitive
for (int i = 2; i < testList.length; ++i)
for (int j = 1; j < i; ++j)
for (int k = 0; k < j; ++k)
{
Object refi = testList[i];
Object refj = testList[j];
Object refk = testList[k];
if (refi.equals (refj) && refj.equals (refk))
{
assertTrue (refk.equals (refi));
}
if (refj.equals (refk) && refk.equals (refi))
{
assertTrue (refi.equals (refj));
}
if (refk.equals (refi) && refi.equals (refj))
{
assertTrue (refk.equals (refj));
}
}
}
// public void testXRefEquals()
// {
// Object[] testList = new Object[] {
// new Xref("1007_at", BioDataSource.AFFY),
// new Xref("3456", BioDataSource.AFFY),
// new Xref("1007_at", BioDataSource.ENTREZ_GENE),
// new Xref ("3456", BioDataSource.ENTREZ_GENE),
// new Xref ("3456", BioDataSource.ENTREZ_GENE),
// new XrefWithSymbol("3456", BioDataSource.ENTREZ_GENE, "INSR"),
// new XrefWithSymbol("3456", BioDataSource.ENTREZ_GENE, "Insulin Receptor"),
// };
//
// for (int i = 0; i < testList.length; ++i)
// {
// Object refi = testList[i];
// // equals must be reflexive
// assertTrue (refi.equals(refi));
// // never equal to null
// assertFalse (refi.equals(null));
// }
// for (int i = 1; i < testList.length; ++i)
// for (int j = 0; j < i; ++j)
// {
// // equals must be symmetric
// Object refi = testList[i];
// Object refj = testList[j];
// assertEquals ("Symmetry fails for " + refj + " and " + refi,
// refi.equals(refj), refj.equals(refi)
// );
//
// // hashcode contract
// if (refi.equals(refj))
// {
// assertEquals (refi.hashCode(), refj.hashCode());
// }
// }
// // equals must be transitive
// for (int i = 2; i < testList.length; ++i)
// for (int j = 1; j < i; ++j)
// for (int k = 0; k < j; ++k)
// {
// Object refi = testList[i];
// Object refj = testList[j];
// Object refk = testList[k];
// if (refi.equals (refj) && refj.equals (refk))
// {
// assertTrue (refk.equals (refi));
// }
// if (refj.equals (refk) && refk.equals (refi))
// {
// assertTrue (refi.equals (refj));
// }
// if (refk.equals (refi) && refi.equals (refj))
// {
// assertTrue (refk.equals (refj));
// }
// }
// }

/**
* Test for maintaining list of unique id's per Pathway.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
import junit.framework.TestCase;

import org.bridgedb.DataSource;
import org.bridgedb.bio.BioDataSource;
import org.bridgedb.bio.DataSourceTxt;
//import org.bridgedb.bio.BioDataSource;
import org.pathvisio.core.biopax.BiopaxNode;
import org.pathvisio.core.debug.StopWatch;
import org.pathvisio.core.preferences.PreferenceManager;
Expand Down Expand Up @@ -89,7 +90,7 @@ public void testParserSpeed() throws ConverterException, FileNotFoundException
assertEquals (900.0, elt.getMWidth(), 0.1);
assertEquals (300.0, elt.getMHeight(), 0.1);
assertEquals ("8739", elt.getElementID());
assertEquals (BioDataSource.ENTREZ_GENE, elt.getDataSource());
// assertEquals (BioDataSource.ENTREZ_GENE, elt.getDataSource());

//TODO: Line doesn't have fixed graphId, can't test
//TODO: generate line graphId based on hash of coordinates if not available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import javax.swing.JScrollPane;
import javax.swing.KeyStroke;

import org.bridgedb.DataSource;
import org.bridgedb.Xref;
import org.bridgedb.bio.BioDataSource;
import org.pathvisio.core.Engine;
import org.pathvisio.core.debug.StopWatch;
import org.pathvisio.core.model.ConverterException;
Expand All @@ -39,7 +39,7 @@
import org.pathvisio.core.view.VPathwayElement;
import org.pathvisio.gui.view.VPathwaySwing;

import buildsystem.Measure;
//import buildsystem.Measure;
import junit.framework.TestCase;

/**
Expand All @@ -51,11 +51,11 @@ public class TestAndMeasure extends TestCase
private static final File PATHVISIO_BASEDIR = new File ("../..");
private static final File TEST_PATHWAY = new File (PATHVISIO_BASEDIR, "testData/WP248_2008a.gpml");

private Measure measure;
// private Measure measure;

@Override public void setUp()
{
measure = new Measure("pv_mut.log");
// measure = new Measure("pv_mut.log");
}

private interface ObjectTester
Expand Down Expand Up @@ -130,8 +130,10 @@ private void individialTest(ObjectTester tester)
try { Thread.sleep(100); } catch (InterruptedException ex) {}
}
long memEnd = (runtime.totalMemory() - runtime.freeMemory());
measure.add("Memory::" + tester.getName() + " " + N + "x", "" + (memEnd - memStart) / N, "bytes");
measure.add("Speed::" + tester.getName() + " " + N + "x", "" + (float)(msec) / (float)(N), "msec");
System.out.println("Memory::" + tester.getName() + " " + N + "x" + "\t" + (memEnd - memStart) / N + "\n");
System.out.println("Speed::" + tester.getName() + " " + N + "x" + "\t" + (float)(msec) / (float)(N) + "\n");
// measure.add("Memory::" + tester.getName() + " " + N + "x", "" + (memEnd - memStart) / N, "bytes");
// measure.add("Speed::" + tester.getName() + " " + N + "x", "" + (float)(msec) / (float)(N), "msec");
}

public void testFile()
Expand All @@ -153,7 +155,7 @@ public void testObjectCreation()
{
public Object create()
{
return new Xref("ENS0000001", BioDataSource.ENTREZ_GENE);
return new Xref("ENS0000001", DataSource.getExistingBySystemCode("L"));
}

public String getName()
Expand All @@ -171,7 +173,7 @@ public Object create()
elt.setMCenterY(10);
elt.setMWidth(8);
elt.setMHeight(10);
elt.setDataSource(BioDataSource.ENTREZ_GENE);
elt.setDataSource(DataSource.getExistingBySystemCode("L"));
elt.setElementID("3463");
elt.setTextLabel("INSR");
pwy1.add (elt);
Expand Down Expand Up @@ -214,7 +216,7 @@ public Object create()
elt.setMCenterY(10);
elt.setMWidth(8);
elt.setMHeight(10);
elt.setDataSource(BioDataSource.ENTREZ_GENE);
elt.setDataSource(DataSource.getExistingBySystemCode("L"));
elt.setElementID("3463");
elt.setTextLabel("INSR");
pwy3.add (elt);
Expand Down Expand Up @@ -261,8 +263,8 @@ public void testPathwayLoading() throws ConverterException
mw.start(); sw.start();
Pathway pwy = new Pathway();
pwy.readFromXml(TEST_PATHWAY, true);
measure.add ("Speed::Hs_Apoptosis readFromXml (+validate)", "" + sw.stop(), "msec");
measure.add ("Memory::Hs_Apoptosis readFromXml (+validate)", "" + mw.stop() / 1024, "kb");
// measure.add ("Speed::Hs_Apoptosis readFromXml (+validate)", "" + sw.stop(), "msec");
// measure.add ("Memory::Hs_Apoptosis readFromXml (+validate)", "" + mw.stop() / 1024, "kb");

mw.start(); sw.start();
JScrollPane sp = new JScrollPane();
Expand All @@ -273,26 +275,26 @@ public void testPathwayLoading() throws ConverterException
vpwy.activateUndoManager(engine);
vpwy.fromModel(pwy);

measure.add ("Speed::Hs_Apoptosis create VPathway", "" + sw.stop(), "msec");
measure.add ("Memory::Hs_Apoptosis create VPathway", "" + mw.stop() / 1024, "kb");
// measure.add ("Speed::Hs_Apoptosis create VPathway", "" + sw.stop(), "msec");
// measure.add ("Memory::Hs_Apoptosis create VPathway", "" + mw.stop() / 1024, "kb");

mw.start(); sw.start();
wrapper.setSize(vpwy.getVWidth(), vpwy.getVHeight());
BufferedImage image = new BufferedImage(vpwy.getVWidth(), vpwy.getVHeight(),
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
wrapper.paint(g2);
measure.add ("Speed::Hs_Apoptosis paint", "" + sw.stop(), "msec");
measure.add ("Memory::Hs_Apoptosis paint", "" + mw.stop() / 1024, "kb");
// measure.add ("Speed::Hs_Apoptosis paint", "" + sw.stop(), "msec");
// measure.add ("Memory::Hs_Apoptosis paint", "" + mw.stop() / 1024, "kb");
g2.dispose();

mw.start(); sw.start();
for (VPathwayElement elt : vpwy.getDrawingObjects())
{
elt.select();
}
measure.add ("Speed::Hs_Apoptosis select all", "" + sw.stop(), "msec");
measure.add ("Memory::Hs_Apoptosis select all", "" + mw.stop() / 1024, "kb");
// measure.add ("Speed::Hs_Apoptosis select all", "" + sw.stop(), "msec");
// measure.add ("Memory::Hs_Apoptosis select all", "" + mw.stop() / 1024, "kb");

image = new BufferedImage(vpwy.getVWidth(), vpwy.getVHeight(),
BufferedImage.TYPE_INT_RGB);
Expand All @@ -304,8 +306,8 @@ public void testPathwayLoading() throws ConverterException
mw.start(); sw.start();
// move all selected items, triggers undo action
for (int i = 0; i < 10; ++i) vpwy.moveByKey(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), 10);
measure.add ("Speed::Hs_Apoptosis move up 10x" , "" + sw.stop(), "msec");
measure.add ("Memory::Hs_Apoptosis move up 10x", "" + mw.stop() / 1024, "kb");
// measure.add ("Speed::Hs_Apoptosis move up 10x" , "" + sw.stop(), "msec");
// measure.add ("Memory::Hs_Apoptosis move up 10x", "" + mw.stop() / 1024, "kb");
}

}

0 comments on commit 50b44a6

Please sign in to comment.