org.semanticweb.owlapi.model.OWLAnnotationValue Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLAnnotationValue. 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: LegoMetadata.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static String getTitle(Iterable<OWLAnnotation> annotations) {
	if (annotations != null) {
		for (OWLAnnotation annotation : annotations) {
			String propertyId = annotation.getProperty().getIRI()
					.toString();
			OWLAnnotationValue annValue = annotation.getValue();
			String value = annValue.accept(LiteralValueVisitor.INSTANCE);
			if (value != null) {
				if ("http://purl.org/dc/elements/1.1/title"
						.equals(propertyId)) {
					return value;
				}
			}
		}
	}
	return null;
}
 
Example #2
Source File: AxiomAnnotationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Retrieve the literal values for the axiom annotations with the given
 * annotation property IRI.
 * 
 * @param iri
 * @param axiom
 * @return literal values or null
 */
public static List<String> getAxiomAnnotationValues(IRI iri, OWLAxiom axiom) {
	List<String> result = null;
	for(OWLAnnotation annotation : axiom.getAnnotations()) {
		OWLAnnotationProperty property = annotation.getProperty();
		if (property.getIRI().equals(iri)) {
			OWLAnnotationValue value = annotation.getValue();
			if (value instanceof OWLLiteral) {
				String literal = ((OWLLiteral) value).getLiteral();
				if (result == null) {
					result = Collections.singletonList(literal);
				}
				else if (result.size() == 1) {
					result = new ArrayList<String>(result);
					result.add(literal);
				}
				else {
					result.add(literal);
				}
			}
		}
	}
	return result;
}
 
Example #3
Source File: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * .
 */
public static Annotation mobiAnnotation(OWLAnnotation owlAnno) {
    // TODO: ??? Fix this.
    if (owlAnno == null) {
        return null;
    }

    AnnotationProperty property = mobiAnnotationProperty(owlAnno.getProperty());
    OWLAnnotationValue value = owlAnno.getValue();
    if (value instanceof OWLLiteral) {
        OWLLiteral literal = (OWLLiteral) value;
        Literal simpleLiteral = mobiLiteral(literal);
        return new SimpleAnnotation(property, simpleLiteral);
    } else if (value instanceof org.semanticweb.owlapi.model.IRI) {
        org.semanticweb.owlapi.model.IRI iri = (org.semanticweb.owlapi.model.IRI) value;
        IRI simpleIri = mobiIRI(iri);
        return new SimpleAnnotation(property, simpleIri);
    } else if (value instanceof OWLAnonymousIndividual) {
        OWLAnonymousIndividual individual = (OWLAnonymousIndividual) value;
        Individual simpleIndividual = mobiIndividual(individual);
        return new SimpleAnnotation(property, simpleIndividual);
    } else {
        throw new OWLRuntimeException("Invalid annotation value");
    }
}
 
Example #4
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Find all corresponding {@link OWLObject}s with an OBO-style alternate identifier.
 * <p>
 * WARNING: This methods scans all object annotations in all ontologies. 
 * This is an expensive method.
 * 
 * @return map of altId to OWLObject (never null)
 */
public Map<String, OWLObject> getAllOWLObjectsByAltId() {
	final Map<String, OWLObject> results = new HashMap<String, OWLObject>();
	final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag());
	if (altIdProperty == null) {
		return Collections.emptyMap();
	}
	for (OWLOntology o : getAllOntologies()) {
		Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION);
		for (OWLAnnotationAssertionAxiom aa : aas) {
			OWLAnnotationValue v = aa.getValue();
			OWLAnnotationProperty property = aa.getProperty();
			if (altIdProperty.equals(property) && v instanceof OWLLiteral) {
				String altId = ((OWLLiteral)v).getLiteral();
				OWLAnnotationSubject subject = aa.getSubject();
				if (subject instanceof IRI) {
					OWLObject obj = getOWLObject((IRI) subject);
					if (obj != null) {
						results.put(altId, obj);
					}
				}
			}
		}
	}
	return results;
}
 
