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


Java OWLOntology.getOntologyID方法代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLOntology.getOntologyID方法的典型用法代码示例。如果您正苦于以下问题:Java OWLOntology.getOntologyID方法的具体用法?Java OWLOntology.getOntologyID怎么用?Java OWLOntology.getOntologyID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.semanticweb.owlapi.model.OWLOntology的用法示例。


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

示例1: translate

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
 * 
 * @param gaf
 * @return lego ontology
 * @throws OWLException
 * @throws UnknownIdentifierException 
 */
public OWLOntology translate(GafDocument gaf) throws OWLException, UnknownIdentifierException {
	final OWLOntologyManager m = graph.getManager();
	OWLOntology lego = m.createOntology(IRI.generateDocumentIRI());
	OWLOntology sourceOntology = graph.getSourceOntology();
	OWLOntologyID ontologyID = sourceOntology.getOntologyID();
	if (ontologyID != null) {
		Optional<IRI> ontologyIRI = ontologyID.getOntologyIRI();
		if (ontologyIRI.isPresent()) {
			OWLDataFactory f = m.getOWLDataFactory();
			OWLImportsDeclaration importDeclaration = f.getOWLImportsDeclaration(ontologyIRI.get());
			m.applyChange(new AddImport(lego, importDeclaration ));
		}
	}
	translate(gaf.getGeneAnnotations(), lego);
	return lego;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:25,代码来源:GafToLegoIndividualTranslator.java

示例2: OntologyMetadata

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
public OntologyMetadata(OWLOntology ont) {
	super();
	OWLOntologyID id = ont.getOntologyID();
	if (id.getOntologyIRI().isPresent())
		ontologyIRI = id.getOntologyIRI().get().toString();
	if (id.getVersionIRI().isPresent())
		versionIRI = id.getVersionIRI().get().toString();
	importDirectives = new HashSet<String>();
	for (OWLImportsDeclaration oid : ont.getImportsDeclarations()) {
		importDirectives.add(oid.getIRI().toString());
	}
	classCount = ont.getClassesInSignature().size();
	namedIndividualCount = ont.getIndividualsInSignature().size();
	axiomCount = ont.getAxiomCount();
	annotations = new HashSet<OntologyAnnotation>();
	for (OWLAnnotation ann : ont.getAnnotations()) {
		annotations.add(new OntologyAnnotation(ann));
	}
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OntologyMetadata.java

示例3: handleVersion

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private String handleVersion(String ontologyId) {
	// TODO add an option to set/overwrite the version manually via command-line
	// TODO re-use/create a method in obo2owl for creating an version IRI
	String version;
	OWLOntology ontology = mooncat.getOntology();
	OWLOntologyID owlOntologyId = ontology.getOntologyID();
	Optional<IRI> versionIRI = owlOntologyId.getVersionIRI();
	if (versionIRI.isPresent() == false) {
		// set a new version IRI using the current date
		version = OntologyVersionTools.format(new Date());
		versionIRI = Optional.of(IRI.create(Obo2OWLConstants.DEFAULT_IRI_PREFIX+ontologyId+"/"+oortConfig.getVersionSubdirectory()+"/"+version+"/"+ontologyId+".owl"));
		
		OWLOntologyManager m = mooncat.getManager();
		m.applyChange(new SetOntologyID(ontology, new OWLOntologyID(owlOntologyId.getOntologyIRI(), versionIRI)));
	}
	else {
		String versionIRIString = versionIRI.get().toString();
		version = OntologyVersionTools.parseVersion(versionIRIString);
		if (version == null) {
			// use the whole IRI? escape?
			logError("Could not parse a version from ontolgy version IRI: "+versionIRIString);
			version = versionIRIString;
		}
	}
	return version;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:OboOntologyReleaseRunner.java

示例4: getTboxIRI

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Executed before the init call {@link #init()}.
 * 
 * @param graph
 * @return IRI, never null
 * @throws OWLOntologyCreationException
 */
protected IRI getTboxIRI(OWLGraphWrapper graph) throws OWLOntologyCreationException {
	OWLOntology tbox = graph.getSourceOntology();
	OWLOntologyID ontologyID = tbox.getOntologyID();
	if (ontologyID != null) {
		Optional<IRI> ontologyIRI = ontologyID.getOntologyIRI();
		if (ontologyIRI.isPresent()) {
			return ontologyIRI.get();
		}
	}
	throw new OWLOntologyCreationException("No ontology id available for tbox. An ontology IRI is required for the import into the abox.");
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:19,代码来源:CoreMolecularModelManager.java

示例5: EcoTools

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Create an instance for the given graph and reasoner.
 * 
 * @param graph
 * @param reasoner
 * @param disposeReasoner set to true, if the reasoner should also be disposed
 * @throws UnknownOWLOntologyException
 * @throws OWLOntologyCreationException
 * 
 * @see #dispose()
 */
public EcoTools (OWLGraphWrapper graph, OWLReasoner reasoner, boolean disposeReasoner) throws UnknownOWLOntologyException, OWLOntologyCreationException {

	// This has bitten me, so let's try and bew specific...
	if( reasoner == null ){ throw new Error("No reasoner was specified for use with the EcoTools. Add a reasoner for the command line"); }
	
	// assume the graph wrapper is more than eco
	// try to find ECO by its purl
	Set<OWLOntology> allOntologies = graph.getAllOntologies();
	OWLOntology eco = null;
	for (OWLOntology owlOntology : allOntologies) {
		OWLOntologyID id = owlOntology.getOntologyID();
		Optional<IRI> ontologyIRI = id.getOntologyIRI();
		if (ontologyIRI.isPresent()) {
			if (ECO_PURL.equals(ontologyIRI.get().toString())) {
				eco = owlOntology;
			}
		}
	}
	if (eco != null) {
		// found eco create new wrapper
		this.eco = new OWLGraphWrapper(eco);
	}
	else {
		// did not find eco, use whole wrapper
		this.eco = graph;
	}
	
	this.reasoner = reasoner;
	this.disposeReasonerP = disposeReasoner;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:42,代码来源:EcoTools.java

示例6: createTraversingEcoMapper

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

示例7: expand

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Create the GCIs for BioChEBI. Add the axioms into the given ontology.
 * 
 * @param ontology
 * @param ignoredClasses
 */
public void expand(OWLOntology ontology, Set<OWLClass> ignoredClasses) {
	final OWLOntologyManager manager = ontology.getOWLOntologyManager();
	final OWLDataFactory factory = manager.getOWLDataFactory();
	
	// scan axioms
	Set<OWLSubClassOfAxiom> axioms = ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED);
	for (OWLSubClassOfAxiom axiom : axioms) {
		OWLClassExpression superCE = axiom.getSuperClass();
		OWLClassExpression subCE = axiom.getSubClass();
		if (subCE.isAnonymous()) {
			// sub class needs to be an named OWLClass
			continue;
		}

		if (superCE instanceof OWLObjectSomeValuesFrom == false) {
			continue;
		}
		OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) superCE;

		OWLObjectPropertyExpression expression = some.getProperty();
		if (expression.isAnonymous()) {
			// object property expression needs to be a named OWLObjectProperty 
			continue;
		}

		OWLObjectProperty p = (OWLObjectProperty) expression;
		
		Set<OWLObjectProperty> expansions = expansionMap.get(p);
		if (expansions == null) {
			continue;
		}

		// get content for GCI
		OWLClassExpression y = some.getFiller();
		OWLClass x = subCE.asOWLClass();
		if (ignoredClasses.contains(x)) {
			continue;
		}
		for (OWLObjectProperty createProperty : expansions) {
			OWLClassExpression ce1 = factory.getOWLObjectSomeValuesFrom(createProperty, x);
			OWLClassExpression ce2 = factory.getOWLObjectSomeValuesFrom(createProperty, y);
			OWLEquivalentClassesAxiom eq = factory.getOWLEquivalentClassesAxiom(ce1, ce2);
			manager.addAxiom(ontology, eq);
		}
	}
	
	Set<OWLOntology> imports = ontology.getImports();
	StringBuilder sb = new StringBuilder();
	DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
	sb.append("Generated on ").append(dateFormat.format(new Date())).append(" using the following import chain:");
	for (OWLOntology owlOntology : imports) {
		OWLOntologyID ontologyID = owlOntology.getOntologyID();
		sb.append(" ");
		appendOntologyId(ontologyID, sb);
	}
	addComment(sb.toString(), ontology);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:64,代码来源:BioChebiGenerator.java

示例8: save

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
public void save(File baseFolder, BufferedWriter w) throws IOException, OWLOntologyStorageException {
	w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
	w.write("<catalog prefer=\"public\" xmlns=\"urn:oasis:names:tc:entity:xmlns:xml:catalog\">\n");
	
	for (OWLOntology ont : ontology.getImportsClosure()) {
		validateImports(ont);
		
		OWLOntologyID ontologyID = ont.getOntologyID();
		IRI actualIRI = null;
		Optional<IRI> optional = ontologyID.getOntologyIRI();
		if (optional.isPresent()) {
			actualIRI = optional.get();
		}

		// Not really sure why this is here, but apparently we can get
		// an ontology without an IRI, in which case we'll generate one
		// that is 'sort of' unique (only fails if two different machines run
		// this tool at the exact same time).
		//
		if (actualIRI == null) {
			IRI generatedIRI = IRI.generateDocumentIRI();
			actualIRI = generatedIRI;
		}
		// Always write the actualIRI
		String actualLocalFile = createLocalFileName(actualIRI);
		IRI outputStream = IRI.create(new File(baseFolder, actualLocalFile));
		ont.getOWLOntologyManager().saveOntology(ont, outputStream);
		
		if (LOGGER.isInfoEnabled()) {
			LOGGER.info("name: "+ actualIRI +" local: "+actualLocalFile);
		}
		w.write("  <uri name=\""+ actualIRI  +"\" uri=\""+ actualLocalFile +"\"/>\n");

		//
		// In case there is a difference between the source document IRI
		// and the IRI of the resolved target (e.g., there is an HTTP
		// redirect from a legacy IRI to a newer IRI), then write an entry
		// in the catalog that points the legacy IRI to the newer, canonical one.
		// Examples of this include:
		//  http://purl.obolibrary.org/obo/so.owl
		// which redirects to:
		//  http://purl.obolibrary.org/obo/so-xp.obo.owl
		//

		IRI 			documentIRI = ont.getOWLOntologyManager().getOntologyDocumentIRI(ont);
		if (documentIRI != actualIRI) {
			String sourceLocalFile = createLocalFileName(actualIRI);
			if (LOGGER.isInfoEnabled()) {
				LOGGER.info("alias: "+ documentIRI + " ==> " + actualIRI + " local: "+ sourceLocalFile);
			}
			w.write("  <uri name=\""+ documentIRI +"\" uri=\""+ sourceLocalFile +"\"/>\n");
		}
	}
	w.write("</catalog>\n");
	w.flush();
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:57,代码来源:ImportClosureSlurper.java


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