
if __name__ == '__main__':

    ppi_listprothum_List = {}
    pidHuman_idmap_file = '../DATA/HINTHUMAN/HomoSapiensbinaryhq.txt'
    with open(pidHuman_idmap_file) as f:
        with open("../Data/ppi/humanlistprotein.txt", 'w+') as fedrgId:
            for line in f:
                it = line.strip().split("\t")
                p1id = it[0]
                p2id = it[1]
                it.remove(it[0])
                if p1id not in ppi_listprothum_List:
                    ppi_listprothum_List[p1id] = set()
                    ppi_listprothum_List[p1id].add(str("9606"))
                    fedrgId.writelines("{}\n".format(str(p1id)))

                if p2id not in ppi_listprothum_List:
                    ppi_listprothum_List[p2id] = set()
                    ppi_listprothum_List[p1id].add(str("9606"))
                    fedrgId.writelines("{}\n".format(str(p2id)))




    ppi_specie2_id_DGLKE_List = {}
    pidHuman_idmap_file = '../results/HomoSapiensbinaryhq.txt'
    with open(pidHuman_idmap_file) as f:
        cluster1 = 0
        for line in f:
            it = line.strip().split(" ")
            cluster1 = cluster1 + 1
            p1id = it[0]
            p2id = it[1]
            it.remove(it[0])
            for elem in it:
                if int(cluster1) not in ppi_specie2_id_DGLKE_List:
                    ppi_specie2_id_DGLKE_List[int(cluster1)] = set()
                ppi_specie2_id_DGLKE_List[int(cluster1)].add(str(elem))

    ppi_specie1_id_DGLKE_List = {}
    pidHuman_idmap_file = '../results/SaccharomycesCerevisiaeS288Cbinaryhq.txt'
    with open(pidHuman_idmap_file) as f:
        cluster1 = 0
        for line in f:
            it = line.strip().split(" ")
            cluster1 = cluster1 + 1
            p1id = it[0]
            p2id = it[1]
            it.remove(it[0])
            for elem in it:
                if int(cluster1) not in ppi_specie1_id_DGLKE_List:
                    ppi_specie1_id_DGLKE_List[int(cluster1)] = set()
                ppi_specie1_id_DGLKE_List[int(cluster1)].add(str(elem))

    with open("../results/alignment_spec1_spec2_protein_ppi.txt", 'w+') as fedrgId:
        for i, row in enumerate(ppi_specie1_id_DGLKE_List):
            cluster_id1 = row
            p1idspec1 = ppi_specie1_id_DGLKE_List[cluster_id1]
            for p1 in p1idspec1:
                fedrgId.writelines("{}\t".format(str(p1)))
            p1idspec2 = ppi_specie2_id_DGLKE_List[cluster_id1]
            for p2 in p1idspec2:
                fedrgId.writelines("{}\t".format(str(p2)))
            fedrgId.writelines("\n")
    with open("../results/alignment_spec1_spec2_pairwise_protein_PPI.txt", 'w+') as fedrgId:
        for i, row in enumerate(ppi_specie1_id_DGLKE_List):
            cluster_id1 = row
            p1idspec1 = ppi_specie1_id_DGLKE_List[cluster_id1]
            for p1 in p1idspec1:
                p1idspec2 = ppi_specie2_id_DGLKE_List[cluster_id1]
                for p2 in p1idspec2:
                    fedrgId.writelines("{}\t".format(str(p1)))
                    fedrgId.writelines("{}\t".format(str(p2)))
                    fedrgId.writelines("\n")

    ##################################################################################
    ppi_bpo_target_gogo_List = {}
    ppi_cco_target_gogo_List = {}
    ppi_mfo_target_gogo_List = {}
    pid_gogo_idmap_file = '../GOGO-master/data/results_go_yeast.txt'
    with open(pid_gogo_idmap_file) as f:
        f.__next__()
        for line in f:
            it0 = line.strip().split("; ")
            itsub2 = it0[1]
            targetprotein_prot = itsub2.strip().split(" ")
            protid2 = targetprotein_prot[0]

            it = line.strip().split(" ")
            it2 = line.strip().split("BPO")
            p1id = it[0]
            score = it2[1]
            it3 = score.strip().split("CCO")
            scorebpo = it3[0]
            it4 = it3[1].strip().split("MFO")
            scorecco = it4[0]
            scoremfo = it4[1]
            CombinedKey = p1id + "-" + protid2
            allscore = scorebpo + " " + scorecco + " " + scoremfo
            if (scorebpo.strip() != 'NA'):
                if str(CombinedKey) not in ppi_bpo_target_gogo_List:
                    ppi_bpo_target_gogo_List[str(CombinedKey)] = set()
                ppi_bpo_target_gogo_List[str(CombinedKey)].add(float(scorebpo))
            if (scorecco.strip() != 'NA'):
                if str(CombinedKey) not in ppi_cco_target_gogo_List:
                    ppi_cco_target_gogo_List[str(CombinedKey)] = set()
                ppi_cco_target_gogo_List[str(CombinedKey)].add(float(scorecco))
            if (scoremfo.strip() != 'NA'):
                if str(CombinedKey) not in ppi_mfo_target_gogo_List:
                    ppi_mfo_target_gogo_List[str(CombinedKey)] = set()
                ppi_mfo_target_gogo_List[str(CombinedKey)].add(float(scoremfo))


    ppi_bpo_source_gogo_List = {}
    ppi_cco_source_gogo_List = {}
    ppi_mfo_source_gogo_List = {}
    pid_gogo_idmap_file = '../GOGO-master/data/results_go_human.txt'
    with open(pid_gogo_idmap_file) as f:
        f.__next__()
        for line in f:
            it0 = line.strip().split("; ")
            itsub2 = it0[1]
            targetprotein_prot=itsub2.strip().split(" ")
            protid2=targetprotein_prot[0]

            it = line.strip().split(" ")
            it2 = line.strip().split("BPO")
            p1id = it[0]
            score=it2[1]
            it3 = score.strip().split("CCO")
            scorebpo=it3[0]
            it4=it3[1].strip().split("MFO")
            scorecco =it4[0]
            scoremfo = it4[1]
            CombinedKey=p1id+"-"+protid2
            allscore=scorebpo + " " + scorecco + " " + scoremfo
            if (scorebpo.strip() != 'NA'):
                if str(CombinedKey) not in ppi_bpo_source_gogo_List:
                    ppi_bpo_source_gogo_List[str(CombinedKey)] = set()
                ppi_bpo_source_gogo_List[str(CombinedKey)].add(float(scorebpo))
            if (scorecco.strip() != 'NA'):
                if str(CombinedKey) not in ppi_cco_source_gogo_List:
                    ppi_cco_source_gogo_List[str(CombinedKey)] = set()
                ppi_cco_source_gogo_List[str(CombinedKey)].add(float(scorecco))
            if (scoremfo.strip() != 'NA'):
                if str(CombinedKey) not in ppi_mfo_source_gogo_List:
                    ppi_mfo_source_gogo_List[str(CombinedKey)] = set()
                ppi_mfo_source_gogo_List[str(CombinedKey)].add(float(scoremfo))
