Permalink
Browse files

[#24] need some cleaning

  • Loading branch information...
1 parent 29bceb5 commit 81ee73fe34687f1ae3f0897208dfbe2f4a99b89b @jnguyenx jnguyenx committed Dec 17, 2016

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -142,9 +142,9 @@ public BMKnowledgeBaseOWLAPIImpl(@IndicatesOwlOntologies OWLOntology owlOntology
}
}
- public static BMKnowledgeBase create(OWLOntology owlOntology, OWLReasonerFactory rf) {
- return new BMKnowledgeBaseOWLAPIImpl(owlOntology, null, rf,
- new CurieUtil(new HashMap<String, String>())); // TODO CURIE support?
+ public static BMKnowledgeBase create(OWLOntology owlOntology, OWLReasonerFactory rf,
+ CurieUtil curieUtil) {
+ return new BMKnowledgeBaseOWLAPIImpl(owlOntology, null, rf, curieUtil);
}
/**
@@ -154,9 +154,8 @@ public static BMKnowledgeBase create(OWLOntology owlOntology, OWLReasonerFactory
* @return
*/
public static BMKnowledgeBase create(OWLOntology owlOntology, OWLOntology owlDataOntology,
- OWLReasonerFactory rf) {
- return new BMKnowledgeBaseOWLAPIImpl(owlOntology, owlDataOntology, rf,
- new CurieUtil(new HashMap<String, String>())); // TODO CURIE support?
+ OWLReasonerFactory rf, CurieUtil curieUtil) {
+ return new BMKnowledgeBaseOWLAPIImpl(owlOntology, owlDataOntology, rf, curieUtil);
}
@@ -174,9 +173,8 @@ public void setKbMetdata(KBMetadata kbMetdata) {
private String getShortForm(IRI iri) {
- LOG.info("getShortForm: " + iri.toString());
- //return curieUtil.getCurie(iri.toString()).or(iri.toString());
- return curieMapper.getShortForm(iri);
+ // TODO not great to have a mix of IRI and CURIE
+ return curieUtil.getCurie(iri.toString()).or(iri.toString());
}
private void populateLabelsFromOntology(LabelMapper labelMapper, OWLOntology ontology) {
@@ -393,8 +391,7 @@ private void setPropertyValues(OWLOntology ont, OWLNamedIndividual i) {
if (obj instanceof OWLLiteral) {
addPropertyValue(pvm, pid, ((OWLLiteral) obj).getLiteral());
} else if (obj instanceof OWLNamedIndividual) {
- addPropertyValue(pvm, pid,
- getShortForm(((OWLNamedIndividual) obj).getIRI()));
+ addPropertyValue(pvm, pid, getShortForm(((OWLNamedIndividual) obj).getIRI()));
}
@@ -404,8 +401,7 @@ private void setPropertyValues(OWLOntology ont, OWLNamedIndividual i) {
if (obj instanceof OWLLiteral) {
addPropertyValue(pvm, pid, ((OWLLiteral) obj).getLiteral());
} else if (obj instanceof OWLNamedIndividual) {
- addPropertyValue(pvm, pid,
- getShortForm(((OWLNamedIndividual) obj).getIRI()));
+ addPropertyValue(pvm, pid, getShortForm(((OWLNamedIndividual) obj).getIRI()));
}
@@ -995,12 +991,14 @@ protected String getIdentifier(OWLNamedObject obj) {
}
/**
- * @param id
+ * @param id CURIE-style
* @return OWLAPI Class object
*/
protected OWLClass getOWLClass(String id) {
Preconditions.checkNotNull(id);
- return getOWLClass(IRI.create(id));
+ // TODO not great to have a mix of IRI and CURIE
+ String iri = curieUtil.getIri(id).or(id);
+ return getOWLClass(IRI.create(iri));
}
/**
@@ -1020,12 +1018,14 @@ protected OWLNamedIndividual getOWLNamedIndividual(IRI iri) {
}
/**
- * @param id
+ * @param id CURIE-style
* @return OWLAPI Class object
*/
public OWLNamedIndividual getOWLNamedIndividual(String id) {
Preconditions.checkNotNull(id);
- return getOWLNamedIndividual(IRI.create(id));
+ // TODO not great to have a mix of IRI and CURIE
+ String iri = curieUtil.getIri(id).or(id);
+ return getOWLNamedIndividual(IRI.create(iri));
}
public Attribute getAttribute(String id) {
@@ -1,5 +1,7 @@
package org.monarchinitiative.owlsim.compute.eval.data;
+import java.util.HashMap;
+
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.log4j.Logger;
import org.junit.Assert;
@@ -8,6 +10,7 @@
import org.monarchinitiative.owlsim.eval.data.BackgroundData;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -59,7 +62,7 @@ private void create(int numClasses, int avgParents, int numIndividuals) throws O
OWLOntology ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
}
}
@@ -1,5 +1,6 @@
package org.monarchinitiative.owlsim.compute.eval.data;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -24,6 +25,7 @@
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
import org.monarchinitiative.owlsim.kb.impl.CURIEMapperImpl;
import org.monarchinitiative.owlsim.kb.impl.LabelMapperImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -420,7 +422,7 @@ private void create(int numClasses, int avgParents, int numIndividuals) throws O
OWLOntology ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
}
}
@@ -1,10 +1,13 @@
package org.monarchinitiative.owlsim.compute.matcher.perf;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.inject.Inject;
+
import org.apache.log4j.Logger;
import org.junit.Test;
import org.monarchinitiative.owlsim.compute.matcher.ProfileMatcher;
@@ -16,6 +19,7 @@
import org.monarchinitiative.owlsim.model.match.MatchSet;
import org.monarchinitiative.owlsim.model.match.ProfileQuery;
import org.monarchinitiative.owlsim.model.match.impl.ProfileQueryImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -96,7 +100,7 @@ private void create(int numClasses, int avgParents, int numIndividuals) throws O
OWLOntology ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
profileMatcher = createProfileMatcher(kb);
}
@@ -1,11 +1,16 @@
package org.monarchinitiative.owlsim.compute.mica;
+import java.util.HashMap;
+
+import javax.inject.Inject;
+
import org.apache.log4j.Logger;
import org.monarchinitiative.owlsim.compute.mica.impl.MICAStoreImpl;
import org.monarchinitiative.owlsim.compute.mica.impl.NoRootException;
import org.monarchinitiative.owlsim.eval.RandomOntologyMaker;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -28,7 +33,6 @@
private Logger LOG = Logger.getLogger(MICAStoreBench.class);
protected boolean writeToStdout = false;
-
public static class Benchmark1 {
void timeNanoTime(int reps) {
for (int i = 0; i < reps; i++) {
@@ -55,7 +59,7 @@ private void create(int numClasses, int avgParents, int numIndividuals) throws O
OWLOntology ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
LOG.info("creating MICAStore");
MICAStore micaStore = new MICAStoreImpl(kb);
LOG.info("created MICAStore");
@@ -1,6 +1,7 @@
package org.monarchinitiative.owlsim.compute.mica.perf;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import org.apache.log4j.Logger;
@@ -14,6 +15,7 @@
import org.monarchinitiative.owlsim.io.JSONWriter;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -82,7 +84,7 @@ private MICARun create(int numClasses, int avgParents, int numIndividuals) throw
OWLOntology ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
kbsc = new KBStatsCalculator(kb);
LOG.info("creating MICAStore");
long t1 = System.currentTimeMillis();
@@ -1,11 +1,14 @@
package org.monarchinitiative.owlsim.compute.stats;
+import java.util.HashMap;
+
import org.apache.log4j.Logger;
import org.junit.Test;
import org.monarchinitiative.owlsim.compute.mica.impl.NoRootException;
import org.monarchinitiative.owlsim.eval.RandomOntologyMaker;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -50,7 +53,7 @@ private void create(int numClasses, int avgParents, int numIndividuals,
.addRandomIndividuals(numIndividuals, avgClassesPerIndividual)
.getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
LOG.info("Knowledge base ready ...");
}
@@ -1,6 +1,7 @@
package org.monarchinitiative.owlsim.compute.stats;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Random;
@@ -9,11 +10,11 @@
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.log4j.Logger;
import org.junit.Assert;
-import org.junit.Test;
import org.monarchinitiative.owlsim.compute.mica.impl.NoRootException;
import org.monarchinitiative.owlsim.eval.RandomOntologyMaker;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -241,7 +242,7 @@ private void create(int numClasses, int avgParents, int numIndividuals, int avgC
this.ontology =
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals, avgClassesPerIndividual).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
icc = new ICStatsCalculator(kb);
LOG.info("creating ICStoreSummary");
icc.calculateICSummary();
@@ -1,6 +1,7 @@
package org.monarchinitiative.owlsim.compute.stats;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -12,6 +13,7 @@
import org.monarchinitiative.owlsim.io.JSONWriter;
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.impl.BMKnowledgeBaseOWLAPIImpl;
+import org.prefixcommons.CurieUtil;
import org.semanticweb.elk.owlapi.ElkReasonerFactory;
import org.semanticweb.owlapi.model.OWLOntology;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
@@ -83,7 +85,7 @@ private ICRun create(int numClasses, int avgParents, int numIndividuals, int avg
RandomOntologyMaker.create(numClasses, avgParents).addRandomIndividuals(numIndividuals, avgClassesPerIndividual).getOntology();
OWLReasonerFactory rf = new ElkReasonerFactory();
- kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf);
+ kb = BMKnowledgeBaseOWLAPIImpl.create(ontology, rf, new CurieUtil(new HashMap<String, String>()));
icc = new ICStatsCalculator(kb);
LOG.info("creating ICStoreSummary");
long t1 = System.currentTimeMillis();
@@ -101,8 +101,6 @@ public void run(ApplicationConfiguration configuration, Environment environment)
configureSwagger(environment);
configureJackson(environment);
- System.out.println(configuration.getCuries());
-
Concurrency concurrency = Concurrency.CONCURRENT;
LOG.info("Creating injector...");
Injector i = Guice.createInjector(
@@ -1,18 +1,3 @@
-/**
- * Copyright (C) 2014 The OwlSim authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
package org.monarchinitiative.owlsim.services.resources;
import java.util.Set;
@@ -33,7 +18,6 @@
import org.monarchinitiative.owlsim.kb.BMKnowledgeBase;
import org.monarchinitiative.owlsim.kb.filter.UnknownFilterException;
import org.monarchinitiative.owlsim.model.match.MatchSet;
-import org.prefixcommons.CurieUtil;
import com.codahale.metrics.annotation.Timed;
import com.googlecode.javaewah.EWAHCompressedBitmap;
@@ -54,9 +38,6 @@
@Inject
BMKnowledgeBase knowledgeBase;
- @Inject
- CurieUtil curieUtil;
-
@GET
@Path("/ancestors")
@Timed
@@ -71,10 +52,7 @@
@ApiParam(value = "cutoff limit", required = false) @QueryParam("limit") Integer limit)
throws UnknownFilterException, IncoherentStateException {
-
- Set<String> resolvedClassIds =
- classIds.stream().map(id -> curieUtil.getIri(id).or(id)).collect(Collectors.toSet());
- EWAHCompressedBitmap superBM = knowledgeBase.getSuperClassesBM(resolvedClassIds);
+ EWAHCompressedBitmap superBM = knowledgeBase.getSuperClassesBM(classIds);
return knowledgeBase.getClassIds(superBM);
}
@@ -92,14 +70,8 @@ public ClassInformationContentPair getMatches(
@ApiParam(value = "cutoff limit", required = false) @QueryParam("limit") Integer limit)
throws UnknownFilterException, IncoherentStateException {
-
- Set<String> resolvedClassIds1 =
- classIds1.stream().map(id -> curieUtil.getIri(id).or(id)).collect(Collectors.toSet());
- Set<String> resolvedClassIds2 =
- classIds2.stream().map(id -> curieUtil.getIri(id).or(id)).collect(Collectors.toSet());
-
ClassInformationContentPair mica =
- micaCalculator.getMostInformativeCommonAncestorWithIC(resolvedClassIds1, resolvedClassIds2);
+ micaCalculator.getMostInformativeCommonAncestorWithIC(classIds1, classIds2);
return mica;
}
Oops, something went wrong.

0 comments on commit 81ee73f

Please sign in to comment.