org.semanticweb.owlapi.model.OWLLiteral Java Examples
The following examples show how to use
org.semanticweb.owlapi.model.OWLLiteral.
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: OntologyMetadataMarkdownWriter.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private static Set<String> getVals(String p, Set<OWLAnnotation> oAnns) { Set<OWLAnnotation> rmAnns = new HashSet<OWLAnnotation>(); Set<String> vs = new HashSet<String>(); System.err.println(" L: "+p); for (OWLAnnotation ann : oAnns) { String ps = ann.getProperty().getIRI().toString(); ps = ps.replaceAll(".*/", ""); if (ps.equals(p)) { String v = (ann.getValue() instanceof OWLLiteral) ? ((OWLLiteral)ann.getValue()).getLiteral() : ann.getValue().toString(); //String v = ann.getValue().toString(); vs.add(v); System.err.println(" P: "+ps+"="+v); rmAnns.add(ann); } } oAnns.removeAll(rmAnns); return vs; }
Example #2
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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 #3
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #4
Source File: IOHelperTest.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test creating IRIs and Literals. * * @throws IOException on file problem */ @Test public void testOntologyAnnotations() throws IOException { IOHelper ioh = new IOHelper(); OWLLiteral literal; assertEquals(IRI.create(base), ioh.createIRI(base)); literal = IOHelper.createLiteral("FOO"); assertEquals("FOO", OntologyHelper.getValue(literal)); literal = ioh.createTypedLiteral("100", "xsd:integer"); assertEquals("100", literal.getLiteral()); assertEquals(ioh.createIRI("xsd:integer"), literal.getDatatype().getIRI()); literal = IOHelper.createTaggedLiteral("100", "en"); assertEquals("100", literal.getLiteral()); assertEquals("en", literal.getLang()); }
Example #5
Source File: OWLGraphWrapper.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * It returns array of synonyms (is encoded as synonym in obo format and IAO_0000118 annotation property in OWL format) of a class * @param c * @return array of strings or null */ @Deprecated public String[] getSynonymStrings(OWLObject c) { OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(IRI.create(DEFAULT_IRI_PREFIX + "IAO_0000118")); Set<OWLAnnotation>anns = null; if (c instanceof OWLEntity) { anns = OwlHelper.getAnnotations((OWLEntity) c, lap, sourceOntology); } else { return null; } List<String> list = new ArrayList<String>(); for (OWLAnnotation a : anns) { if (a.getValue() instanceof OWLLiteral) { OWLLiteral val = (OWLLiteral) a.getValue(); list.add(val.getLiteral()); // return first - todo - check zero or one } } return list.toArray(new String[list.size()]); }
Example #6
Source File: ModelAnnotationSolrDocumentLoader.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #7
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * fetches the value of a single-valued annotation property for an OWLObject * <p> * TODO: provide a flag that determines behavior in the case of >1 value * * @param c * @param lap * @return value */ public String getAnnotationValue(OWLObject c, OWLAnnotationProperty lap) { Set<OWLAnnotation>anns = new HashSet<OWLAnnotation>(); if (c instanceof OWLEntity) { for (OWLOntology ont : getAllOntologies()) { anns.addAll(OwlHelper.getAnnotations((OWLEntity) c, lap, ont)); } } else { return null; } for (OWLAnnotation a : anns) { if (a.getValue() instanceof OWLLiteral) { OWLLiteral val = (OWLLiteral) a.getValue(); return (String) SerializationUtils.clone(val.getLiteral()); // return first - TODO - check zero or one } } return null; }
Example #8
Source File: TableToAxiomConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #9
Source File: GetLabelsTest.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 #10
Source File: AxiomAnnotationTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * 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 #11
Source File: QueryResultTest.java From sparql-dl-api with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void setUp() { arg1 = new QueryArgument(new Var("x")); arg2 = new QueryArgument(IRI.create("http://xmlns.com/foaf/0.1/name")); arg3 = new QueryArgument(mock(OWLLiteral.class)); atom = new QueryAtom(QueryAtomType.PROPERTY_VALUE, arg1, arg2, arg3); QueryAtomGroupImpl groupImpl = new QueryAtomGroupImpl(); groupImpl.addAtom(atom); group = groupImpl; QueryImpl queryImpl = new QueryImpl(QueryType.SELECT); queryImpl.addAtomGroup(group); queryImpl.addResultVar(arg1); query = queryImpl; }
Example #12
Source File: LiteralTranslator.java From sparql-dl-api with GNU Lesser General Public License v3.0 | 6 votes |
public OWLLiteral toOWLLiteral(QueryArgument argument) { return argument.getValueAsLiteral(); // Matcher matcher = LITERAL_PATTERN.matcher(argument.getValue()); // if(matcher.matches()) { // String literal = matcher.group(1); // String lang = matcher.group(3); // String datatypeIRI = matcher.group(5); // if (lang != null) { // return dataFactory.getOWLLiteral(literal, lang); // } // else if (datatypeIRI != null) { // OWLDatatype datatype; // if(datatypeIRI.equals("http://www.w3.org/2001/XMLSchema#string")) { // datatype = STRING_DATATYPE; // } // else { // datatype = dataFactory.getOWLDatatype(IRI.create(datatypeIRI)); // } // return dataFactory.getOWLLiteral(literal, datatype); // } // } // return dataFactory.getOWLLiteral(argument.getValue(), dataFactory.getRDFPlainLiteral()); }
Example #13
Source File: QueryArgument.java From sparql-dl-api with GNU Lesser General Public License v3.0 | 6 votes |
public String getValueAsString() { if (value instanceof IRI) { return value.toString(); } else if (value instanceof OWLLiteral) { return ((OWLLiteral) value).getLiteral(); } else if (value instanceof OWLAnonymousIndividual) { return ((OWLAnonymousIndividual) value).getID().toString(); } else if (value instanceof Var) { return ((Var) value).getName(); } else { return value.toString(); } }
Example #14
Source File: OntologyLoader.java From molgenis with GNU Lesser General Public License v3.0 | 6 votes |
private Set<String> getAnnotation(OWLEntity entity, String property) { Set<String> annotations = new HashSet<>(); try { OWLAnnotationProperty owlAnnotationProperty = factory.getOWLAnnotationProperty(IRI.create(property)); for (OWLAnnotation annotation : entity.getAnnotations(ontology, owlAnnotationProperty)) { if (annotation.getValue() instanceof OWLLiteral) { OWLLiteral val = (OWLLiteral) annotation.getValue(); annotations.add(val.getLiteral()); } } } catch (Exception e) { throw new RuntimeException("Failed to get label for OWLClass " + entity); } return annotations; }
Example #15
Source File: GraphOwlVisitor.java From SciGraph with Apache License 2.0 | 6 votes |
@Override public Void visit(OWLSubClassOfAxiom axiom) { long subclass = getOrCreateNode(getIri(axiom.getSubClass())); long superclass = getOrCreateNode(getIri(axiom.getSuperClass())); long relationship = getOrCreateRelationship(subclass, superclass, OwlRelationships.RDFS_SUBCLASS_OF); for (OWLAnnotation annotation : axiom.getAnnotations()) { // TODO: Is there a more elegant way to process these annotations? String property = annotation.getProperty().getIRI().toString(); if (annotation.getValue() instanceof OWLLiteral) { Optional<Object> value = OwlApiUtils.getTypedLiteralValue((OWLLiteral) annotation.getValue()); if (value.isPresent()) { graph.addRelationshipProperty(relationship, property, value.get()); } } } return null; }
Example #16
Source File: SpeciesMergeUtil.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
private OWLAxiom tr(OWLClass c, OWLAnnotationAssertionAxiom ax) { OWLAnnotationProperty p = ax.getProperty(); if (!ecmap.containsKey(c)) { // preserve as-is, exception for labels if (p.isLabel()) { OWLLiteral lit = (OWLLiteral) ax.getValue(); String newVal = lit.getLiteral() + " (" + suffix + ")"; return fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ax.getSubject(), fac.getOWLLiteral(newVal)); } return ax; } else { // the class is merged - ditch its axioms // (in future some may be preserved - syns?) // fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ecmap, // ax.getValue()); return null; } }
Example #17
Source File: SimpleOntologyValuesTest.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testOwlapiLiteral() throws Exception { Literal literal = mock(Literal.class); IRI datatypeIRI = mock(IRI.class); org.semanticweb.owlapi.model.IRI owlIRI = mock(org.semanticweb.owlapi.model.IRI.class); expect(datatypeIRI.stringValue()).andReturn("http://www.w3.org/2001/XMLSchema#string").anyTimes(); expect(literal.getDatatype()).andReturn(datatypeIRI); expect(literal.getLanguage()).andReturn(Optional.empty()); expect(literal.getLabel()).andReturn("test"); mockStaticPartial(SimpleOntologyValues.class, "owlapiIRI"); expect(SimpleOntologyValues.owlapiIRI(isA(IRI.class))).andReturn(owlIRI).anyTimes(); replay(literal, datatypeIRI, SimpleOntologyValues.class); OWLLiteral owlLiteral = SimpleOntologyValues.owlapiLiteral(literal); assertEquals("test", owlLiteral.getLiteral()); }
Example #18
Source File: SimpleOntologyValuesTest.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testMobiLiteral() throws Exception { OWLLiteral owlLiteral = new OWLLiteralImplString("testString"); IRI iri = factory.createIRI("http://www.w3.org/2001/XMLSchema#string"); Literal literal = mock(Literal.class); Datatype datatype = mock(Datatype.class); expect(datatype.getIRI()).andReturn(iri).anyTimes(); expect(literal.getDatatype()).andReturn(iri).anyTimes(); expect(literal.getLabel()).andReturn("testString").anyTimes(); replay(literal, datatype); mockStaticPartial(SimpleOntologyValues.class, "mobiDatatype"); expect(SimpleOntologyValues.mobiDatatype(isA(OWLDatatype.class))).andReturn(datatype).anyTimes(); replay(SimpleOntologyValues.class); assertEquals("testString", SimpleOntologyValues.mobiLiteral(owlLiteral).getLabel()); assertEquals(iri, SimpleOntologyValues.mobiLiteral(owlLiteral).getDatatype()); }
Example #19
Source File: OwlApiUtils.java From SciGraph with Apache License 2.0 | 6 votes |
/*** * @param literal An OWLLiteral * @return an optional correctly typed Java object from the OWLLiteral */ public static Optional<Object> getTypedLiteralValue(OWLLiteral literal) { Object literalValue = null; if (literal.isBoolean()) { literalValue = literal.parseBoolean(); } else if (literal.isInteger()) { literalValue = literal.parseInteger(); } else if (literal.isFloat()) { literalValue = literal.parseFloat(); } else if (literal.isDouble()) { literalValue = literal.parseDouble(); } else { // This needs to be addressed by #110 if (literal.hasLang() && !literal.getLang().startsWith("en")) { if (!unknownLanguages.contains(literal.getLang())) { unknownLanguages.add(literal.getLang()); logger.warning("Ignoring *all* literals with unsupported language: \"" + literal.getLang() + "\"."); } return Optional.empty(); } literalValue = literal.getLiteral(); } return Optional.of(literalValue); }
Example #20
Source File: SimpleOntologyValues.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
/** * . */ public static OWLAnnotation owlapiAnnotation(Annotation anno) { // TODO: ??? Fix this. if (anno == null) { return null; } OWLAnnotationProperty owlAnnoProperty = owlapiAnnotationProperty(anno.getProperty()); Value value = anno.getValue(); if (value instanceof IRI) { org.semanticweb.owlapi.model.IRI iri = owlapiIRI((IRI) value); return new OWLAnnotationImpl(owlAnnoProperty, iri, Stream.empty()); } else if (value instanceof Literal) { OWLLiteral literal = owlapiLiteral((Literal) value); return new OWLAnnotationImpl(owlAnnoProperty, literal, Stream.empty()); } else if (value instanceof SimpleIndividual) { OWLIndividual individual = owlapiIndividual((SimpleIndividual) value); return new OWLAnnotationImpl(owlAnnoProperty, (OWLAnonymousIndividual) individual, Stream.empty()); } else { throw new MobiOntologyException("Invalid annotation value"); } }
Example #21
Source File: SimpleOntologyValues.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
/** * . */ 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 #22
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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 typeCURIE a CURIE string for the type of synonym * @param propertyCURIE a CURIE string for the property * @param value the string value of the synonym * @return the axiom */ protected static OWLAnnotationAssertionAxiom synonym( OWLOntology ontology, OWLEntity subject, String typeCURIE, String propertyCURIE, String value) { OWLDataFactory dataFactory = ontology.getOWLOntologyManager(). getOWLDataFactory(); IRI type = format.getIRI(typeCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty( format.getIRI(propertyCURIE)); OWLLiteral literal = dataFactory.getOWLLiteral(value); return synonym(ontology, subject, type, property, literal); }
Example #23
Source File: OWLConverter.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Convenience method for adding an annotation assertion to the * ontology itself, taking a CURIE for the property and an Boolean literal. * * @param ontology the current ontology * @param propertyCURIE will be expanded to the full annotation * property IRI * @param value the literal value of the annotation * @return the annotation axiom */ protected static OWLAnnotation annotate(OWLOntology ontology, String propertyCURIE, String value) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); IRI iri = format.getIRI(propertyCURIE); OWLAnnotationProperty property = dataFactory.getOWLAnnotationProperty(iri); OWLLiteral literal = dataFactory.getOWLLiteral(value); OWLAnnotation annotation = dataFactory.getOWLAnnotation( property, literal); manager.applyChange( new AddOntologyAnnotation(ontology, annotation)); return annotation; }
Example #24
Source File: OWLGraphWrapperEdges.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public void excludeAllWith(OWLAnnotationProperty ap, OWLOntology o) { for (OWLObjectProperty p : o.getObjectPropertiesInSignature(Imports.INCLUDED)) { Set<OWLAnnotation> anns = OwlHelper.getAnnotations(p, ap, o); for (OWLAnnotation ann : anns) { if (ann.getValue() instanceof OWLLiteral) { OWLLiteral v = (OWLLiteral) ann.getValue(); if (v.parseBoolean()) { excludeProperty(p); } } } } }
Example #25
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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 #26
Source File: OWLGraphWrapperExtended.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 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 #27
Source File: AxiomAnnotationTools.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Append xref annotations onto an existing axiom * * @param axiom * @param xrefs * @param ontology * @return */ public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) { // filter existing Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations()); final OWLOntologyManager manager = ontology.getOWLOntologyManager(); final OWLDataFactory factory = manager.getOWLDataFactory(); for (String x : xrefs) { OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref")); OWLLiteral v = factory.getOWLLiteral(x); newAnnotations.add(factory.getOWLAnnotation(p, v)); } final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology); return newAxiom; }
Example #28
Source File: AxiomCopier.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 #29
Source File: FrameMakerLD.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
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 #30
Source File: GraphReasoner.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind, OWLDataProperty pe) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException { // TODO Auto-generated method stub return null; }