org.semanticweb.owlapi.model.OWLOntologyIRIMapper Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLOntologyIRIMapper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassTaxonMatrixTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper("src/test/resources/rules/ontology/extensions/catalog-v001.xml");
	pw.addIRIMapper(mapper);
	all = new OWLGraphWrapper(pw.parseOWL(IRI.create("http://purl.obolibrary.org/obo/go/extensions/x-taxon-importer.owl")));
	classes = new HashSet<OWLClass>();
	for(OWLClass cls : all.getSourceOntology().getClassesInSignature(true)) {
		String id = all.getIdentifier(cls);
		if (id.startsWith("GO:")) {
			classes.add(cls);
		}
	}
	rat = all.getOWLClassByIdentifier(TaxonTools.NCBI + "10114");
	yeast = all.getOWLClassByIdentifier(TaxonTools.NCBI + "4932");
}
 
Example #2
Source File: AnnotationRulesEngineTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
	elkLogger = Logger.getLogger("org.semanticweb.elk");
	elkLogLevel = elkLogger.getLevel();
	elkLogger.setLevel(Level.ERROR);
	
	String qcfile = LOCATION + "annotation_qc.xml";
	String xrfabbslocation = LOCATION + "GO.xrf_abbs";
	ParserWrapper p = new ParserWrapper();
	
	OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper(getResource("rules/ontology/extensions/catalog-v001.xml"));
	p.addIRIMapper(mapper);
	
	OWLOntology goTaxon = p.parse("http://purl.obolibrary.org/obo/go/extensions/go-plus.owl");
	OWLOntology gorel = p.parse("http://purl.obolibrary.org/obo/go/extensions/gorel.owl");
	OWLGraphWrapper graph = new OWLGraphWrapper(goTaxon);
	graph.addImport(gorel);
	eco = EcoMapperFactory.createTraversingEcoMapper(p, getResourceIRIString("eco.obo")).getMapper();
	
	AnnotationRulesFactory rulesFactory = new GoAnnotationRulesFactoryImpl(
			qcfile, xrfabbslocation, graph, eco, null);
	engine = new AnnotationRulesEngine(rulesFactory, true, false);
}
 
Example #3
Source File: AnnotationRulesEngineSingleTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() throws Exception {
	elkLogger = Logger.getLogger("org.semanticweb.elk");
	elkLogLevel = elkLogger.getLevel();
	elkLogger.setLevel(Level.ERROR);
	
	String qcfile = LOCATION + "annotation_qc.xml";
	String xrfabbslocation = LOCATION + "GO.xrf_abbs";
	
	ParserWrapper p = new ParserWrapper();
	
	OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper(getResource("rules/ontology/extensions/catalog-v001.xml"));
	p.addIRIMapper(mapper);
	
	OWLOntology goTaxon = p.parse("http://purl.obolibrary.org/obo/go/extensions/go-plus.owl");
	OWLOntology gorel = p.parse("http://purl.obolibrary.org/obo/go/extensions/gorel.owl");
	OWLGraphWrapper graph = new OWLGraphWrapper(goTaxon);
	graph.addImport(gorel);
	eco = EcoMapperFactory.createTraversingEcoMapper(p, getResourceIRIString("eco.obo")).getMapper();
	
	AnnotationRulesFactory rulesFactory = new GoAnnotationRulesFactoryImpl(
			qcfile, xrfabbslocation, graph, eco, null);
	engine = new AnnotationRulesEngine(rulesFactory, true, false);
}
 
Example #4
Source File: AbstractGoRuleTestHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@BeforeClass
public static void beforeClass() throws Exception {
	owltoolsLogger = Logger.getLogger("owltools");
	owltoolsLogLevel = owltoolsLogger.getLevel();
	owltoolsLogger.setLevel(Level.ERROR);
	AbstractEcoRuleTestHelper.beforeClass();
	if (graph == null) {
		ParserWrapper p = new ParserWrapper();
		OWLOntologyIRIMapper mapper = new CatalogXmlIRIMapper(getResource("rules/ontology/extensions/catalog-v001.xml"));
		p.addIRIMapper(mapper);
		OWLOntology goTaxon = p.parse("http://purl.obolibrary.org/obo/go/extensions/go-plus.owl");
		OWLOntology gorel = p.parse("http://purl.obolibrary.org/obo/go/extensions/gorel.owl");
		
		graph = new OWLGraphWrapper(goTaxon);
		graph.addImport(gorel);
	}
}
 