Example #5
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getOntologyAnnotationValue(OWLOntology o, OboFormatTag tag) {
	IRI dateTagIRI = Obo2Owl.trTagToIRI(tag.getTag());
	Set<OWLAnnotation> annotations = o.getAnnotations();
	for (OWLAnnotation annotation : annotations) {
		OWLAnnotationProperty property = annotation.getProperty();
		if(dateTagIRI.equals(property.getIRI())) {
			OWLAnnotationValue value = annotation.getValue();
			if (value != null) {
				if (value instanceof IRI) {
					return ((IRI) value).toString();
				}
				else if (value instanceof OWLLiteral) {
					return ((OWLLiteral) value).getLiteral();
				}
			}
		}
	}
	return null;
}
 
Example #6
Source File: TableToAxiomConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void buildClassMap(OWLGraphWrapper g) {
	IRI x = Obo2OWLVocabulary.IRI_OIO_hasDbXref.getIRI();
	for (OWLOntology ont : g.getAllOntologies()) {
		for (OWLClass c : ont.getClassesInSignature()) {
			for (OWLAnnotationAssertionAxiom aa : ont.getAnnotationAssertionAxioms(c.getIRI())) {
				if (aa.getProperty().getIRI().equals(x)) {
					OWLAnnotationValue v = aa.getValue();
					if (v instanceof OWLLiteral) {
						String xid =((OWLLiteral)v).getLiteral();
						OWLClass xc = (OWLClass) g.getOWLObjectByIdentifier(xid);
						if (xc == null) {
							LOG.error("Cannot get class for: "+xid);
						}
						else {
							config.classMap.put(xc, c);
						}
						//LOG.info(c + " ===> "+xid);
					}
				}					
			}
		}
	}
}
 
Example #7
Source File: GetLabelsTest.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getLabel(OWLEntity obj) throws MultiLabelException {
	String label = null;
	OWLAnnotationProperty labelProperty = ont.getOWLOntologyManager().getOWLDataFactory().getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(obj, labelProperty, ont)) {
		if (ann.getProperty().isLabel()) {
			OWLAnnotationValue v = ann.getValue();
			if (v instanceof OWLLiteral) {
				if (label != null) {
					throw new MultiLabelException(obj);
				}
				label = ((OWLLiteral)v).getLiteral();
			}
		}
	}
	return label;
}
 
Example #8
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
		OWLOntology ontology, OWLEntity subject, 
		OWLAnnotationValue type,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationProperty hasSynonymType =
		dataFactory.getOWLAnnotationProperty(
			format.getIRI("oio:hasSynonymType"));
	OWLAnnotation annotation = 
		dataFactory.getOWLAnnotation(hasSynonymType, type);
	Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
	annotations.add(annotation);
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value,
			annotations);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example #9
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) {
	return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() {

		@Override
		public OWLNamedIndividual visit(final IRI iri) {
			OWLNamedIndividual i = null;
			for(OWLNamedIndividual current : model.getIndividualsInSignature()) {
				if (current.getIRI().equals(iri)) {
					i = current;
					break;
				}
			}
			return i;
		}

		@Override
		public OWLNamedIndividual visit(OWLAnonymousIndividual individual) {
			return null;
		}

		@Override
		public OWLNamedIndividual visit(OWLLiteral literal) {
			return null;
		}
	});
}
 
Example #10
Source File: AbstractOWLOntologyLoader.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
protected Optional<String> evaluateLabelAnnotationValue(OWLEntity entity, OWLAnnotationValue value) {
    // get label annotations
    Optional<String> label = getOWLAnnotationValueAsString(value);
    if (!label.isPresent()) {
        // try and get the URI fragment and use that as label
        Optional<String> fragment = getShortForm(entity.getIRI());
        if (fragment.isPresent()) {
            return Optional.of(fragment.get());
        }
        else {
            getLog().warn("OWLEntity " + entity + " contains no label. " +
                    "No labels for this class will be loaded.");
            return  Optional.of(entity.toStringID());
        }
    }
    return label;
}
 
Example #11
Source File: OntologyHelper.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
private Collection<String> findAnnotationNames(IRI iri, OWLAnnotationProperty annotationType) {
	Collection<String> classNames = new HashSet<String>();

	// get all literal annotations
	for (OWLAnnotationAssertionAxiom axiom : ontology.getAnnotationAssertionAxioms(iri)) {
		if (axiom.getAnnotation().getProperty().equals(annotationType)) {
			OWLAnnotationValue value = axiom.getAnnotation().getValue();
			Optional<String> name = getOWLAnnotationValueAsString(value);
			if (name.isPresent()) {
				classNames.add(name.get());
			}
		}
	}

	return classNames;
}
 
