def ensembl_to_kegg(organism,kegg_db):
    """
    Looks up KEGG mappings of KEGG ids to ensembl ids

    :param organism: an organisms as listed in organismsKEGG()
    :param kegg_db: a matching KEGG db as reported in databasesKEGG

    :returns: a Pandas dataframe of with 'KEGGid' and 'ENSid'.

    """
    print("KEGG API: http://rest.genome.jp/link/"+kegg_db+"/"+organism)
    sys.stdout.flush()
    kegg_ens=urlopen("http://rest.genome.jp/link/"+kegg_db+"/"+organism).read()
    kegg_ens=kegg_ens.split("\n")
    final=[]
    for i in kegg_ens:
        final.append(i.split("\t"))
    df=pd.DataFrame(final[0:len(final)-1])[[0,1]]
    ens_id=pd.DataFrame(df[1].str.split(":").tolist())[1]
    df=pd.concat([df,ens_id],axis=1)
    df.columns=['KEGGid','ensDB','ENSid']
    df=df[['KEGGid','ENSid']]
    return df
def ensembl_to_kegg ( organism , kegg_db ) : print ( "KEGG API: http://rest.genome.jp/link/" + kegg_db + "/" + organism ) sys . stdout . flush ( ) kegg_ens = urlopen ( "http://rest.genome.jp/link/" + kegg_db + "/" + organism ) . read ( ) kegg_ens = kegg_ens . split ( "\n" ) final = [ ] for i in kegg_ens : final . append ( i . split ( "\t" ) ) df = pd . DataFrame ( final [ 0 : len ( final ) - 1 ] ) [ [ 0 , 1 ] ] ens_id = pd . DataFrame ( df [ 1 ] . str . split ( ":" ) . tolist ( ) ) [ 1 ] df = pd . concat ( [ df , ens_id ] , axis = 1 ) df . columns = [ 'KEGGid' , 'ensDB' , 'ENSid' ] df = df [ [ 'KEGGid' , 'ENSid' ] ] return df
Looks up KEGG mappings of KEGG ids to ensembl ids

    :param organism: an organisms as listed in organismsKEGG()
    :param kegg_db: a matching KEGG db as reported in databasesKEGG

    :returns: a Pandas dataframe of with 'KEGGid' and 'ENSid'.