def getGeneByStableId(self, StableId): """returns the gene matching StableId, or None if no record found""" query = self._get_gene_query(self.CoreDb, StableId=StableId) try: record = list(query.execute())[0] gene = Gene(self, self.CoreDb, data=record) except IndexError: gene = None return gene
def getGenesMatching(self, Symbol=None, Description=None, StableId=None, BioType=None, like=True): """Symbol: HGC gene symbol, case doesn't matter description: a functional description StableId: the ensebl identifier BioType: the biological encoding type""" # TODO additional arguments to satisfy: external_ref, go_terms if Symbol is not None: Symbol = Symbol.lower() # biotype -> gene # description -> gene # Symbols -> xref # StableId -> gene_stable_id # XREF table calls # for gene symbols, these need to be matched against the display_label # attribute of core.xref table # for description, these need to be matched against the description # field of the xref table # TODO catch conditions where user passes in both a symbol and a # biotype args = dict(Symbol=Symbol, Description=Description, StableId=StableId, BioType=BioType, like=like) query = self._get_gene_query(self.CoreDb, **args) records = query.execute() if records.rowcount == 0 and Symbol is not None: # see if the symbol has a synonym Symbol = self._get_symbol_from_synonym(self.CoreDb, Symbol) if Symbol is not None: args['Symbol'] = Symbol records = self._get_gene_query(self.CoreDb, **args).execute() else: records = [] for record in records: gene = Gene(self, self.CoreDb, data=record) yield gene