当前位置: 首页>>代码示例>>Java>>正文


Java OWLDocumentFormat类代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLDocumentFormat的典型用法代码示例。如果您正苦于以下问题:Java OWLDocumentFormat类的具体用法?Java OWLDocumentFormat怎么用?Java OWLDocumentFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


OWLDocumentFormat类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLDocumentFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: headerOWL

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
public void headerOWL() {
	if (isOWLOntologyFormat()) {
		LOG.info("using OWL ontology header");
		OWLDocumentFormat ofmt = this.getOWLOntologyFormat();
		if (ofmt instanceof RDFXMLDocumentFormat) {
			response.setContentType("application/rdf+xml;charset-utf-8");
		}
		else if (ofmt instanceof OWLXMLDocumentFormat) {
			response.setContentType("application/xml;charset-utf-8");
		}
		else {
			response.setContentType("text/plain;charset-utf-8");
		}
	}
	else {
		response.setContentType("text/plain;charset-utf-8");
	}
	response.setStatus(HttpServletResponse.SC_OK);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OWLHandler.java

示例2: printCachedObjects

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
public void printCachedObjects() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException {
	if (getFormat().equals("json")) {
		OWLGsonRenderer jsonp = new OWLGsonRenderer(response.getWriter());
		if (cachedObjects.size() > 0) {
			jsonp.render(cachedObjects);
		}
		else {
			jsonp.render(cachedAxioms);
		}
	}
	else {
		// ontology format
		if (cachedAxioms.size() == 0)
			return;
		OWLOntology tmpOnt = getTemporaryOntology();
		graph.getManager().addAxioms(tmpOnt, cachedAxioms);
		OWLDocumentFormat ofmt = getOWLOntologyFormat();
		LOG.info("Format:"+ofmt);
		ParserWrapper pw = new ParserWrapper();
		//graph.getManager().saveOntology(tmpOnt, ofmt, response.getOutputStream());
		pw.saveOWL(tmpOnt, ofmt, response.getOutputStream());
		graph.getManager().removeOntology(tmpOnt);
		cachedAxioms = new HashSet<OWLAxiom>();
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:OWLHandler.java

示例3: testConversion

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Ignore
@Test
public void testConversion() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	OWLOntology ont = pw.parse("http://purl.obolibrary.org/obo/go.owl");
	OWLGraphWrapper g = new OWLGraphWrapper(ont);

	GafObjectsBuilder builder = new GafObjectsBuilder();

	GafDocument gafdoc = builder.buildDocument("http://geneontology.org/gene-associations/gene_association.GeneDB_Spombe.gz");

	GAFOWLBridge bridge = new GAFOWLBridge(g);
	OWLOntology gafOnt = g.getManager().createOntology();
	bridge.setTargetOntology(gafOnt);
	bridge.translate(gafdoc);
	
	OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
	g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("/tmp/gaf.owl")));
	
	for (OWLAxiom ax : gafOnt.getAxioms()) {
		//LOG.info("AX:"+ax);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:PombeGAFOWLBridgeTest.java

示例4: testConversion

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testConversion() throws Exception{
	ParserWrapper pw = new ParserWrapper();
	OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
	OWLGraphWrapper g = new OWLGraphWrapper(ont);
	g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));

	GafObjectsBuilder builder = new GafObjectsBuilder();

	GafDocument gafdoc = builder.buildDocument(getResource("xp_inference_test.gaf"));

	GAFOWLBridge bridge = new GAFOWLBridge(g);
	OWLOntology gafOnt = g.getManager().createOntology();
	bridge.setTargetOntology(gafOnt);
	bridge.translate(gafdoc);
	
	OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
	g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("/tmp/gaf.owl")));
	
	for (OWLAxiom ax : gafOnt.getAxioms()) {
		LOG.info("AX:"+ax);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:GAFOWLBridgeTest.java

示例5: testConversion

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testConversion() throws Exception{
	ParserWrapper pw = new ParserWrapper();
	OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
	OWLGraphWrapper g = new OWLGraphWrapper(ont);
	g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));

	GafObjectsBuilder builder = new GafObjectsBuilder();

	GafDocument gafdoc = builder.buildDocument(getResource("xp_inference_test.gaf"));

	BasicABox bridge = new BasicABox(g);
	OWLOntology gafOnt = g.getManager().createOntology();
	bridge.setTargetOntology(gafOnt);
	bridge.translate(gafdoc);
	
	OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
	g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("target/foo.owl")));
	
	for (OWLAxiom ax : gafOnt.getAxioms()) {
		LOG.info("AX:"+ax);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:BasicAboxBridgeTest.java

示例6: testConversion

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testConversion() throws Exception{
	ParserWrapper pw = new ParserWrapper();
	OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
	OWLGraphWrapper g = new OWLGraphWrapper(ont);
	g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));

	GafObjectsBuilder builder = new GafObjectsBuilder();

	GafDocument gafdoc = builder.buildDocument(getResource("mgi-exttest.gaf"));

	GAFOWLBridge bridge = new GAFOWLBridge(g);
	bridge.setGenerateIndividuals(false);
	OWLOntology gafOnt = g.getManager().createOntology();
	bridge.setTargetOntology(gafOnt);
	bridge.translate(gafdoc);
	
	OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
	g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("target/gaf.owl")));
	
	for (OWLAxiom ax : gafOnt.getAxioms()) {
		//LOG.info("AX:"+ax);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:MgiGAFOWLBridgeTest.java

示例7: testConversionToIndividuals

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testConversionToIndividuals() throws Exception{
	ParserWrapper pw = new ParserWrapper();
	OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
	OWLGraphWrapper g = new OWLGraphWrapper(ont);
	g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));

	GafObjectsBuilder builder = new GafObjectsBuilder();

	GafDocument gafdoc = builder.buildDocument(getResource("mgi-exttest.gaf"));

	GAFOWLBridge bridge = new GAFOWLBridge(g);
	bridge.setGenerateIndividuals(false);
	OWLOntology gafOnt = g.getManager().createOntology();
	bridge.setTargetOntology(gafOnt);
	bridge.setBasicAboxMapping(true);
	bridge.translate(gafdoc);
	
	OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
	g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("target/gaf-abox.owl")));
	
	for (OWLAxiom ax : gafOnt.getAxioms()) {
		//LOG.info("AX:"+ax);
	}

}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:MgiGAFOWLBridgeTest.java

