Skip to content

Commit

Permalink
Improve documentation, search by uniprot if phrase >=2
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Oct 4, 2017
1 parent ef918e1 commit 72d58e0
Showing 1 changed file with 38 additions and 27 deletions.
65 changes: 38 additions & 27 deletions website/search/gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,35 @@ def sort_key(self, gene, phrase):
return distance(self.get_feature(gene), phrase)


class SymbolGeneSearch(GeneSearch):
"""Look up a gene by HGNC symbol
Targets: Gene.name
Example:
search for "TP53" should return TP53 (among others)
"""

name = 'gene_symbol'
feature = 'name'


class GeneNameSearch(GeneSearch):
"""Look up a gene by full name, defined by HGNC
Targets: Gene.full_name
Example:
search for "tumour protein" should return TP53 (among others)
"""

name = 'gene_name'
feature = 'full_name'


class IsoformBasedSearch(GeneOrProteinSearch):
"""Looks up a gene, based on a feature of its isoforms.
The matched isoforms are recorded in GeneMatch object.
"""

@staticmethod
def create_query(limit, filters, entities=(Gene, Protein), add_joins=lambda query: query):
Expand Down Expand Up @@ -134,9 +162,10 @@ def create_query(limit, filters, entities=(Gene, Protein), add_joins=lambda quer


class RefseqGeneSearch(IsoformBasedSearch):
"""Look up a gene by isoforms RefSeq (Protein.refseq).
"""Look up a gene by isoforms RefSeq.
The matched isoforms are recorded in GeneMatch object.
Only numeric phrases and phrases starting with:
"NM_" or "nm_" will be evaluated.
Targets: Protein.refseq
Example:
Expand Down Expand Up @@ -188,39 +217,21 @@ def sort_key(isoform, phrase):
return distance(isoform.refseq, phrase)


class SymbolGeneSearch(GeneSearch):
"""Look up a gene by HGNC symbol
Targets: Gene.name
Example:
search for "TP53" should return TP53 (among others)
"""

name = 'gene_symbol'
feature = 'name'


class GeneNameSearch(GeneSearch):
"""Look up a gene by full name, defined by HGNC
Targets: Gene.full_name
Example:
search for "tumour protein" should return TP53 (among others)
"""

name = 'gene_name'
feature = 'full_name'


class UniprotSearch(IsoformBasedSearch):
"""
"""Look up a gene by isoforms Uniprot accession.
Only phrases longer than 2 characters will be evaluated.
Targets: Protein.external_references.uniprot_entries
"""

name = 'uniprot'

def search(self, phrase, sql_filters=None, limit=None):

if len(phrase) < 3:
return []

matches = []

filters = [UniprotEntry.accession.like(phrase + '%')]
Expand Down

0 comments on commit 72d58e0

Please sign in to comment.