forked from saezlab/pypath
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhumap.py
90 lines (61 loc) · 1.9 KB
/
humap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of the `pypath` python module
#
# Copyright 2014-2023
# EMBL, EMBL-EBI, Uniklinik RWTH Aachen, Heidelberg University
#
# Authors: see the file `README.rst`
# Contact: Dénes Türei ([email protected])
#
# Distributed under the GPLv3 License.
# See accompanying file LICENSE.txt or copy at
# https://www.gnu.org/licenses/gpl-3.0.html
#
# Website: https://pypath.omnipathdb.org/
#
import itertools
import pypath.share.curl as curl
import pypath.resources.urls as urls
import pypath.utils.mapping as mapping
import pypath.internals.intera as intera
def humap_complexes():
url = urls.urls['humap']['humap_url']
c = curl.Curl(url, large = True)
complexes = {}
for l in c.result:
l = l.strip().split()
for uniprots in itertools.product(*(
mapping.map_name(entrez, 'entrez', 'uniprot')
for entrez in l
)):
cplex = intera.Complex(
components = uniprots,
sources = 'hu.MAP',
)
complexes[cplex.__str__()] = cplex
return complexes
def humap2_complexes(min_confidence = 0):
url = urls.urls['humap']['humap2_url']
c = curl.Curl(url, large = True)
complexes = {}
_ = next(c.result)
for l in c.result:
l = l.strip().split(',')
confidence = int(l[1])
if confidence < min_confidence:
continue
for uniprots in itertools.product(*(
mapping.map_name(uniprot, 'uniprot', 'uniprot')
for uniprot in l[2].split()
)):
if not uniprots:
continue
cplex = intera.Complex(
components = uniprots,
sources = 'hu.MAP2',
attrs = {'humap2_confidence': confidence},
)
complexes[cplex.__str__()] = cplex
return complexes