def _get_matching_genes(user, query): """Returns genes that match the given query string, and that the user can view. Args: user: Django user query: String typed into the awesomebar Returns: Sorted list of matches where each match is a dictionary of strings """ result = [] for g in get_queried_genes(query, MAX_RESULTS_PER_CATEGORY): if query.lower() in g['gene_id'].lower(): title = g['gene_id'] description = g['gene_symbol'] else: title = g['gene_symbol'] description = g['gene_id'] result.append({ 'key': g['gene_id'], 'title': title, 'description': '('+description+')' if description else '', 'href': '/gene_info/'+g['gene_id'], }) return result
def _get_matching_genes(user, query): """Returns genes that match the given query string, and that the user can view. Args: user: Django user query: String typed into the awesomebar Returns: Sorted list of matches where each match is a dictionary of strings """ result = [] for g in get_queried_genes(query, MAX_RESULTS_PER_CATEGORY): if query.lower() in g['gene_id'].lower(): title = g['gene_id'] description = g['gene_symbol'] else: title = g['gene_symbol'] description = g['gene_id'] result.append({ 'key': g['gene_id'], 'title': title, 'description': '(' + description + ')' if description else '', 'href': '/gene_info/' + g['gene_id'], }) return result