Example #12
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param property the annotation property
 * @param value the annotation value
 * @return the annotation axiom
 */
protected static OWLAnnotationAssertionAxiom annotate(
		OWLOntology ontology, 
		OWLEntity subject,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
Example #13
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Get the definition xrefs (IAO_0000115)
 * 
 * @param c
 * @return list of definition xrefs
 */
public List<String> getDefXref(OWLObject c){
	OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_IAO_0000115.getIRI()); 
	OWLAnnotationProperty xap = getAnnotationProperty(OboFormatTag.TAG_XREF.getTag());

	if (c instanceof OWLEntity) {
		List<String> list = new ArrayList<String>();
		for (OWLOntology ont : getAllOntologies()) {
			Set<OWLAnnotationAssertionAxiom> axioms = ont.getAnnotationAssertionAxioms(((OWLEntity) c).getIRI());
			for (OWLAnnotationAssertionAxiom axiom :axioms){
				if(lap.equals(axiom.getProperty())){
					for(OWLAnnotation annotation: axiom.getAnnotations(xap)){
						OWLAnnotationValue value = annotation.getValue();
						if(value instanceof OWLLiteral){
							list.add(((OWLLiteral)value).getLiteral());
						}
					}
				}

			}
		}
		return list;
	}
	else {
		return null;
	}
}
 
Example #14
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method to get the first string literal of an
 * annotation property.
 *
 * @param ontology the current ontology
 * @param taxon the subject
 * @param property the property
 * @return null or the label content
 */
protected static String getFirstLiteral(OWLOntology ontology,
		OWLEntity taxon, OWLAnnotationProperty property) {
	Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAnnotationAssertionAxioms(taxon.getIRI());
	for (OWLAnnotationAssertionAxiom axiom : axioms) {
		if (property.equals(axiom.getProperty())) {
			OWLAnnotationValue value = axiom.getValue();
			if (value instanceof OWLLiteral) {
				OWLLiteral literal = (OWLLiteral)value;
				return literal.getLiteral();
			}
		}
	}
	return null;
}
 
Example #15
Source File: AbstractOWLOntologyLoader.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
private Optional<String> getOWLAnnotationValueAsString (OWLAnnotationValue value) {

        if (value instanceof IRI) {
            Optional<String> shortForm= getShortForm((IRI) value);
            if ( shortForm.isPresent()) {
                return Optional.of(shortForm.get());
            }
        }
        else if (value instanceof OWLLiteral) {
            return Optional.of(((OWLLiteral) value).getLiteral());
        }
        return Optional.empty();

    }
 
