Search in sources :

Example 1 with OntologyTermSimple

use of ubic.basecode.ontology.model.OntologyTermSimple in project Gemma by PavlidisLab.

the class OntologyServiceImpl method initializeCategoryTerms.

private synchronized void initializeCategoryTerms() {
    URL termUrl = OntologyServiceImpl.class.getResource("/ubic/gemma/core/ontology/EFO.factor.categories.txt");
    OntologyServiceImpl.categoryTerms = new ConcurrentHashSet<>();
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(termUrl.openStream()))) {
        String line;
        boolean warned = false;
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("#") || StringUtils.isEmpty(line))
                continue;
            String[] f = StringUtils.split(line, '\t');
            if (f.length < 2) {
                continue;
            }
            OntologyTerm t = this.getTerm(f[0]);
            if (t == null) {
                // available. Inference will not be available.
                if (!warned) {
                    OntologyServiceImpl.log.info("Ontology needed is not loaded? Using light-weight placeholder for " + f[0] + " (further warnings hidden)");
                    warned = true;
                }
                t = new OntologyTermSimple(f[0], f[1]);
            }
            OntologyServiceImpl.categoryTerms.add(t);
        }
    } catch (IOException ioe) {
        OntologyServiceImpl.log.error("Error reading from term list '" + termUrl + "'; returning general term list", ioe);
        OntologyServiceImpl.categoryTerms = null;
    }
    OntologyServiceImpl.categoryTerms = Collections.unmodifiableCollection(OntologyServiceImpl.categoryTerms);
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) OntologyTerm(ubic.basecode.ontology.model.OntologyTerm) IOException(java.io.IOException) URL(java.net.URL) OntologyTermSimple(ubic.basecode.ontology.model.OntologyTermSimple)

Aggregations

BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 URL (java.net.URL)1 OntologyTerm (ubic.basecode.ontology.model.OntologyTerm)1 OntologyTermSimple (ubic.basecode.ontology.model.OntologyTermSimple)1