def convert_symbol_to_entrezid(self, symbol):
        """Convert Symbol to Entrez Gene Id"""
        entrezdict = {}
        server = "http://rest.genenames.org/fetch/symbol/{0}".format(symbol)
        r = requests.get(server, headers={"Content-Type": "application/json"})
        if not r.ok:
            r.raise_for_status()
            sys.exit()
        response = r.text
        info = xmltodict.parse(response)
        for data in info['response']['result']['doc']['str']:
            if data['@name'] == 'entrez_id':
                entrezdict[data['@name']] = data['#text']
            if data['@name'] == 'symbol':
                entrezdict[data['@name']] = data['#text']
        return entrezdict
def convert_symbol_to_entrezid ( self , symbol ) : entrezdict = { } server = "http://rest.genenames.org/fetch/symbol/{0}" . format ( symbol ) r = requests . get ( server , headers = { "Content-Type" : "application/json" } ) if not r . ok : r . raise_for_status ( ) sys . exit ( ) response = r . text info = xmltodict . parse ( response ) for data in info [ 'response' ] [ 'result' ] [ 'doc' ] [ 'str' ] : if data [ '@name' ] == 'entrez_id' : entrezdict [ data [ '@name' ] ] = data [ '#text' ] if data [ '@name' ] == 'symbol' : entrezdict [ data [ '@name' ] ] = data [ '#text' ] return entrezdict
Convert Symbol to Entrez Gene Id