use of ubic.basecode.ontology.search.SearchIndex in project Gemma by PavlidisLab.
the class GeneOntologyServiceImpl method findTerm.
@Override
public Collection<OntologyTerm> findTerm(String queryString) {
if (!this.isReady())
return new HashSet<>();
if (GeneOntologyServiceImpl.log.isDebugEnabled())
GeneOntologyServiceImpl.log.debug("Searching Gene Ontology for '" + queryString + "'");
// make sure we are all-inclusive
queryString = queryString.trim();
queryString = queryString.replaceAll("\\s+", " AND ");
StopWatch timer = new StopWatch();
timer.start();
Collection<OntologyResource> rawMatches = new HashSet<>();
for (SearchIndex index : this.indices) {
rawMatches.addAll(OntologySearch.matchIndividuals(model, index, queryString));
}
if (timer.getTime() > 100) {
GeneOntologyServiceImpl.log.info("Find " + rawMatches.size() + " raw go terms from " + queryString + ": " + timer.getTime() + " ms");
}
timer.reset();
timer.start();
/*
* Required to make sure the descriptions are filled in.
*/
Collection<OntologyTerm> matches = new HashSet<>();
for (OntologyResource r : rawMatches) {
if (StringUtils.isBlank(r.getUri()))
continue;
OntologyTerm termForURI = GeneOntologyServiceImpl.getTermForURI(r.getUri());
if (termForURI == null) {
GeneOntologyServiceImpl.log.warn("No term for : " + r);
continue;
}
matches.add(termForURI);
}
if (timer.getTime() > 100) {
GeneOntologyServiceImpl.log.info("Convert " + rawMatches.size() + " raw go terms to terms: " + timer.getTime() + " ms");
}
return matches;
}
Aggregations