Retrieves all pathways for a given organism.
    :param organism: an organism as listed in organismsKEGG()
    :returns df: a Pandas dataframe with the columns 'KEGGid','pathIDs', and 'pathName'.
    :returns df_: a Pandas dataframe with a columns for 'KEGGid', and one column for each pathway with the corresponding gene ids below

def pathwaysKEGG(organism):
    """
    Retrieves all pathways for a given organism.
    :param organism: an organism as listed in organismsKEGG()
    :returns df: a Pandas dataframe with the columns 'KEGGid','pathIDs', and 'pathName'.
    :returns df_: a Pandas dataframe with a columns for 'KEGGid', and one column for each pathway with the corresponding gene ids below
    """

    print("KEGG API: http://rest.kegg.jp/list/pathway/"+organism)
    sys.stdout.flush()
    kegg_paths=urlopen("http://rest.kegg.jp/list/pathway/"+organism).read()
    kegg_paths=kegg_paths.split("\n")
    final=[]
    for k in kegg_paths:
        final.append(k.split("\t"))
    df=pd.DataFrame(final[0:len(final)-1])[[0,1]]
    df.columns=['pathID','pathName']

    print("KEGG API: http://rest.kegg.jp/link/"+organism+"/pathway/")
    sys.stdout.flush()
    kegg_paths_genes=urlopen("http://rest.kegg.jp/link/"+organism+"/pathway/").read()
    kegg_paths_genes=kegg_paths_genes.split("\n")
    kegg_paths_genes=[ s.split("\t") for s in kegg_paths_genes ]
    kegg_paths_genes=pd.DataFrame(kegg_paths_genes)
    kegg_paths_genes.columns=['pathID','KEGGid']
    
    df=pd.merge(kegg_paths_genes,df,on=["pathID"],how="outer")
    
    def CombineAnn(df):
        return pd.Series(dict(KEGGid = ', '.join([ s for s in list(set(df['KEGGid']))  if str(s) != "nan" ] ) , 
                    pathIDs = ', '.join([ s for s in list(set(df['pathID'])) if str(s) != "nan" ]),
                    pathName = ', '.join([ s for s in list(set(df['pathName'])) if str(s) != "nan" ] )  ) ) 
    
    df=df.groupby('KEGGid',as_index=True).apply(CombineAnn)
    df.reset_index(inplace=True, drop=True)
    
    df_=kegg_paths_genes[['KEGGid']].drop_duplicates()
    for c in list(set(kegg_paths_genes["pathID"].tolist())):
        tmp=kegg_paths_genes[kegg_paths_genes["pathID"]==c][["KEGGid"]].drop_duplicates().dropna()
        tmp.columns=[c]
        df_=pd.merge(df_,tmp,left_on=["KEGGid"],right_on=[c],how="outer")
    
    return df, df_