示例8: getSuffix

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
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";
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:BridgeExtractor.java

示例9: saveOWL

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
public void saveOWL(OWLOntology ont, OWLDocumentFormat owlFormat, String file) throws OWLOntologyStorageException, IOException {
    if ((owlFormat instanceof OBODocumentFormat) ||
            (owlFormat instanceof OWLOboGraphsFormat) || 
            (owlFormat instanceof OWLOboGraphsYamlFormat) || 
            (owlFormat instanceof OWLJSONFormat) || 
            (owlFormat instanceof OWLJsonLDFormat)){
        try {
            FileOutputStream os = new FileOutputStream(new File(file));
            saveOWL(ont, owlFormat, os);
        } catch (FileNotFoundException e) {
            throw new OWLOntologyStorageException("Could not open file: "+file, e);
        }
    }
    else {
        IRI iri;
        if (file.startsWith("file://")) {
            iri = IRI.create(file);
        }
        else {
            iri = IRI.create(new File(file));
        }
        manager.saveOntology(ont, owlFormat, iri);
    }
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:25,代码来源:ParserWrapper.java

示例10: writeModel

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
/**
 * Writes a model into a file
 * @param m the manager
 * @param o the ontology to write
 * @param f the format in which should be written
 * @param outPath 
 */
public static void writeModel(OWLOntologyManager m, OWLOntology o, OWLDocumentFormat f, String outPath){
    OutputStream out=null;
    try {
        out = new FileOutputStream(outPath);
        m.saveOntology(o, f, out);
        out.close();
    } catch (Exception ex) {
        System.out.println("Error while writing the model to file "+ex.getMessage());
        if(out!=null){
            try{
                out.close();
            }catch(Exception e){}
        }
    }
}
 
开发者ID:dgarijo,项目名称:Widoco,代码行数:23,代码来源:WidocoUtils.java

示例11: exportModel

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
/**
 * Export the ABox, will try to set the ontologyID to the given modelId (to
 * ensure import assumptions are met)
 * 
 * @param model
 * @param ontologyFormat
 * @return modelContent
 * @throws OWLOntologyStorageException
 */
public String exportModel(ModelContainer model, OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException {
	final OWLOntology aBox = model.getAboxOntology();
	final OWLOntologyManager manager = aBox.getOWLOntologyManager();
	
	// make sure the exported ontology has an ontologyId and that it maps to the modelId
	final IRI expectedABoxIRI = model.getModelId();
	Optional<IRI> currentABoxIRI = aBox.getOntologyID().getOntologyIRI();
	if (currentABoxIRI.isPresent() == false) {
		manager.applyChange(new SetOntologyID(aBox, expectedABoxIRI));
	}
	else {
		if (expectedABoxIRI.equals(currentABoxIRI) == false) {
			OWLOntologyID ontologyID = new OWLOntologyID(Optional.of(expectedABoxIRI), Optional.of(expectedABoxIRI));
			manager.applyChange(new SetOntologyID(aBox, ontologyID));
		}
	}

	// write the model into a buffer
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	if (ontologyFormat != null) {
		manager.saveOntology(aBox, ontologyFormat, outputStream);
	}
	else {
		manager.saveOntology(aBox, outputStream);
	}
	
	// extract the string from the buffer
	String modelString = outputStream.toString();
	return modelString;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:40,代码来源:CoreMolecularModelManager.java

示例12: gaf2OwlSimple

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:43,代码来源:GafCommandRunner.java

示例13: save

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
public void save(String fn, OWLDocumentFormat format, OWLOntology xo) throws FileNotFoundException, OWLOntologyStorageException {
	fn = fn + "." + getSuffix(format);
	File file = new File(fn);
	file.getParentFile().mkdirs();
	OutputStream os = new FileOutputStream(file);
	LOG.info("Saving: "+xo);
	ontology.getOWLOntologyManager().saveOntology(xo, format, os);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:9,代码来源:BridgeExtractor.java

示例14: testMerge

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testMerge() throws OWLOntologyCreationException, IOException, IncoherentOntologyException, OWLOntologyStorageException {
    ParserWrapper pw = new ParserWrapper();
    OWLGraphWrapper g =
            pw.parseToOWLGraph(getResourceIRIString("equivalence-set-merge-util-test.obo"));
    OWLOntology ont1 = g.getSourceOntology();
    ElkReasonerFactory rf = new ElkReasonerFactory();
    OWLReasoner reasoner = rf.createReasoner(ont1);
    EquivalenceSetMergeUtil esmu = new EquivalenceSetMergeUtil(g, reasoner);
    esmu.setPrefixScore("A", 8.0);
    esmu.setPrefixScore("B", 6.0);
    esmu.setPrefixScore("C", 4.0);
    OWLAnnotationProperty lp = g.getDataFactory().getOWLAnnotationProperty( OWLRDFVocabulary.RDFS_LABEL.getIRI() );
    esmu.setPropertyPrefixScore( lp, "C", 5.0);
    esmu.setPropertyPrefixScore( lp, "B", 4.0);
    esmu.setPropertyPrefixScore( lp, "A", 3.0);
    
    OWLAnnotationProperty dp = g.getDataFactory().getOWLAnnotationProperty( Obo2OWLVocabulary.IRI_IAO_0000115.getIRI() );
    esmu.setPropertyPrefixScore( dp, "B", 5.0);
    esmu.setPropertyPrefixScore( dp, "A", 4.0);
    esmu.setPropertyPrefixScore( dp, "C", 3.0);
    
    esmu.setRemoveAxiomatizedXRefs(true);

    esmu.merge();
    OWLDocumentFormat fmt = new OBODocumentFormat();
    pw.saveOWL(g.getSourceOntology(), "target/esmu.owl");
    //pw.setCheckOboDoc(false);
    pw.saveOWL(g.getSourceOntology(), fmt, "target/esmu.obo");
    
    OWLOntology ont2 = pw.parseOWL(getResourceIRIString("equivalence-set-merge-util-expected.obo"));
    assertEquals(0, compare(ont1, ont2));
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:34,代码来源:EquivalenceSetMergeUtilTest.java

示例15: testOnt

import org.semanticweb.owlapi.model.OWLDocumentFormat; //导入依赖的package包/类
@Test
public void testOnt() throws Exception{
	OWLGraphWrapper  wrapper = getOBO2OWLOntologyWrapper("caro.obo");
	final StringWriter stringWriter = new StringWriter();
	OWLGsonRenderer gr = new OWLGsonRenderer(new PrintWriter(stringWriter));
	gr.render(wrapper.getSourceOntology());
	if (RENDER_FLAG) {
		System.out.println(stringWriter.toString());
		ParserWrapper pw = new ParserWrapper();
		OWLDocumentFormat owlFormat = new OWLJSONFormat();
		File foo = folder.newFile("foo.json");
		pw.saveOWL(wrapper.getSourceOntology(), owlFormat , foo.getAbsolutePath());
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:15,代码来源:OWLGsonRendererTest.java


注:本文中的org.semanticweb.owlapi.model.OWLDocumentFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。