Search in sources :

Example 11 with EdamUri

use of org.edamontology.edammap.core.edam.EdamUri in project edammap by edamontology.

the class QueryLoader method edamUriJson.

private static EdamUri edamUriJson(Edam edam, Map<EdamUri, Concept> concepts) {
    if (edam.getUri() != null && !edam.getUri().trim().isEmpty()) {
        EdamUri edamUri = new EdamUri(edam.getUri().trim().toLowerCase(Locale.ROOT), EDAM_PREFIX);
        if (!checkEdamUri(edamUri, concepts))
            return null;
        return edamUri;
    }
    if (edam.getTerm() != null && !edam.getTerm().trim().isEmpty()) {
        String term = edam.getTerm().trim();
        if (concepts != null) {
            for (Entry<EdamUri, Concept> e : concepts.entrySet()) {
                if (e.getValue().getLabel().equals(term))
                    return e.getKey();
            }
            for (Entry<EdamUri, Concept> e : concepts.entrySet()) {
                if (e.getValue().getExactSynonyms().contains(term))
                    return e.getKey();
            }
            for (Entry<EdamUri, Concept> e : concepts.entrySet()) {
                if (e.getValue().getNarrowSynonyms().contains(term))
                    return e.getKey();
                if (e.getValue().getBroadSynonyms().contains(term))
                    return e.getKey();
            }
        }
        logger.warn("Can't find EDAM URI for term {} in JSON", term);
        return null;
    } else {
        logger.warn("An EDAM object is empty in JSON");
        return null;
    }
}
Also used : Concept(org.edamontology.edammap.core.edam.Concept) EdamUri(org.edamontology.edammap.core.edam.EdamUri)

Aggregations

EdamUri (org.edamontology.edammap.core.edam.EdamUri)11 ArrayList (java.util.ArrayList)4 Concept (org.edamontology.edammap.core.edam.Concept)4 LinkedHashSet (java.util.LinkedHashSet)3 Idf (org.edamontology.edammap.core.idf.Idf)3 Map (java.util.Map)2 Results (org.edamontology.edammap.core.benchmarking.Results)2 Output (org.edamontology.edammap.core.output.Output)2 PreProcessor (org.edamontology.edammap.core.preprocessing.PreProcessor)2 ConceptProcessed (org.edamontology.edammap.core.processing.ConceptProcessed)2 File (java.io.File)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 CoreArgs (org.edamontology.edammap.core.args.CoreArgs)1 IdfMake (org.edamontology.edammap.core.idf.IdfMake)1 ServerInput (org.edamontology.edammap.core.input.ServerInput)1 Function (org.edamontology.edammap.core.input.json.Function)1 InputOutput (org.edamontology.edammap.core.input.json.InputOutput)1