Exemplo n.º 1
0
def db2ppi(list_sep):
    """
    read dbfile and convert complexes to ppi for faster quering
    """
    ppi_db = nx.Graph()
    for members in list_sep:
        for pairs in st.fast_comb(members.split("#"), 2):
            ppi_db.add_edge(str.upper(pairs[0]), str.upper(pairs[1]))
    ppi_db.remove_edges_from(nx.selfloop_edges(ppi_db, keys=True))
    return ppi_db
Exemplo n.º 2
0
 def pairwise(self):
     """
     performs pairwise comparison
     """
     for pairs in st.fast_comb(np.array(self.members), 2):
         self.calc_corr(pairs)
         self.calc_diff(*pairs)
         self.calc_shift([x.get_acc() for x in pairs])
     # now need to average
     self.cor = np.mean(self.cor, axis=0)
     self.diff = np.mean(self.diff, axis=0)
     self.shifts = np.mean(self.shifts)
Exemplo n.º 3
0
def combine_all(G, gaf, t):
    """
    permute all of blocks of whatever
    """
    go_type = ["CC", "MF", "BP"]
    out = []
    for go in go_type:
        k = [scr(G, gaf, x[0], x[1], go) for x in list(st.fast_comb(t, 2))]
        out.append(st.mean(k))
    # add to out the mean of the three Ontologies
    # TODO check mean or sum
    out.append(sum(out))
    return out
Exemplo n.º 4
0
def overlap_net(ppi_network, mb, over=0.5):
    """
    calculates the overlap between a network and a list
    """
    match, nomatch = 0, 0
    mb = re.split(r"#", mb)
    if len(mb) < 2:
        return True
    for pairs in st.fast_comb(mb, 2):
        if ppi_network.has_edge(pairs[0], pairs[1]):
            match += 1
        else:
            nomatch += 1
    if match / (nomatch + match) >= over:
        return True
    else:
        return False