org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat Java Examples

The following examples show how to use org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat. 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: BridgeExtractor.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getSuffix(OWLDocumentFormat format) {
	if (format instanceof RDFXMLDocumentFormat) {
		return "owl";
	}
	if (format instanceof FunctionalSyntaxDocumentFormat) {
		return "ofn";
	}
	if (format instanceof OWLXMLDocumentFormat) {
		return "owx";
	}
	if (format instanceof ManchesterSyntaxDocumentFormat) {
		return "omn";
	}

	return "owl";
}
 
Example #2
Source File: OntologyService.java    From snomed-owl-toolkit with Apache License 2.0 5 votes vote down vote up
public void saveOntology(OWLOntology ontology, OutputStream outputStream) throws OWLOntologyStorageException {
	manager.getOntologyStorers().add(new SnomedFunctionalSyntaxStorerFactory());

	FunctionalSyntaxDocumentFormat owlDocumentFormat = getFunctionalSyntaxDocumentFormat();
	ontology.getOWLOntologyManager().setOntologyFormat(ontology, owlDocumentFormat);
	ontology.saveOntology(owlDocumentFormat, outputStream);
}
 
Example #3
Source File: OntologyService.java    From snomed-owl-toolkit with Apache License 2.0 5 votes vote down vote up
public FunctionalSyntaxDocumentFormat getFunctionalSyntaxDocumentFormat() {
	FunctionalSyntaxDocumentFormat owlDocumentFormat = new SnomedFunctionalSyntaxDocumentFormat();
	SnomedPrefixManager prefixManager = getSnomedPrefixManager();
	owlDocumentFormat.setPrefixManager(prefixManager);
	owlDocumentFormat.setDefaultPrefix(SNOMED_CORE_COMPONENTS_URI);
	owlDocumentFormat.setPrefix(SKOS_PREFIX, SKOS_URI);
	return owlDocumentFormat;
}
 
Example #4
Source File: SavingInferredAxioms.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws OWLOntologyStorageException,
		OWLOntologyCreationException {
	OWLOntologyManager inputOntologyManager = OWLManager.createOWLOntologyManager();
	OWLOntologyManager outputOntologyManager = OWLManager.createOWLOntologyManager();

	// Load your ontology.
	OWLOntology ont = inputOntologyManager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));

	// Create an ELK reasoner.
	OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ont);

	// Classify the ontology.
	reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	// To generate an inferred ontology we use implementations of
	// inferred axiom generators
	List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
	gens.add(new InferredSubClassAxiomGenerator());
	gens.add(new InferredEquivalentClassAxiomGenerator());

	// Put the inferred axioms into a fresh empty ontology.
	OWLOntology infOnt = outputOntologyManager.createOntology();
	InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner,
			gens);
	iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);

	// Save the inferred ontology.
	outputOntologyManager.saveOntology(infOnt,
			new FunctionalSyntaxDocumentFormat(),
			IRI.create((new File("path-to-output").toURI())));

	// Terminate the worker threads used by the reasoner.
	reasoner.dispose();
}
 
Example #5
Source File: GafCommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Created to mimic the translation to OWL for GAF checks
 * 
 * @param opts
 * @throws Exception
 */
@CLIMethod("--gaf2owl-simple")
public void gaf2OwlSimple(Opts opts) throws Exception {
	opts.info("-o FILE", "translates previously loaded GAF document into OWL, requires a loaded ontology to lookup ids");
	String out = null;
	while (opts.hasOpts()) {
		if (opts.nextEq("-o")) {
			out = opts.nextOpt();
		}
		else
			break;

	}
	if (g == null) {
		LOG.error("An ontology is required.");
		exit(-1);
	}
	else if (gafdoc == null) {
		LOG.error("A GAF document is required.");
		exit(-1);
	}
	else if (out == null) {
		LOG.error("An output file is required.");
		exit(-1);
	}
	LOG.info("Creating OWL represenation of annotations.");
	GAFOWLBridge bridge = new GAFOWLBridge(g);
	bridge.setGenerateIndividuals(false);
	bridge.setBasicAboxMapping(false);
	bridge.setBioentityMapping(BioentityMapping.CLASS_EXPRESSION);
	bridge.setSkipNotAnnotations(true);
	OWLOntology translated = bridge.translate(gafdoc);
	File outputFile = new File(out);
	OWLOntologyManager manager = translated.getOWLOntologyManager();
	OWLDocumentFormat ontologyFormat= new FunctionalSyntaxDocumentFormat();
	manager.saveOntology(translated, ontologyFormat, IRI.create(outputFile));
}