org.semanticweb.owlapi.model.OWLException Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLException. 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: ChEBIParser.java    From act with GNU General Public License v3.0 6 votes vote down vote up
private HashMap<OWLClass, P<OWLClass, HashMap<String, EntryTypes>>>
  getAllElementsWithParentsIn(Set<OWLClass> parentCategories) throws OWLException {
  HashMap<OWLClass, P<OWLClass, HashMap<String, EntryTypes>>> selected;
  selected = new HashMap<OWLClass, P<OWLClass, HashMap<String, EntryTypes>>>();
  for (OWLClass cl : ontology.getClassesInSignature()) {
    Set<OWLClass> parents = get_has_role_parents(cl);
    HashMap<String, EntryTypes> data = getData(cl);

    for (OWLClass p : parents) {
      if (parentCategories.contains(p)) {
        // this class has a parent within the set we are looking for.
        // so it qualifies as a class to be returned.. add it to map
        P<OWLClass, HashMap<String, EntryTypes>> p_data;
        p_data = new P<OWLClass, HashMap<String, EntryTypes>>(p, data);
        selected.put(cl, p_data);
      }
    }
  }
  return selected;
}
 
Example #2
Source File: ChEBIParser.java    From act with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Print the class hierarchy from this class down, assuming this class is at
 * the given level. Makes no attempt to deal sensibly with multiple
 * inheritance.
 */
private void readSubtree(OWLClass clazz, HashMap<OWLClass, OWLClass> parents, int level, boolean doPrint) throws OWLException {
  if (doPrint) {
    for (int i = 0; i < level * INDENT; i++) {
      err.print(" ");
    }
    err.println(labelFor(clazz, ontology));
  }
  /* Find the children and recurse */
  for (OWLClassExpression c : clazz.getSubClasses(ontology)) {
    OWLClass child = c.asOWLClass();
    if (!child.equals(clazz)) {
      parents.put(child, clazz); // install parents in map
      readSubtree(child, parents, level + 1, doPrint); // recurse
    }
  }
}
 
Example #3
Source File: ChEBIParser.java    From act with GNU General Public License v3.0 6 votes vote down vote up
private OWLClass recurseToSubtreeRoot(OWLClass curr_root, String subtree) throws OWLException {
  String label = labelFor(curr_root, ontology);
  if (subtree.equals(label))
    return curr_root;

  /* Else find the children and recurse */
  OWLClass descendant = null;
  for (OWLClassExpression c : curr_root.getSubClasses(ontology)) {
    OWLClass child = c.asOWLClass();
    if (!child.equals(curr_root)) {
      descendant = recurseToSubtreeRoot(child, subtree);
      if (descendant != null)
        break;
    }
  }

  return descendant;
}
 
Example #4
Source File: OWLView.java    From relex with Apache License 2.0 5 votes vote down vote up
public void saveOWL(String path)
{
	try
	{
		physicalURI = URI.create("file:" + path);

		manager.setOntologyDocumentIRI(ontology,IRI.create(physicalURI));

		manager.saveOntology(ontology);
	}
	catch (OWLException ex)
	{
		Logger.getLogger(OWLView.class.getName()).log(Level.SEVERE, null, ex);
	}
}
 