Example #16
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Find the corresponding {@link OWLObject}s for a given set of OBO-style alternate identifiers.
 * <p>
 * WARNING: This methods scans all object annotations in all ontologies. 
 * This is an expensive method.
 * <p>
 * Consider loading all altId-mappings using {@link #getAllOWLObjectsByAltId()}.
 * 
 * @param altIds
 * @return map of altId to OWLObject (never null)
 * @see #getAllOWLObjectsByAltId()
 */
public Map<String, OWLObject> getOWLObjectsByAltId(Set<String> altIds) {
	final Map<String, OWLObject> results = new HashMap<String, OWLObject>();
	final OWLAnnotationProperty altIdProperty = getAnnotationProperty(OboFormatTag.TAG_ALT_ID.getTag());
	if (altIdProperty == null) {
		return Collections.emptyMap();
	}
	for (OWLOntology o : getAllOntologies()) {
		Set<OWLAnnotationAssertionAxiom> aas = o.getAxioms(AxiomType.ANNOTATION_ASSERTION);
		for (OWLAnnotationAssertionAxiom aa : aas) {
			OWLAnnotationValue v = aa.getValue();
			OWLAnnotationProperty property = aa.getProperty();
			if (altIdProperty.equals(property) && v instanceof OWLLiteral) {
				String altId = ((OWLLiteral)v).getLiteral();
				if (altIds.contains(altId)) {
					OWLAnnotationSubject subject = aa.getSubject();
					if (subject instanceof IRI) {
						OWLObject obj = getOWLObject((IRI) subject);
						if (obj != null) {
							results.put(altId, obj);
						}
					}
				}
			}
		}
	}
	return results;
}
 
Example #17
Source File: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * gets the OBO-style ID of the specified object. e.g., "GO:0008150"
 * SerializationUtils.clone is used to avoid memory leaks.
 * 
 * @param iriId
 * @return OBO-style identifier, using obo2owl mappings or the literals extracted from oboInowl#id.
 */
public String getIdentifier(IRI iriId) {
	if (iriId.toString().startsWith(Obo2OWLConstants.DEFAULT_IRI_PREFIX))
		return (String) SerializationUtils.clone(Owl2Obo.getIdentifier(iriId));

	final OWLAnnotationProperty oboIdInOwl = getDataFactory().getOWLAnnotationProperty(Obo2Owl.trTagToIRI(OboFormatTag.TAG_ID.getTag()));
	for (OWLOntology o : getAllOntologies()) {
		Collection<OWLAnnotation> oas = EntitySearcher.getAnnotations(iriId, o);
		if (oas == null) continue;

		for (OWLAnnotation oa: oas) {
			// We specifically look for the annotation property, oboInOwl:id; ignore others.
			if (oa.getProperty().equals(oboIdInOwl) != true)
				continue;

			// We then get the object value of this property, which is supposed to be a literal.
			OWLAnnotationValue objValue = oa.getValue();
			if (objValue.isLiteral() != true) {
				LOG.warn("Odd. " + objValue + " of oboInOwl#id for "+ iriId + ", is supposed to be an literal, but it is not.");
				continue;
			}

			Optional<OWLLiteral> literalOpt = objValue.asLiteral();
			if (literalOpt.isPresent() != true) {
				LOG.warn("Odd. " + objValue + " of oboInOwl#id for "+ iriId + ", does not exist.");
				continue;
			}

			OWLLiteral literal = literalOpt.get();
			return (String) SerializationUtils.clone(literal.getLiteral());
		}
	}

	// In the case where the input class does not have oboInOwl#id, we return its original URL.
	LOG.warn("Unable to retrieve the value of oboInOwl#id as the identifier for " + iriId + "; we will use an original iri as the identifier.");
	return (String) SerializationUtils.clone(iriId.toString());
}
 
Example #18
Source File: OntologyHelper.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
private Optional<String> getOWLAnnotationValueAsString(OWLAnnotationValue value) {
	if (value instanceof IRI) {
		Optional<String> shortForm = getShortForm((IRI) value);
		if (shortForm.isPresent()) {
			return Optional.of(shortForm.get());
		}
	} else if (value instanceof OWLLiteral) {
		return Optional.of(((OWLLiteral) value).getLiteral());
	}
	return Optional.empty();
}
 
Example #19
Source File: FrameMakerLD.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Object makeAnnotationValue(OWLAnnotationValue v) {
	if (v instanceof IRI) {
		return ((IRI)v).toString();
	}
	else if (v instanceof OWLLiteral) {
		String lit = ((OWLLiteral)v).getLiteral();
		return lit;
	}
	else {
		return null;
	}
}
 
Example #20
Source File: AxiomCopier.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private AnnTuple getAnnTuple(OWLAnnotationAssertionAxiom aax) {
    String v;
    OWLAnnotationValue av = aax.getValue();
    if (av instanceof OWLLiteral) {
        v = ((OWLLiteral)av).getLiteral();
    }
    else {
        v = av.toString();
    }
    v = v.toLowerCase();
    return new AnnTuple((IRI)aax.getSubject(), v);
}
 
Example #21
Source File: SpeciesMergeUtil.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isSkippable(OWLClass c) {
	Set<OWLAnnotation> anns = OwlHelper.getAnnotations(c, ont);
	for (OWLAnnotation ann : anns) {
		String ap = ann.getProperty().getIRI().toString();
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof IRI) {
			IRI iv = (IRI)v;
			if (ap.endsWith("inSubset")) {
				// TODO - formalize this
				if (iv.toString().contains("upper_level")) {
					return true;
				}
				// this tag is used in uberon
				if (iv.toString().contains("non_informative")) {
					return true;
				}
				// hack: representation of early dev a bit problematic
				// temporary: find a way to exclude these axiomatically
				if (iv.toString().contains("early_development")) {
					return true;
				}
			}

		}
	}	
	return false;
}
 
