本文整理汇总了Java中org.semanticweb.owlapi.model.OWLObject类的典型用法代码示例。如果您正苦于以下问题:Java OWLObject类的具体用法?Java OWLObject怎么用?Java OWLObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OWLObject类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRendering
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
protected String getRendering(Object object) {
if (object instanceof OWLObject) {
String rendering = getOWLModelManager().getRendering(((OWLObject) object));
for (OWLObject eqObj : equivalentObjects) {
// Add in the equivalent class symbol
rendering += " \u2261 " + getOWLModelManager().getRendering(eqObj);
}
return rendering;
} else {
if (object != null) {
return object.toString();
} else {
return "";
}
}
}
示例2: containsRel
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
private void containsRel(String s, String t, String r, OWLShuntGraph shuntGraph, OWLGraphWrapper graph, Set<OWLShuntEdge> remaining) {
boolean found = false;
OWLObject cs = graph.getOWLObjectByIdentifier(s);
OWLObject ct = graph.getOWLObjectByIdentifier(t);
for (OWLShuntEdge edge : shuntGraph.edges) {
if (s.equals(edge.sub) && t.equals(edge.obj) && r.equals(edge.pred)) {
found = true;
remaining.remove(edge);
break;
}
}
assertTrue("Did not find edge: ("+
graph.getLabelOrDisplayId(cs)+"; "+
graph.getLabelOrDisplayId(ct)+"; "+
r+")", found);
}
示例3: testGetOBOSynonymsMultipleScopes
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
@Test
public void testGetOBOSynonymsMultipleScopes() throws Exception{
OWLGraphWrapper wrapper = getOBO2OWLOntologyWrapper("ncbi_taxon_slim.obo");
OWLObject cls = wrapper.getOWLClass(OWLGraphWrapper.DEFAULT_IRI_PREFIX + "NCBITaxon_10088");
List<ISynonym> synonyms = wrapper.getOBOSynonyms(cls);
assertEquals(2, synonyms.size());
ISynonym synonym1 = synonyms.get(0);
ISynonym synonym2 = synonyms.get(1);
// TODO what is the right order of synonyms?
if (synonym1.getLabel().equals("mice")) {
ISynonym temp = synonym1;
synonym1 = synonym2;
synonym2 = temp;
}
assertEquals("Nannomys", synonym1.getLabel());
assertEquals("RELATED", synonym1.getScope());
assertNull(synonym1.getCategory());
assertNull(synonym1.getXrefs());
assertEquals("mice", synonym2.getLabel());
assertEquals("EXACT", synonym2.getScope());
assertNull(synonym2.getCategory());
assertNull(synonym2.getXrefs());
}
示例4: testSagaComplex
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
@Test
public void testSagaComplex() throws Exception {
OWLObject focusObject = g.getOWLClassByIdentifier("GO:0000124"); // SAGA complex
Set<OWLPropertyExpression> props = new HashSet<OWLPropertyExpression>();
props.add(g.getOWLObjectProperty(OBOUpperVocabulary.BFO_part_of.getIRI()));
ShuntGraphPair pair = ShuntGraphUtils.createShuntGraphPair(g, focusObject, props, true);
OWLShuntGraph topology = pair.getTopologyGraph();
checkNodesSagaComplex(g, topology);
checkTopologyRelationsSagaComplex(g, topology);
OWLShuntGraph inferred = pair.getInferredGraph();
checkNodesSagaComplex(g, inferred);
checkInferredRelationsSagaComplex(g, inferred);
}
示例5: getConceptSchemeComboBox
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
public static JComboBox getConceptSchemeComboBox(OWLEditorKit owlEditorKit) {
final Comparator<OWLObject> comp = owlEditorKit.getModelManager().getOWLObjectComparator();
List<OWLIndividual> sorted;
Collections.sort(sorted = new ArrayList<OWLIndividual>(getConceptSchemes(owlEditorKit)), new OWLObjectComparatorAdapter<OWLIndividual>(comp) {
public int compare(OWLIndividual o1, OWLIndividual o2) {
return super.compare(o1,o2);
}
});
JComboBox schemaBox = new JComboBox(sorted.toArray());
schemaBox.setRenderer(new OWLCellRendererSimple(owlEditorKit));
if(!getConceptSchemes(owlEditorKit).isEmpty()) {
schemaBox.setSelectedIndex(0);
}
return schemaBox;
}
示例6: executeQuery
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
@Override
public ResultSet executeQuery(final String query, final Statement statement) throws OwlapiDriverException {
final ResultSet resultSet = connector.executeRead(snapshot -> {
if (snapshot.getReasoner() == null) {
throw new ReasonerNotAvailableException("Cannot execute query without a reasoner.");
}
final OWLAPIv3OWL2Ontology ont = new OWLAPIv3OWL2Ontology(snapshot.getOntologyManager(),
snapshot.getOntology(), snapshot.getReasoner());
final QueryResult<OWLObject> res = OWL2QueryEngine.exec(query, ont);
return res != null ? AbstractResultSet.createResultSet(res, statement, query) : null;
});
if (resultSet == null) {
throw new OwlapiDriverException("Unable to execute query " + query);
}
return resultSet;
}
示例7: addTransitiveAncestorsToShuntGraph
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* Add a set of edges, as ancestors to x in OWLShuntGraph g.
* This is reflexive.
*
* @param x
* @param g
* @param rel_ids
* @return the modified OWLShuntGraph
*/
public OWLShuntGraph addTransitiveAncestorsToShuntGraph(OWLObject x, OWLShuntGraph g, List<String> rel_ids) {
// Add this node, our seed.
String topicID = getIdentifier(x);
String topicLabel = getLabel(x);
OWLShuntNode tn = new OWLShuntNode(topicID, topicLabel);
g.addNode(tn);
Set<OWLObjectProperty> props = relationshipIDsToPropertySet(rel_ids);
if (x instanceof OWLClass) {
addTransitiveAncestorsToShuntGraph((OWLClass) x, topicID, g, props);
}
else if (x instanceof OWLObjectProperty) {
addTransitiveAncestorsToShuntGraph((OWLObjectProperty) x, topicID, g, props);
}
return g;
}
示例8: removeDirectEdgesBetween
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* Remove direct edges between the {@code OWLObject}s with the OBO-like IDs
* {@code sourceId} and {@code targetId}.
*
* @param sourceId A {@code String} that is the OBO-like ID of the {@code OWLObject}
* whose edges to remove outgoing from.
* @param targetId A {@code String} that is the OBO-like ID of the {@code OWLObject}
* whose edges to remove incoming to.
* @return An {@code int} that is the number of {@code OWLGraphEdge}s
* removed as a result.
*/
public int removeDirectEdgesBetween(String sourceId, String targetId) {
OWLObject source = this.getOwlGraphWrapper().getOWLObjectByIdentifier(sourceId);
if (source == null) {
throw new IllegalArgumentException(sourceId + " was not found in the ontology");
}
OWLObject target = this.getOwlGraphWrapper().getOWLObjectByIdentifier(targetId);
if (target == null) {
throw new IllegalArgumentException(targetId + " was not found in the ontology");
}
Set<OWLGraphEdge> edgesToRemove = new HashSet<OWLGraphEdge>();
for (OWLGraphEdge edge: this.getOwlGraphWrapper().getOutgoingEdgesWithGCI(source)) {
if (edge.getTarget().equals(target)) {
edgesToRemove.add(edge);
}
}
int edgesRemoved = this.removeEdges(edgesToRemove);
if (log.isInfoEnabled()) {
log.info("Edges between " + sourceId + " and " + targetId + " removed, " +
edgesRemoved + " removed.");
}
return edgesRemoved;
}
示例9: render
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
public void render(OWLGraphWrapper g) {
if (isWriteHeader) {
print("IRI");
sep();
print("label");
sep();
print("definition");
nl();
}
graph = g;
Set<OWLObject> objs = new HashSet<OWLObject>(g.getSourceOntology().getClassesInSignature(Imports.EXCLUDED));
objs.addAll(g.getSourceOntology().getIndividualsInSignature(Imports.EXCLUDED));
for (OWLObject obj : objs) {
if (obj.equals(g.getDataFactory().getOWLNothing()))
continue;
if (obj.equals(g.getDataFactory().getOWLThing()))
continue;
if (obj instanceof OWLNamedObject)
render((OWLNamedObject)obj);
}
stream.close();
}
示例10: testSim
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
@Test
// @Ignore("takes a long time, add to separate test suite") // uncomment this line to deactivate the test
public void testSim() throws Exception{
OWLGraphWrapper wrapper =
getOntologyWrapperFromURL("http://obo.svn.sourceforge.net/viewvc/obo/phenotype-commons/ontology/mp-hp-ext-merged-uberon.owl?revision=3905");
DescriptionTreeSimilarity sa =
new DescriptionTreeSimilarity();
OWLObject a = wrapper.getOWLObject("http://purl.obolibrary.org/obo/MP_0005391");
OWLObject b = wrapper.getOWLObject("http://purl.obolibrary.org/obo/HP_0000478");
SimEngine se = new SimEngine(wrapper);
//sa.forceReflexivePropertyCreation = true;
sa.calculate(se, b, a);
sa.print();
System.out.println(sa.getScore());
}
示例11: getAxiomsCommand
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* Params: id
* @throws OWLOntologyCreationException
* @throws OWLOntologyStorageException
* @throws IOException
* @throws OWLParserException
*/
public void getAxiomsCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException, OWLParserException {
headerOWL();
boolean direct = getParamAsBoolean(Param.direct, false);
OWLObject obj = this.resolveEntity();
LOG.info("finding axioms about: "+obj);
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
if (obj instanceof OWLClass) {
axioms.addAll(graph.getSourceOntology().getAxioms((OWLClass)obj, Imports.EXCLUDED));
}
if (obj instanceof OWLIndividual) {
axioms.addAll(graph.getSourceOntology().getAxioms((OWLIndividual)obj, Imports.EXCLUDED));
}
if (obj instanceof OWLObjectProperty) {
axioms.addAll(graph.getSourceOntology().getAxioms((OWLObjectProperty)obj, Imports.EXCLUDED));
}
for (OWLAxiom ax : axioms) {
output(ax);
}
}
示例12: testDescendants
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
@Test
public void testDescendants() throws Exception {
OWLGraphWrapper g = getOntologyWrapper();
OWLClass c = g.getOWLClass("http://purl.obolibrary.org/obo/NCBITaxon_10090");
OWLObject i = g.getOWLObject("http://purl.obolibrary.org/obo/MGI_101761");
System.out.println("Descendants of "+c);
System.out.println("Expecting "+i);
boolean ok = false;
for (OWLGraphEdge e : g.getIncomingEdgesClosure(c)) {
System.out.println("i:"+e);
if (e.getSource().equals(i))
ok = true;
}
assertTrue(ok);
}
示例13: makeSubsetOntologyCommand
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* generates a sub-ontology consisting only of classes specified using the id param.
* If the include_ancestors param is true, then the transitive closure of the input classes is
* included. otherwise, intermediate classes are excluded and paths are filled.
*
* @throws OWLOntologyCreationException
* @throws OWLOntologyStorageException
* @throws IOException
* @see Mooncat#makeMinimalSubsetOntology(Set, IRI)
*/
public void makeSubsetOntologyCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
headerOWL();
Set<OWLClass> objs = resolveClassList();
Set<OWLClass> tObjs = new HashSet<OWLClass>();
if (getParamAsBoolean("include_ancestors")) {
// TODO - more more efficient
for (OWLClass obj : objs) {
for (OWLObject t : graph.getAncestorsReflexive(obj)) {
tObjs.add((OWLClass)t);
}
}
}
else {
tObjs = objs;
}
Mooncat mooncat;
mooncat = new Mooncat(graph);
OWLOntology subOnt =
mooncat.makeMinimalSubsetOntology(tObjs,
IRI.create("http://purl.obolibrary.org/obo/temporary"));
for (OWLAxiom axiom : subOnt.getAxioms()) {
output(axiom); // TODO
}
graph.getManager().removeOntology(subOnt);
}
示例14: combinePathsToMakeExpression
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* given two paths to the same node..
* TODO - also include from tips of edges to LCS..?
*
* @param x
* @param ea
* @param eb
* @return class expression
*/
private OWLClassExpression combinePathsToMakeExpression(OWLObject x, OWLGraphEdge ea, OWLGraphEdge eb) {
LOG.info("combining, tgt="+x+" EA="+ea+" EB="+eb);
Set<OWLClassExpression> args = new HashSet<OWLClassExpression>();
if (ea == null) {
ea = new OWLGraphEdge(null,x,new Vector<OWLQuantifiedProperty>(),null);
ea.setTarget(x);
}
if (eb == null) {
eb = new OWLGraphEdge(null,x,new Vector<OWLQuantifiedProperty>(),null);
eb.setTarget(x);
}
LOG.info("making Union of "+ea+" and "+eb);
if (!ea.getTarget().equals(x)) {
LOG.info("##EA no match!!");
}
if (!eb.getTarget().equals(x)) {
LOG.info("##EB no match!!");
}
return makeUnion(ea,eb);
}
示例15: getRelationClosureMapEngine
import org.semanticweb.owlapi.model.OWLObject; //导入依赖的package包/类
/**
* Generator for the cache in {@link #getRelationClosureMap(OWLObject, List)}.
*
* @param obj
* @param relation_ids
* @return map of ids to their displayable labels
* @see #getRelationClosureMap(OWLObject, List)
*/
public Map<String,String> getRelationClosureMapEngine(OWLObject obj, List<String> relation_ids){
final Map<String,String> relation_map = new HashMap<String,String>(); // capture labels/ids
// reflexive
String id = getIdentifier(obj);
String label = getLabel(obj);
relation_map.put(id, label);
// Our relation collection.
final Set<OWLObjectProperty> props = relationshipIDsToPropertySet(relation_ids);
if (obj instanceof OWLClass) {
addIdLabelClosure((OWLClass) obj, true, props, relation_map);
}
else if (obj instanceof OWLObjectProperty) {
addIdLabelClosure((OWLObjectProperty) obj, true, relation_map);
}
return relation_map;
}