Example #5
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Create a {@link TraversingEcoMapper} instance using the given
 * {@link OWLGraphWrapper}. It is assumed that ECO can be retrieved from the
 * graph using its default IRI. The mappings are retrieved using the PURL.
 * <p>
 * Uses the given reasoner in the traversal methods. If disposeReasoner is
 * set to true, dispose also the reasoner, while calling
 * {@link TraversingEcoMapper#dispose()}.
 * 
 * @param all
 *            graph containing all ontologies, including ECO
 * @param reasoner
 *            reasoner capable of traversing ECO
 * @param disposeReasoner
 *            set to true if the reasoner should be disposed, when calling
 *            {@link TraversingEcoMapper#dispose()}
 * @return mapper
 * @throws IOException
 * @throws OWLException
 * @throws IllegalArgumentException
 *             throw when the reasoner is null, or the
 *             {@link OWLGraphWrapper} does not contain ECO.
 * 
 * @see EcoMapper#ECO_PURL_IRI
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static TraversingEcoMapper createTraversingEcoMapper(OWLGraphWrapper all, OWLReasoner reasoner, boolean disposeReasoner) throws IOException, OWLException {
	
	// This has bitten me, so let's try and be specific...
	if( reasoner == null )	{
		throw new IllegalArgumentException("No reasoner was specified for use with the EcoTools. Add a reasoner for the command line");
	}
			
	OWLOntology eco = null;
	
	// assume the graph wrapper is more than eco
	// try to find ECO by its purl
	Set<OWLOntology> allOntologies = all.getAllOntologies();
	for (OWLOntology owlOntology : allOntologies) {
		OWLOntologyID id = owlOntology.getOntologyID();
		Optional<IRI> ontologyIRI = id.getOntologyIRI();
		if (ontologyIRI.isPresent()) {
			if (EcoMapper.ECO_PURL_IRI.equals(ontologyIRI.get())) {
				eco = owlOntology;
			}
		}
	}
	if (eco == null) {
		throw new IllegalArgumentException("The specified graph did not contain ECO with the IRI: "+EcoMapper.ECO_PURL_IRI);
	}

	OWLGraphWrapper ecoGraph = new OWLGraphWrapper(eco);
	Reader reader = null;
	try {
		reader = createReader(EcoMapper.ECO_MAPPING_PURL);
		EcoMappings<OWLClass> mappings = loadEcoMappings(reader, ecoGraph);
		return new TraversingEcoMapperImpl(mappings, reasoner, disposeReasoner);
	}
	finally {
		IOUtils.closeQuietly(reader);
	}
}
 
Example #6
Source File: ChEBIParser.java    From act with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws OWLException,
      InstantiationException, IllegalAccessException,
      ClassNotFoundException, IOException {
  // We load an ontology from the URI specified
  IRI documentIRI = IRI.create(args[0]);
  IRI inchiIRI = IRI.create(args[1]);

  String subtree = "CHEBI_25212(metabolite)";
  if (args.length > 2)
    subtree = args[2]; // override the default

  find(subtree, documentIRI, inchiIRI);
}
 
Example #7
Source File: ChEBIParser.java    From act with GNU General Public License v3.0 5 votes vote down vote up
private static void find(String subtreeRoot, IRI documentIRI, IRI inchiIRI) throws OWLException, IOException {
  OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
  // Load the ontology...
  OWLOntology ontology = manager.loadOntologyFromOntologyDocument(documentIRI);
  // Print metadata about ontology...
  System.err.println("Ontology Loaded...");
  System.err.println("Document IRI: " + documentIRI);
  System.err.println("Ontology    : " + ontology.getOntologyID());
  System.err.println("Format      : " + manager.getOntologyFormat(ontology));

  HashMap<String, String> inchis = readInchis(inchiIRI);

  ChEBIParser chebi = new ChEBIParser(ontology);

  OWLClass clazz = manager.getOWLDataFactory().getOWLThing();
  System.err.println("Toplevel    : " + clazz);
  clazz = chebi.recurseToSubtreeRoot(clazz, subtreeRoot);
  System.err.println("Requested   : " + clazz);
  // Print the hierarchy
  HashMap<OWLClass, OWLClass> treeParents = new HashMap<OWLClass, OWLClass>();
  boolean doPrintSubtree = true;
  chebi.readSubtree(clazz, treeParents, doPrintSubtree);

  Set<OWLClass> metabolite_categories = treeParents.keySet();
  // System.err.println("Metabolite categories: " + metabolite_categories);

  // The function getAllElementsWithParentsIn picks out elements from the ontology that
  // have a "has_role" relationship with any member of metabolite_categories.
  // E.g., chemA has_role eukaryotic_metabolite; chemB has_role metabolite
  //      then { chemA -> eukaryotic_metabolite, chemB -> metabolite } will be in the
  //      returned map.
  // The fn also gathers data for each of the elems
  // e.g., { Sy->Synonyms, X->xref, S->SMILES, I -> InChI, Ik -> InChIKey }
  HashMap<OWLClass, P<OWLClass, HashMap<String, EntryTypes>>> elems;
  elems = chebi.getAllElementsWithParentsIn(metabolite_categories);
  for (OWLClass e : elems.keySet())
    output(e, elems.get(e), inchis, ontology);
}
 
Example #8
Source File: OntologyChangedListener.java    From ProtegeVOWL with MIT License 4 votes vote down vote up
public void ontologiesChanged(List<? extends OWLOntologyChange> arg0) throws OWLException {
	// not implemented yet
}
 
Example #9
Source File: GafCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected int preCheckOntology(String inConsistentMsg, String unsatisfiableMsg, String unsatisfiableModule) throws OWLException, IOException {
	// pre-check: only try to load ontology iff:
	// * ontology is consistent 
	// * no unsatisfiable classes
	OWLReasoner currentReasoner = reasoner;
	boolean disposeReasoner = false;
	try {
		if (currentReasoner == null) {
			disposeReasoner = true;
			currentReasoner = new ElkReasonerFactory().createReasoner(g.getSourceOntology());
		}
		boolean consistent = currentReasoner.isConsistent();
		if (consistent == false) {
			LOG.error(inConsistentMsg);
			return -1;
		}
		Set<OWLClass> unsatisfiable = currentReasoner.getUnsatisfiableClasses().getEntitiesMinusBottom();
		if (unsatisfiable.isEmpty() == false) {
			LOG.error(unsatisfiableMsg);
			OWLPrettyPrinter prettyPrinter = getPrettyPrinter();
			for (OWLClass owlClass : unsatisfiable) {
				LOG.error("Unsatisfiable: "+prettyPrinter.render(owlClass));
			}
			LOG.info("Creating module for unsatisfiable classes in file: "+unsatisfiableModule);
			ModuleType mtype = ModuleType.BOT;
			OWLOntologyManager m = g.getManager();
			SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, g.getSourceOntology(), mtype );
			Set<OWLEntity> seeds = new HashSet<OWLEntity>(unsatisfiable);
			Set<OWLAxiom> axioms = sme.extract(seeds);
			OWLOntology module = m.createOntology();
			m.addAxioms(module, axioms);
			File moduleFile = new File(unsatisfiableModule).getCanonicalFile();
			m.saveOntology(module, IRI.create(moduleFile));
			return -1;
		}
	}
	finally {
		if (disposeReasoner && currentReasoner != null) {
			currentReasoner.dispose();
		}
	}
	return 0;
}
 
Example #10
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static TraversingEcoMapper createTraversingEcoMapper(Reader mappingsReader, OWLGraphWrapper eco, OWLReasoner reasoner, boolean disposeReasoner) throws IOException, OWLException {
	EcoMappings<OWLClass> mappings = loadEcoMappings(mappingsReader, eco);
	return new TraversingEcoMapperImpl(mappings, reasoner, disposeReasoner);
}
 
Example #11
Source File: ReasonerDiff.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static Set<OWLAxiom> getInferences(OWLGraphWrapper graph, String reasonerName) throws OWLException {
	
	graph.mergeImportClosure();
	InferenceBuilder builder = new InferenceBuilder(graph, reasonerName);
	try {
		Set<OWLAxiom> inferredAxioms = new HashSet<OWLAxiom>();

		OWLOntology ontology = graph.getSourceOntology();
		OWLDataFactory dataFactory = ontology.getOWLOntologyManager().getOWLDataFactory();

		OWLReasoner reasoner = builder.getReasoner(ontology);
		for (OWLClass cls : ontology.getClassesInSignature()) {
			NodeSet<OWLClass> scs = reasoner.getSuperClasses(cls, true);
			for (Node<OWLClass> scSet : scs) {
				for (OWLClass sc : scSet) {
					if (sc.isOWLThing()) {
						continue; // do not report subclasses of owl:Thing
					}
					// we do not want to report inferred subclass links
					// if they are already asserted in the ontology
					boolean isAsserted = false;
					for (OWLClassExpression asc : OwlHelper.getSuperClasses(cls, ontology)) {
						if (asc.equals(sc)) {
							// we don't want to report this
							isAsserted = true;
						}
					}
					// include any inferred axiom that is NOT already asserted in the ontology
					if (!isAsserted) {						
						inferredAxioms.add(dataFactory.getOWLSubClassOfAxiom(cls, sc));
					}
				}
			}
		}
		return inferredAxioms;
	}
	finally {
		builder.dispose();
	}
	
}
 
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();
	}
}
 
