def test_hgnc(): h = HGNC() h.get_info() h.fetch('symbol', 'ZNF3') h.fetch('alias_name', 'A-kinase anchor protein, 350kDa') h.search('BRAF') h.search('symbol', 'ZNF*') h.search('symbol', 'ZNF?') h.search('symbol', 'ZNF*+AND+status:Approved') h.search('symbol', 'ZNF3+OR+ZNF12') h.search('symbol', 'ZNF*+NOT+status:Approved')
def test_hgnc(): h = HGNC() h.get_info() h.fetch("symbol", "ZNF3") h.fetch("alias_name", "A-kinase anchor protein, 350kDa") h.search("BRAF") h.search("symbol", "ZNF*") h.search("symbol", "ZNF?") h.search("symbol", "ZNF*+AND+status:Approved") h.search("symbol", "ZNF3+OR+ZNF12") h.search("symbol", "ZNF*+NOT+status:Approved")
def kegg_to_hugo(genes, species='hsa'): """ Converts all KEGG names to HGNC Parameters ---------- genes : list species : str Returns ------- dict """ prefix = species + ':' hugo = HGNC(verbose=True) hugo_dict = {} not_found = set() for i in genes: tmp_name = i.lstrip(prefix) mapping = hugo.search(tmp_name) if 'response' in mapping: response = mapping['response'] if 'numFound' in response: if response['numFound'] == 0: not_found.add(i) continue elif response['numFound'] == 1: docs = response['docs'][0] hugo_dict[i] = docs['symbol'] continue else: if 'symbol' in response['docs'][0]: hugo_dict[i] = response['docs'][0]['symbol'] else: not_found.add(i) if not_found != 0: print("{} not found after HGNC mapping".format(len(not_found))) print("{} ".format(not_found)) return hugo_dict, not_found
def kegg_to_hugo(genes, species='hsa'): """ Converts all KEGG names to HGNC Parameters ---------- genes : list species : str Returns ------- dict """ prefix = species + ':' hugo = HGNC(verbose=True) hugo_dict = {} not_found = set() for i in genes: tmp_name = i.lstrip(prefix) mapping = hugo.search(tmp_name) if 'response' in mapping: response = mapping['response'] if 'numFound' in response: if response['numFound'] == 0: not_found.add(i) continue elif response['numFound'] == 1: docs = response['docs'][0] hugo_dict[i] = docs['symbol'] continue else: if 'symbol' in response['docs'][0]: hugo_dict[i] = response['docs'][0]['symbol'] else: not_found.add(i) if not_found != 0: print("{} not found after HGNC mapping".format(len(not_found))) print("{} ".format(not_found)) return hugo_dict, not_found