From 1b6a128137e5d7a6ff75566869232fc054afabef Mon Sep 17 00:00:00 2001 From: RncLsn Date: Fri, 15 May 2015 17:32:22 +0100 Subject: Testing and fixing. Executed successfully on UOBM{1,2,3,4,5,6,7,8}. --- .../ac/ox/cs/pagoda/global_tests/ClauseTester.java | 158 +++++++++++++++++ .../ox/cs/pagoda/global_tests/CostEvaluation.java | 115 ++++++++++++ .../ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java | 193 +++++++++++++++++++++ .../cs/pagoda/global_tests/JAIR_Scalability.java | 91 ++++++++++ .../ox/cs/pagoda/global_tests/LightEvaluation.java | 67 +++++++ .../ox/cs/pagoda/global_tests/PagodaDBPedia.java | 30 ++++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java | 20 +++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java | 25 +++ .../ac/ox/cs/pagoda/global_tests/PagodaLUBM.java | 24 +++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java | 46 +++++ .../ox/cs/pagoda/global_tests/PagodaNPD_bench.java | 30 ++++ .../uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java | 20 +++ .../ac/ox/cs/pagoda/global_tests/PagodaUOBM.java | 53 ++++++ .../pagoda/global_tests/TestGlobalCorrectness.java | 53 ++++++ 14 files changed, 925 insertions(+) create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java create mode 100644 test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java (limited to 'test/uk/ac/ox/cs/pagoda/global_tests') diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java b/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java new file mode 100644 index 0000000..abd0741 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/ClauseTester.java @@ -0,0 +1,158 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.semanticweb.HermiT.model.*; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntology; +import org.semanticweb.owlapi.model.OWLOntologyManager; +import org.testng.Assert; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.approx.Clause; +import uk.ac.ox.cs.pagoda.approx.Clausifier; + +public class ClauseTester { + + @Test + public void test_simple() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, x, y1), + Atom.create(r, x, y2) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_more() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"), y3 = Variable.create("y3"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, x, y1), + Atom.create(r, x, y2), + Atom.create(r, x, y3), + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2), + Atom.create(Equality.INSTANCE, y1, y3), + Atom.create(Equality.INSTANCE, y2, y3) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_inverse() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_fillter() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicConcept B = AtomicConcept.create("B"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x), + Atom.create(B, y1), + Atom.create(B, y2) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + + @Test + public void test_negFillter() { + Variable x = Variable.create("X"), y1 = Variable.create("y1"), y2 = Variable.create("y2"); + AtomicConcept A = AtomicConcept.create("A"); + AtomicConcept B = AtomicConcept.create("B"); + AtomicRole r = AtomicRole.create("r"); + Atom[] bodyAtoms = new Atom[] { + Atom.create(A, x), + Atom.create(r, y1, x), + Atom.create(r, y2, x) + }; + + Atom[] headAtoms = new Atom[] { + Atom.create(Equality.INSTANCE, y1, y2), + Atom.create(B, y1), + Atom.create(B, y2) + }; + + OWLOntologyManager m = OWLManager.createOWLOntologyManager(); + OWLOntology emptyOntology = null; + try { + emptyOntology = m.createOntology(); + } catch (Exception e) { + e.printStackTrace(); + Assert.fail("failed to create a new ontology"); + } + Clause c = new Clause(Clausifier.getInstance(emptyOntology), DLClause.create(headAtoms, bodyAtoms)); + System.out.println(c.toString()); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java b/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java new file mode 100644 index 0000000..01e8203 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/CostEvaluation.java @@ -0,0 +1,115 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.semanticweb.owlapi.model.OWLOntology; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.owl.OWLHelper; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner; +import uk.ac.ox.cs.pagoda.reasoner.QueryReasoner.Type; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; +import uk.ac.ox.cs.pagoda.util.Timer; +import uk.ac.ox.cs.pagoda.util.Utility; + +public class CostEvaluation { + + @Test + public void lubm100() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") + ); +// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); + } + + public void lubm1000() { + int number = 1000; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_all_pagoda.sparql") + }; + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); +// AllTests.copy("output/log4j.log", "results-backup/jair/lubm" + number + ".out"); + } + + @Test + public void uobm5() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") + }; + PagodaTester.main(args); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + public void uobm100() { + int number = 200; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_group3_all.sparql") + }; + PagodaTester.main(args); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + public void uobm500() { + int number = 500; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_all_pagoda.sparql") + }; + + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); +// AllTests.copy("output/log4j.log", "results-backup/jair/uobm" + number + ".out"); + } + + + public static void main(String... args) { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + args = new String[] { + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql") + }; + + OWLOntology ontology = OWLHelper.loadOntology(args[0]); + QueryReasoner reasoner = QueryReasoner.getInstance(Type.ELHOU, ontology, true, true); + Timer t = new Timer(); + reasoner.loadOntology(ontology); + reasoner.importData(args[1]); + if (!reasoner.preprocess()) + return ; + Utility.logInfo("Preprocessing Done in " + t.duration() + " seconds."); + + reasoner.evaluate(reasoner.getQueryManager().collectQueryRecords(args[2])); + } +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java new file mode 100644 index 0000000..0d77fdb --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_PAGOdA.java @@ -0,0 +1,193 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class JAIR_PAGOdA { + + @Test + public void lubm1() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda"); + } + + @Test + public void lubm1_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_conj"); + } + + @Test + public void lubm1_rolledUp() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + "/home/yzhou/backup/20141212/univ-bench-queries.owl", + TestUtil.combinePaths(ontoDir, "lubm/data/lubm1.ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/atomic_lubm.sparql") + ); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/lubm1/pagoda_rolledUp"); + } + + @Test + public void uobm1() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda"); + } + + @Test + public void uobm1_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_conj"); + } + + @Test + public void uobm1_rolledUp() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + "/home/yzhou/backup/20141212/univ-bench-dl-queries.owl", + TestUtil.combinePaths(ontoDir, "uobm/data/uobm1.ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/atomic_uobm.sparql") + }; + PagodaTester.main(args); +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uobm1/pagoda_rolledUp"); + } + + @Test + public void fly() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + }; + PagodaTester.main(args); +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda"); + } + + @Test + public void fly_conj() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + }; + PagodaTester.main(args); + TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_conj"); + } + + + public void fly_rolledUp() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( +// TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl", + TestUtil.combinePaths(ontoDir, "fly/fly-all-in-one_rolledUp.owl"), + null, + TestUtil.combinePaths(ontoDir, "fly/queries/fly_atomic.sparql") + ); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/fly/pagoda_rolledUp"); + } + + public void dbpedia() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/queries/atomic_ground.sparql"), + "dbpedia.ans" + ); + +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/dbpedia/pagoda"); + } + + public void npd() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic_ground.sparql") + , "npd.ans" + ); + +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/npd/pagoda"); + } + + public void reactome() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/reactome_sample_10.ttl"), +// null, +// TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/example.sparql") + , "pagoda_reactome.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_reactome.example"); + +// TestUtil.copyFile(("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_10p"); + } + + public void chembl() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/graph sampling/sample_1.nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/example.sparql") + , "pagoda_chembl.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_chembl.example"); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_1p"); + } + + public void uniprot() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/graph sampling/sample_1.nt"), +// null, +// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/example.sparql") + , "pagoda_uniprot.ans" + ); + TestUtil.copyFile("log4j.log", "output/jair/pagoda_uniprot.example"); +// TestUtil.copyFile("output/log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_1p"); + } + + + public static void main(String... args) { + try { + new JAIR_PAGOdA().lubm1(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java new file mode 100644 index 0000000..cdf55bd --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/JAIR_Scalability.java @@ -0,0 +1,91 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.Properties; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class JAIR_Scalability { + + private static final String date = "_0123"; + + @Test + public void reactome() throws IOException { + testReactome(10, false); + } + + @Test + public void chembl() throws IOException { + testChEMBL(1, false); + } + + @Test + public void uniprot() throws IOException { + testUniProt(1, false); + } + + public void testReactome(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/biopax-level3-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/graph sampling/simplifed_sample_" + percentage + ".ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/reactome/queries/test.sparql") + , "reactome.ans" + }; + if (percentage == 10) + args[1] = args[1].replace("simplifed", "reactome"); + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/reactome/pagoda_" + percentage + "p" + date); + } + + public void testChEMBL(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/cco-noDPR.ttl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/sample_" + percentage + ".nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/chembl/queries/test.sparql") + , "chembl.ans" + }; + if (percentage == 1 || percentage == 10 || percentage == 50) + args[1] = args[1].replace("chembl", "chembl/graph sampling"); + else + if (percentage == 100) + args[1] = "/home/yzhou/RDFData/ChEMBL/facts/ChEMBL.ttl"; + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/chembl/pagoda_" + percentage + "p" + date); + } + + public void testUniProt(int percentage, boolean save) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + String[] args = new String[] { + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/core-sat-processed.owl"), + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/sample_" + percentage + ".nt"), +// TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/atomic_ground.sparql") + TestUtil.combinePaths(ontoDir, "bio2rdf/uniprot/queries/test.sparql") + , "uniprot.ans" + }; + + if (percentage == 1 || percentage == 10 || percentage == 50) + args[1] = args[1].replace("uniprot", "uniprot/graph sampling"); + else + if (percentage == 100) + args[1] = "/home/yzhou/krr-nas-share/Yujiao/ontologies/bio2rdf/uniprot/data/uniprot_cleaned.nt"; + + PagodaTester.main(args); + if (save) + TestUtil.copyFile("log4j.log", "/home/yzhou/java-workspace/test-share/results_new/uniprot/pagoda_" + percentage + "p" + date); + } + + public static void main(String... args) throws IOException { + Properties.ShellModeDefault = true; + new JAIR_Scalability().testUniProt(50, false); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java new file mode 100644 index 0000000..3ee268e --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/LightEvaluation.java @@ -0,0 +1,67 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +public class LightEvaluation { + + @Test + public void uobm1() throws IOException { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + TestUtil.copyFile("log4j.log", "output/jair/uobm1.out"); + } + + @Test + public void lubm100() throws IOException { + int number = 100; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "lubm/univ-bench.owl"), + TestUtil.combinePaths(ontoDir, "lubm/data/lubm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "lubm/queries/test.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/lubm100.out"); + } + + @Test + public void fly() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + TestUtil.combinePaths(ontoDir, "fly/queries/fly.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/fly.out"); + } + + @Test + public void dbpedia() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/dbpedia.out"); + } + + @Test + public void npdWithoutDataType() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + TestUtil.copyFile("log4j.log", "results-backup/current/npd_minus.out"); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java new file mode 100644 index 0000000..2b9cdbd --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaDBPedia.java @@ -0,0 +1,30 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaDBPedia { + + @Test + public void test() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "dbpedia/integratedOntology-all-in-one-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "dbpedia/data/dbpedia-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "dbpedia/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/dbpedia.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/dbpedia.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java new file mode 100644 index 0000000..da059f9 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaELU.java @@ -0,0 +1,20 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaELU { + + @Test void test() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + } + + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java new file mode 100644 index 0000000..d558e0f --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaFLY.java @@ -0,0 +1,25 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaFLY { + + @Test + public void test() { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "fly/fly_anatomy_XP_with_GJ_FC_individuals.owl"), + TestUtil.combinePaths(ontoDir, "fly/queries/fly_pellet.sparql") + ); + +// Statistics stat = new Statistics("output/log4j.log"); +// String diff = stat.diff("results-backup/benchmark/fly.out"); +// AllTests.copy("output/log4j.log", "results-backup/current/fly.out"); +// if (!diff.isEmpty()) +// fail(diff); + } + + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java new file mode 100644 index 0000000..2014ec1 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaLUBM.java @@ -0,0 +1,24 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +public class PagodaLUBM { + + private void testN(int number ) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + TestGlobalCorrectness.test(Paths.get(ontoDir, "lubm/univ-bench.owl"), + Paths.get(ontoDir, "lubm/data/lubm" + number + ".ttl"), + Paths.get(ontoDir, "lubm/queries/test.sparql"), + Paths.get(ontoDir, "lubm/lubm" + number + ".json")); + } + + @Test + public void test1() throws IOException { + testN(1); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java new file mode 100644 index 0000000..17d1e82 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD.java @@ -0,0 +1,46 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaNPD { + + @Test + public void testNPDwithoutDataType() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all-minus-datatype.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-minus-datatype-new.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd_minus.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd_minus.out"); + if (!diff.isEmpty()) + fail(diff); + } + + @Test + public void testNPD() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd/npd-all.owl"), + TestUtil.combinePaths(ontoDir, "npd/data/npd-data-dump-processed.ttl"), + TestUtil.combinePaths(ontoDir, "npd/queries/atomic.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java new file mode 100644 index 0000000..c908cb4 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaNPD_bench.java @@ -0,0 +1,30 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.tester.Statistics; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; + +import static org.junit.Assert.fail; + +public class PagodaNPD_bench { + + @Test + public void test() throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.owl"), + TestUtil.combinePaths(ontoDir, "npd-benchmark/npd-v2-ql_a.ttl"), + TestUtil.combinePaths(ontoDir, "npd-benchmark/queries/all.sparql") + ); + + Statistics stat = new Statistics("output/log4j.log"); + String diff = stat.diff("results-backup/benchmark/npd-bench.out"); + TestUtil.copyFile("output/log4j.log", "results-backup/current/npd-bench.out"); + if (!diff.isEmpty()) + fail(diff); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java new file mode 100644 index 0000000..88e0835 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaRLU.java @@ -0,0 +1,20 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.junit.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +public class PagodaRLU { + + @Test + public void testRL() { + int number = 1; + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main( + TestUtil.combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + TestUtil.combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + TestUtil.combinePaths(ontoDir, "uobm/queries/standard.sparql") + ); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java new file mode 100644 index 0000000..065fb29 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/PagodaUOBM.java @@ -0,0 +1,53 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.TestUtil; + +import java.io.IOException; +import java.nio.file.Paths; + +import static uk.ac.ox.cs.pagoda.util.TestUtil.combinePaths; + +public class PagodaUOBM { + + private void testN(int number ) throws IOException { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + TestGlobalCorrectness.test(Paths.get(ontoDir, "uobm/univ-bench-dl.owl"), + Paths.get(ontoDir, "uobm/data/uobm" + number + ".ttl"), + Paths.get(ontoDir, "uobm/queries/test.sparql"), + Paths.get(ontoDir, "uobm/uobm" + number + ".json")); + } + + @Test + public void test1() throws IOException { + testN(1); + } + + private static final int N_1 = 8; + private static final int N_2 = 10; + + + @DataProvider(name = "uobmNumbers") + public static Object[][] uobmNumbers() { + Integer[][] integers = new Integer[N_2 - N_1 + 1][1]; + for (int i = 0; i < N_2 - N_1 + 1; i++) + integers[i][0]= N_1 + i; + return integers; + } + +// @Test +// public void justExecute3() { +// justExecute(1); +// } + + @Test(dataProvider = "uobmNumbers") + public void justExecute(int number) { + String ontoDir = TestUtil.getConfig().getProperty("ontoDir"); + PagodaTester.main(combinePaths(ontoDir, "uobm/univ-bench-dl.owl"), + combinePaths(ontoDir, "uobm/data/uobm" + number + ".ttl"), + combinePaths(ontoDir, "uobm/queries/test.sparql")); + } + +} diff --git a/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java b/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java new file mode 100644 index 0000000..dff2366 --- /dev/null +++ b/test/uk/ac/ox/cs/pagoda/global_tests/TestGlobalCorrectness.java @@ -0,0 +1,53 @@ +package uk.ac.ox.cs.pagoda.global_tests; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import org.apache.log4j.Level; +import org.testng.Assert; +import uk.ac.ox.cs.pagoda.query.QueryRecord; +import uk.ac.ox.cs.pagoda.tester.PagodaTester; +import uk.ac.ox.cs.pagoda.util.Utility; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Type; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Set; + +/** + * This is a unit test for TestNG. + *

+ * It tests the correctness on the final output. + * */ +public class TestGlobalCorrectness { + + public static void test(Path ontology, Path data, Path queries, Path givenAnswers) { + try { + Utility.setLogLevel(Level.DEBUG); + Path computedAnswers = Paths.get(File.createTempFile("answers", ".json").getAbsolutePath()); + new File(computedAnswers.toString()).deleteOnExit(); + PagodaTester.main(ontology.toString(), data.toString(), queries.toString(), computedAnswers.toString()); + assertSameContent(computedAnswers, givenAnswers); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static void assertSameContent(Path computedAnswersFile, Path givenAnswersFile) throws IOException { + BufferedReader computedReader = Files.newBufferedReader(computedAnswersFile); + BufferedReader givenReader = Files.newBufferedReader(givenAnswersFile); + + Gson gson = QueryRecord.GsonCreator.getInstance(); + + Type cqType = new TypeToken>() {}.getType(); + Set computedAnswers = gson.fromJson(computedReader, cqType); + Set givenAnswers = gson.fromJson(givenReader, cqType); + + Assert.assertEquals(computedAnswers, givenAnswers); + } + + +} -- cgit v1.2.3