Example #13
Source File: SnomedTaxonomyLoader.java    From snomed-owl-toolkit with Apache License 2.0 4 votes vote down vote up
@Override
public void newReferenceSetMemberState(String[] fieldNames, String id, String effectiveTime, String active, String moduleId, String refsetId, String referencedComponentId, String... otherValues) {
	boolean activeBool = ACTIVE.equals(active);
	if (refsetId.equals(Concepts.OWL_AXIOM_REFERENCE_SET) && owlParsingExceptionThrown == null) {
		if (activeBool) {
			try {
				addActiveAxiom(id, referencedComponentId, otherValues[0]);
			} catch (OWLException | OWLRuntimeException | IllegalArgumentException | ArrayIndexOutOfBoundsException e) {
				owlParsingExceptionThrown = e;
				owlParsingExceptionMemberId = id;
			}
		} else {
			// Remove the axiom from our active set
			// Match by id rather than a deserialised representation because the equals method may fail.
			snomedTaxonomy.removeAxiom(referencedComponentId, id);
		}
	} else if (refsetId.equals(Concepts.OWL_ONTOLOGY_REFERENCE_SET)) {
		if (Concepts.OWL_ONTOLOGY_NAMESPACE.equals(referencedComponentId)) {
			if (activeBool) {
				snomedTaxonomy.addOntologyNamespace(id, otherValues[0]);
			} else {
				snomedTaxonomy.removeOntologyNamespace(id);
			}
		} else if (Concepts.OWL_ONTOLOGY_HEADER.equals(referencedComponentId)) {
			if (activeBool) {
				snomedTaxonomy.addOntologyHeader(id, otherValues[0]);
			} else {
				snomedTaxonomy.removeOntologyHeader(id);
			}
		} else {
			LOGGER.warn("Unrecognised referencedComponentId '{}' in OWL Ontology reference set file. Only {} or {} are expected. Ignoring entry.",
					referencedComponentId, Concepts.OWL_ONTOLOGY_NAMESPACE, Concepts.OWL_ONTOLOGY_HEADER);
		}
	} else if (refsetId.equals(Concepts.MRCM_ATTRIBUTE_DOMAIN_INTERNATIONAL_REFERENCE_SET)) {
		long attributeId = parseLong(referencedComponentId);
		boolean ungrouped = otherValues[1].equals("0");
		Long contentTypeId = parseLong(otherValues[5]);
		if (activeBool && ungrouped) {
			snomedTaxonomy.addUngroupedRole(contentTypeId, attributeId);
		} else {
			snomedTaxonomy.removeUngroupedRole(contentTypeId, attributeId);
		}
	} else if (fieldNames.length == 7 && fieldNames[6].equals("acceptabilityId")) {
		snomedTaxonomy.setDescriptionAcceptability(referencedComponentId, refsetId, otherValues[0], activeBool);
	}
	ComponentFactory componentFactoryTap = getComponentFactoryTap();
	if (componentFactoryTap != null) {
		componentFactoryTap.newReferenceSetMemberState(fieldNames, id, effectiveTime, active, moduleId, refsetId, referencedComponentId, otherValues);
	}
}
 