Example #5
Source File: ParserWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void addIRIMappers(List<OWLOntologyIRIMapper> mappers) {
    List<OWLOntologyIRIMapper> reverse = new ArrayList<OWLOntologyIRIMapper>(mappers);
    Collections.reverse(reverse);
    for (OWLOntologyIRIMapper mapper : reverse) {
        addIRIMapper(mapper);
    }
}
 
Example #6
Source File: EmptyImportTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
		throws URISyntaxException, OWLOntologyCreationException {

	final URI ontologyRoot = getClass().getClassLoader()
			.getResource("empty_import").toURI();

	OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(ontologyRoot.toString());
	
	man.setIRIMappers(Collections.singleton(iriMapper));

	final URI mainOntology = getClass().getClassLoader()
			.getResource("empty_import/" + name).toURI();

	return man.loadOntologyFromOntologyDocument(new File(mainOntology));

}
 
Example #7
Source File: ElkReasonerTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
		throws URISyntaxException, OWLOntologyCreationException {

	final URI ontologyRoot = getClass().getClassLoader()
			.getResource("ontologies").toURI();

	OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(
			ontologyRoot.toString());

	man.setIRIMappers(Collections.singleton(iriMapper));

	final URI mainOntology = getClass().getClassLoader()
			.getResource("ontologies/" + name).toURI();

	return man.loadOntologyFromOntologyDocument(new File(mainOntology));

}
 
Example #8
Source File: IgnoreChangesInNonImportedOntologiesTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
/**
 * Loading ontologies from the test resources
 * 
 * @param man
 * @param name
 * @return the loaded ontology
 * @throws URISyntaxException
 * @throws OWLOntologyCreationException
 */
private OWLOntology loadOntology(OWLOntologyManager man, String name)
		throws URISyntaxException, OWLOntologyCreationException {

	final URI ontologyRoot = getClass().getClassLoader()
			.getResource("ontologies").toURI();

	OWLOntologyIRIMapper iriMapper = new ThisIRIMapper(ontologyRoot.toString());
	man.setIRIMappers(Collections.singleton(iriMapper));

	final InputStream mainOntology = getClass().getClassLoader()
			.getResourceAsStream("ontologies/" + name);

	return man.loadOntologyFromOntologyDocument(mainOntology);

}
 
Example #9
Source File: ParserWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void addIRIMapper(OWLOntologyIRIMapper mapper) {
    manager.getIRIMappers().add(mapper);
    mappers.add(0, mapper);
}
 
Example #10
Source File: ParserWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void removeIRIMapper(OWLOntologyIRIMapper mapper) {
    manager.getIRIMappers().remove(mapper);
    mappers.remove(mapper);
}
 
Example #11
Source File: ParserWrapper.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public List<OWLOntologyIRIMapper> getIRIMappers() {
    return Collections.unmodifiableList(mappers);
}
 