Example #22
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLObject> findTaggedEntities(OWLAnnotationProperty p, Set<OWLAnnotationValue> values, final OWLGraphWrapper graph) {
	if (p == null || values == null || values.isEmpty()) {
		return Collections.emptySet();
	}
	final Set<OWLObject> entities = new HashSet<OWLObject>();
	Set<OWLOntology> allOntologies = graph.getAllOntologies();
	for (OWLOntology ontology : allOntologies) {
		Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION);
		for (OWLAnnotationAssertionAxiom axiom : axioms) {
			if (p.equals(axiom.getProperty()) && values.contains(axiom.getValue())) {
				axiom.getSubject().accept(new OWLAnnotationSubjectVisitor(){

					@Override
					public void visit(IRI iri) {
						OWLObject owlObject = graph.getOWLObject(iri);
						if (owlObject != null) {
							entities.add(owlObject);
						}
					}

					@Override
					public void visit(OWLAnonymousIndividual individual) {
						// do nothing
					}
				});
			}
		}
	}
	return entities;
}
 
Example #23
Source File: OntologyAnnotation.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public OntologyAnnotation(OWLAnnotation ann) {
	property = ann.getProperty().getIRI().toString();
	OWLAnnotationValue v = ann.getValue();
	if (v instanceof IRI) {
		value = v.toString();
	}
	else {
		OWLLiteral lit = ((OWLLiteral)v);
		value = lit.getLiteral().toString();
	}
}
 
Example #24
Source File: PropertyViewOntologyBuilder.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public String getLabel(OWLEntity c, OWLOntology ont) {
	String label = null;		
	// todo - ontology import closure
	for (OWLAnnotation ann : OwlHelper.getAnnotations(c, owlDataFactory.getRDFSLabel(), ont)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
Example #25
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isUpperLevel(OWLClass c) {
	// TODO - cache
	Set<OWLAnnotation> anns = OwlHelper.getAnnotations(c, inputOntology);
	for (OWLAnnotation ann : anns) {
		String ap = ann.getProperty().getIRI().toString();
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof IRI) {
			IRI iv = (IRI)v;
			if (ap.endsWith("inSubset")) {
				// TODO - formalize this
				if (iv.toString().contains("upper_level")) {
					return true;
				}
				// this tag is used in uberon
				if (iv.toString().contains("non_informative")) {
					return true;
				}
				// hack: representation of early dev a bit problematic
				// temporary: find a way to exclude these axiomatically
				if (iv.toString().contains("early_development")) {
					return true;
				}
			}

		}
	}
	return false;
}
 
Example #26
Source File: AbstractSimPreProcessor.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public String getLabel(OWLEntity c, OWLOntology ont) {
	String label = null;		
	// todo - ontology import closure
	OWLAnnotationProperty property = getOWLDataFactory().getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(c, property, ont)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
Example #27
Source File: OldSimpleOwlSim.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getLabel(OWLEntity e) {
	String label = null;		
	// todo - ontology import closure
	OWLAnnotationProperty property = owlDataFactory.getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(e, property, sourceOntology)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
Example #28
Source File: SimEngine.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * any class whose label matches any of the strings returned
 * here will be excluded from any analysis.
 *
 * the set of excluded labels is controlled by loading an
 * ontology with an entity PhenoSim_0000001 where all
 * the literals associated with this are excluded.
 * (note that this method may change in future)
 * 
 * @return excluded labels 
 */
public Set<String> getExcludedLabels() {
	if (excludedLabels != null)
		return excludedLabels;
	excludedLabels = new HashSet<String>();
	for (OWLAnnotationAssertionAxiom aa :
		getGraph().getSourceOntology().getAnnotationAssertionAxioms(IRI.create("http://purl.obolibrary.org/obo/PhenoSim_0000001"))) {
		OWLAnnotationValue v = aa.getValue();
		if (v instanceof OWLLiteral) {
			excludedLabels.add(((OWLLiteral)v).getLiteral());
		}
	}
	return excludedLabels;
}
 
Example #29
Source File: FrameMakerLD.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private AnnotationLD makeAnnotation(OWLAnnotationProperty property,
		OWLAnnotationValue value) {
	return new AnnotationLD(makeAnnotationPropertyStub(property), makeAnnotationValue(value));
}
 
Example #30
Source File: OwlConverter.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-method")
public ElkAnnotationValue convert(OWLAnnotationValue value) {
	return OWL_ANNOTATION_CONVERTER.visit(value);
}