import pandas as pd 
import numpy as np 

def preprocess(text):
    return 

categories = ['common', 'age', 'tumor', 'status', 'stage', 'histological']

common_df = pd.read_csv("../Results/GO/adaptive/common/GO_Molecular_Function_2018_table.txt", header=0, index_col=None, sep='\t')
print(common_df)
common_df.sort_values("Adjusted P-value", ascending=True, inplace=True)
common_df['Term'], common_df['ID'] = common_df['Term'].str.split('GO:', 1).str

for category in categories:    
    curr_df = pd.read_csv("../Results/GO/adaptive/{}/GO_Molecular_Function_2018_table.txt".format(category), header=0, index_col=None, sep='\t')
    curr_df.sort_values("Adjusted P-value", ascending=True, inplace=True)
    curr_df['Term'], curr_df['ID'] = curr_df['Term'].str.split('GO:', 1).str
    common = np.intersect1d(common_df["Term"].values[:15], curr_df["Term"].values[:15]) 
    print(category)
    # print(common)
    common = np.intersect1d(common_df["ID"].values[:15], curr_df["ID"].values[:15]) 
    print(category)
    print(common)
    print(common.shape)