Example #12
Source File: OWLView.java    From relex with Apache License 2.0 4 votes vote down vote up
public void initOntology()
{
	try
	{
		//Auxiliar structures
		//map_owl_relexwords = new HashMap<String,OWLIndividual>();
		map_owl_properties = new HashMap<String,OWLProperty>();

		// OWLOntologyManager that manages a set of ontologies
		manager = OWLManager.createOWLOntologyManager();

		// URI of the ontology
		ontologyURI = URI.create("http://student.dei.uc.pt/~racosta/relex/owl_format.owl");

		// Pphysical URI
		physicalURI = URI.create("file:/media/Docs/uc/MSc-2/SW/Project/ontologies/relex2.owl");

		// Set up a mapping, which maps the ontology URI to the physical URI
		OWLOntologyIRIMapper mapper = new SimpleIRIMapper(IRI.create(ontologyURI),IRI.create(physicalURI));
		manager.addIRIMapper(mapper);

		// Now create the ontology - we use the ontology URI
		ontology = manager.createOntology(IRI.create(physicalURI));
		//Data factory, allows to manipulate ontology data
		factory = manager.getOWLDataFactory();

		sentence = factory.getOWLClass(IRI.create(ontologyURI + "#Sentence"));
		word = factory.getOWLClass(IRI.create(ontologyURI + "#Word"));
		//relex_word = factory.getOWLClass(IRI.create(ontologyURI + "#Relex_word"));

		//Generic properties for classes
		has = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#relex_has"));
		//map_owl_properties.put("type",factory.getOWLObjectProperty(IRI.create(ontologyURI + "#type")));

		// word is subclass of phrase
		//OWLAxiom subclassing = factory.getOWLSubClassAxiom(word, sentence);

		// Add the axiom to the ontology
		//AddAxiom addAxiom = new AddAxiom(ontology, subclassing);
		// We now use the manager to apply the change
		//manager.applyChange(addAxiom);

		//2ยบ Add the predefined properties

		/*map_owl_properties.put("tense",factory.getOWLObjectProperty(IRI.create(ontologyURI + * "#p_tense")));
		map_owl_properties.put("index",factory.getOWLDataProperty(IRI.create(ontologyURI + "#p_index")));
		//Add possible relex words
		map_owl_relexwords.put("masculine",factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_masculine")));
		map_owl_relexwords.put("feminine",factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_feminine")));
		map_owl_relexwords.put("person",factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_person")));
		map_owl_relexwords.put("neuter",factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_neuter")));*/

		/*OWLObjectProperty number = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#number"));
		OWLObjectProperty tense = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#tense"));
		OWLObjectProperty query = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#query"));
		OWLObjectProperty quantification = factory.getOWLObjectProperty(IRI.create(ontologyURI + "#quantification"));*/

		// Add axioms to the ontology
		//OWLAxiom genderax = factory.getOWLObjectProperty(infinitive);

		//Phrase Individuals
		/*phr_type_map_owl = new HashMap<String,OWLIndividual>();
		phr_type_map_owl.put("Adverbial Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_adjective")));
		phr_type_map_owl.put("Adverbial Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_adverb")));
		phr_type_map_owl.put("Noun Phrase",      factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_noun")));
		phr_type_map_owl.put("Prepositional Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_prepositional")));
		phr_type_map_owl.put("Particle",         factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_particle")));
		phr_type_map_owl.put("Quantifier Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_quantifier")));
		phr_type_map_owl.put("Clause",           factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_clause")));
		phr_type_map_owl.put("Subordinate Clause", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_subordinate")));
		phr_type_map_owl.put("Subject Inverted", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_inverted")));
		phr_type_map_owl.put("Sentence",         factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_root")));
		phr_type_map_owl.put("Verb Phrase",      factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_verb")));
		phr_type_map_owl.put("Wh-Adverb Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_wh-adverb")));
		phr_type_map_owl.put("Wh-Noun Phrase",   factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_wh-noun")));
		phr_type_map_owl.put("Wh-Prepositional Phrase", factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#rw_wh-prep")));*/

		//Add all the phr_type_map_owl Individuals to the Relex_word Class
		/*Set<String> s = phr_type_map_owl.keySet();
		for (Iterator<String> it = s.iterator(); it.hasNext();)
		{
			manager.applyChange(new AddAxiom(ontology, factory.getOWLClassAssertionAxiom(phr_type_map_owl.get(it.next()), relex_word)));
		}

		//Add all the map_owl_relexwords Individuals to the Relex_word Class
		s = map_owl_relexwords.keySet();
		for (Iterator<String> it = s.iterator(); it.hasNext();)
		{
			manager.applyChange(new AddAxiom(ontology, factory.getOWLClassAssertionAxiom(map_owl_relexwords.get(it.next()), relex_word)));
		}*/

	}
	catch (OWLException e)
	{
		e.printStackTrace();
	}
}