Snippets

Dénes Türei list interactions by pathways (pypath)

Created by Dénes Türei
from functools import reduce

result = {}

for pw_source in ['signalink', 'kegg', 'signor']:
    
    attr = '%s_pathways' % pw_source
    result[pw_source] = {}
    
    pwnames = list(
        reduce(
            lambda pws1, pws2: pws1 | pws2,
            map(
                lambda e: e[attr],
                pa.graph.es
            ),
            set([])
        ))
    
    for pw in pwnames:
        result[pw_source][pw] = []
        for e in pa.graph.es:
            if pw in e[attr]:
                result[pw_source][pw].append((
                    pa.nodNam[e.source],
                    pa.nodNam[e.target],
                    e.index
                ))

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.