Search in sources :

Example 1 with JsonAnnotation

use of org.geneontology.minerva.json.JsonAnnotation in project minerva by geneontology.

the class ModelCreator method extractDataProperties.

Map<OWLDataProperty, Set<OWLLiteral>> extractDataProperties(JsonAnnotation[] values, ModelContainer model) throws UnknownIdentifierException {
    Map<OWLDataProperty, Set<OWLLiteral>> result = new HashMap<OWLDataProperty, Set<OWLLiteral>>();
    if (values != null && values.length > 0) {
        OWLDataFactory f = model.getOWLDataFactory();
        for (JsonAnnotation jsonAnn : values) {
            if (jsonAnn.key != null && jsonAnn.value != null) {
                AnnotationShorthand shorthand = AnnotationShorthand.getShorthand(jsonAnn.key, curieHandler);
                if (shorthand == null) {
                    IRI pIRI = curieHandler.getIRI(jsonAnn.key);
                    if (dataPropertyIRIs.contains(pIRI)) {
                        OWLLiteral literal = JsonTools.createLiteral(jsonAnn, f);
                        if (literal != null) {
                            OWLDataProperty property = f.getOWLDataProperty(pIRI);
                            Set<OWLLiteral> literals = result.get(property);
                            if (literals == null) {
                                literals = new HashSet<OWLLiteral>();
                                result.put(property, literals);
                            }
                            literals.add(literal);
                        }
                    }
                }
            }
        }
    }
    return result;
}
Also used : JsonAnnotation(org.geneontology.minerva.json.JsonAnnotation) AnnotationShorthand(org.geneontology.minerva.util.AnnotationShorthand)

Example 2 with JsonAnnotation

use of org.geneontology.minerva.json.JsonAnnotation in project minerva by geneontology.

the class ModelCreator method extract.

Set<OWLAnnotation> extract(JsonAnnotation[] values, String userId, Set<String> providerGroups, VariableResolver batchValues, ModelContainer model) throws UnknownIdentifierException {
    Set<OWLAnnotation> result = new HashSet<OWLAnnotation>();
    OWLDataFactory f = model.getOWLDataFactory();
    if (values != null) {
        for (JsonAnnotation jsonAnn : values) {
            if (jsonAnn.key != null && jsonAnn.value != null) {
                AnnotationShorthand shorthand = AnnotationShorthand.getShorthand(jsonAnn.key, curieHandler);
                if (shorthand != null) {
                    if (AnnotationShorthand.evidence == shorthand) {
                        IRI evidenceIRI;
                        if (batchValues.notVariable(jsonAnn.value)) {
                            evidenceIRI = curieHandler.getIRI(jsonAnn.value);
                        } else {
                            evidenceIRI = batchValues.getVariableValue(jsonAnn.value).getIRI();
                        }
                        result.add(create(f, shorthand, evidenceIRI));
                    } else {
                        result.add(create(f, shorthand, JsonTools.createAnnotationValue(jsonAnn, f)));
                    }
                } else {
                    IRI pIRI = curieHandler.getIRI(jsonAnn.key);
                    if (dataPropertyIRIs.contains(pIRI) == false) {
                        OWLAnnotationValue annotationValue = JsonTools.createAnnotationValue(jsonAnn, f);
                        result.add(f.getOWLAnnotation(f.getOWLAnnotationProperty(pIRI), annotationValue));
                    }
                }
            }
        }
    }
    addGeneratedAnnotations(userId, providerGroups, result, f);
    return result;
}
Also used : JsonAnnotation(org.geneontology.minerva.json.JsonAnnotation) AnnotationShorthand(org.geneontology.minerva.util.AnnotationShorthand)

Aggregations

JsonAnnotation (org.geneontology.minerva.json.JsonAnnotation)2 AnnotationShorthand (org.geneontology.minerva.util.AnnotationShorthand)2