Search in sources :

Example 1 with StandardBlastDatabase

use of org.jbei.ice.lib.search.blast.StandardBlastDatabase in project ice by JBEI.

the class SearchIndexes method runSearch.

/**
 * Executes search using parameters specified in the query.
 *
 * @param userId unique user identifier making the request. This can be null if the request is via web of
 *               registries
 * @param query  wrapper around search query
 * @return wrapper around the list of search results
 */
public SearchResults runSearch(String userId, SearchQuery query) {
    String queryString = query.getQueryString();
    HashMap<String, SearchResult> blastResults = null;
    // check if there is a blast result and run first
    if (query.hasBlastQuery()) {
        if (query.getBlastQuery().getBlastProgram() == null)
            query.getBlastQuery().setBlastProgram(BlastProgram.BLAST_N);
        try {
            StandardBlastDatabase blastDatabase = StandardBlastDatabase.getInstance();
            blastResults = blastDatabase.runBlast(query.getBlastQuery());
        } catch (BlastException e) {
            Logger.error("Exception running blast " + e.getMessage());
            return null;
        }
    }
    // if no other search query or filter and there are blast results (not null) then return the blast results
    if (StringUtils.isEmpty(queryString) && blastResults != null && !query.hasFilter()) {
        if (blastResults.isEmpty())
            return new SearchResults();
        int start = query.getParameters().getStart();
        int count = query.getParameters().getRetrieveCount();
        return HibernateSearch.getInstance().filterBlastResults(userId, start, count, query, blastResults);
    }
    // text query (may also include blast)
    // no filter type indicates a term or phrase query
    HibernateSearch hibernateSearch = HibernateSearch.getInstance();
    if (!StringUtils.isEmpty(queryString)) {
        HashMap<String, QueryType> terms = parseQueryString(queryString);
        return hibernateSearch.executeSearch(userId, terms, query, blastResults);
    } else {
        return hibernateSearch.executeSearchNoTerms(userId, blastResults, query);
    }
}
Also used : StandardBlastDatabase(org.jbei.ice.lib.search.blast.StandardBlastDatabase) HibernateSearch(org.jbei.ice.storage.hibernate.search.HibernateSearch) BlastException(org.jbei.ice.lib.search.blast.BlastException)

Aggregations

BlastException (org.jbei.ice.lib.search.blast.BlastException)1 StandardBlastDatabase (org.jbei.ice.lib.search.blast.StandardBlastDatabase)1 HibernateSearch (org.jbei.ice.storage.hibernate.search.HibernateSearch)1