Example #14
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Create an instance of a {@link EcoMapper}. Uses the given
 * {@link ParserWrapper} to load the ontology. Retrieves ECO from the given location and the
 * mapping from the PURL.
 * 
 * @param p
 * @param location
 * @return mapper pair
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<EcoMapper> createEcoMapper(ParserWrapper p, String location) throws OWLException, IOException {
	final OWLOntology eco = p.parseOWL(location);
	final OWLGraphWrapper graph = new OWLGraphWrapper(eco);
	final EcoMapper mapper = createEcoMapper(graph);
	final OntologyMapperPair<EcoMapper> pair = new OntologyMapperPair<EcoMapper>(graph, mapper);
	return pair ;
}
 
Example #15
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Create a {@link TraversingEcoMapper} instance using the given
 * {@link ParserWrapper} to load ECO from the given location. The mappings
 * are retrieved using the PURL.
 * <p>
 * Creates an ELK reasoner to be used in the traversal methods. Use
 * {@link TraversingEcoMapper#dispose()} to ensure proper cleanup of the ELK
 * worker thread pool.
 * 
 * @param p
 * @param location
 * @return mapper
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<TraversingEcoMapper> createTraversingEcoMapper(ParserWrapper p, String location) throws OWLException, IOException {
	OWLOntology eco = p.parseOWL(EcoMapper.ECO_PURL_IRI);
	OWLReasoner reasoner = reasonerFactor.createReasoner(eco);
	Reader reader = null;
	try {
		OWLGraphWrapper ecoGraph = new OWLGraphWrapper(eco);
		reader = createReader(EcoMapper.ECO_MAPPING_PURL);
		final TraversingEcoMapper mapper = createTraversingEcoMapper(reader, ecoGraph, reasoner, true);
		return new OntologyMapperPair<TraversingEcoMapper>(ecoGraph, mapper);
	}
	finally {
		IOUtils.closeQuietly(reader);
	}
}
 
Example #16
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create an instance of a {@link EcoMapper}. Uses a separate parser. Load
 * the ECO and mappings using their PURLs.
 * 
 * @return mapper pair
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_PURL
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<EcoMapper> createEcoMapper() throws OWLException, IOException {
	return createEcoMapper(new ParserWrapper());
}
 
Example #17
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create an instance of a {@link EcoMapper}. Uses a the manager to load ECO via the
 * PURL. Load mappings using the PURL.
 * @param m 
 * 
 * @return mapper pair
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_PURL
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<EcoMapper> createEcoMapper(OWLOntologyManager m) throws OWLException, IOException {
	ParserWrapper p = new ParserWrapper();
	p.setManager(m);
	return createEcoMapper(p);
}
 
Example #18
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create an instance of a {@link EcoMapper}. Uses the given
 * {@link ParserWrapper} to load the ontology. Retrieves ECO and the
 * mappings using their PURLs.
 * 
 * @param p
 * @return mapper pair
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_PURL
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<EcoMapper> createEcoMapper(ParserWrapper p) throws OWLException, IOException {
	return createEcoMapper(p, EcoMapper.ECO_PURL);
}
 
Example #19
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create a {@link TraversingEcoMapper} instance using a new
 * {@link ParserWrapper} to load ECO. ECO and the mappings are retrieved
 * using their PURLs.
 * <p>
 * Creates an ELK reasoner to be used in the traversal methods. Use
 * {@link TraversingEcoMapper#dispose()} to ensure proper cleanup of the ELK
 * worker thread pool.
 * 
 * @return mapper pair
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_PURL
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<TraversingEcoMapper> createTraversingEcoMapper() throws OWLException, IOException {
	return createTraversingEcoMapper(new ParserWrapper());
}
 
Example #20
Source File: EcoMapperFactory.java    From owltools with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Create a {@link TraversingEcoMapper} instance using the given
 * {@link ParserWrapper} to load ECO. ECO and the mappings are retrieved
 * using their PURLs.
 * <p>
 * Creates an ELK reasoner to be used in the traversal methods. Use
 * {@link TraversingEcoMapper#dispose()} to ensure proper cleanup of the ELK
 * worker thread pool.
 * 
 * @param p
 * @return mapper
 * @throws OWLException
 * @throws IOException
 * 
 * @see EcoMapper#ECO_PURL
 * @see EcoMapper#ECO_MAPPING_PURL
 */
public static OntologyMapperPair<TraversingEcoMapper> createTraversingEcoMapper(ParserWrapper p) throws OWLException, IOException {
	return createTraversingEcoMapper(p, EcoMapper.ECO_PURL);
}
 
Example #21
Source File: ChEBIParser.java    From act with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Print the class hierarchy for the given ontology from this class down,
 * assuming this class is at the given level. Makes no attempt to deal
 * sensibly with multiple inheritance.
 */
private void readSubtree(OWLClass clazz, HashMap<OWLClass, OWLClass> parents, boolean doPrint) throws OWLException {
  parents.put(clazz, null); // install in parents map the root we are looking for
  readSubtree(clazz, parents, 0, doPrint);
}