def load_odict(fname): def ogroups_to_odict_list(ogroups): orthdict = dict([(p1,[p2 for p2 in og[1]]) for og in ogroups for p1 in og[0]]) return orthdict odict = ogroups_to_odict_list(orth.load_ogroups('','',fname=fname)) return odict
def load_paralogs(sp_base, sp_other, ogroup_max, other_ogroup_max): """ Get all pairwise base species paralogs from sharing orthogroups in the inParanoid orthology files between the base and other species. """ ogs = orth.load_ogroups(sp_base, sp_other) use_ogs = [] if ogroup_max: for og_base, og_other in ogs: if (len(og_base) <= ogroup_max and (other_ogroup_max is None or len(og_other) <= other_ogroup_max)): use_ogs.append(og_base) else: use_ogs = ut.i0(base_ogs) base_paralogs = pu.groups_to_pairs(use_ogs) return base_paralogs