-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.py
More file actions
48 lines (36 loc) · 1011 Bytes
/
script.py
File metadata and controls
48 lines (36 loc) · 1011 Bytes
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
#!/usr/bin/python2.6
# -*-coding:Latin-1 -*
from numpy import *
f = open('rattus.txt', 'r')
a = loadtxt(f, skiprows = 1, usecols = (0,1,2), dtype = int)
# List of unique proteins
b = concatenate((a[:,1],a[:,2]),axis=0)
b = unique(b)
b.sort()
savetxt('prot_list', b, delimiter=' ', fmt='%i')
# Number of proteins
n = len(b)
# Number of interactions
m = len(a)
# Adjacence matrix
c = zeros((n, n), dtype = int)
for i in range(0, n):
for j in range(0, m):
if(b[i] == a[j,1]):
c[(b.tolist()).index(a[j,2]),i] +=1
if(b[i] == a[j,2]):
c[(b.tolist()).index(a[j,1]),i] +=1
savetxt('adj_matrix', c, delimiter=' ', fmt='%i')
cd = [0.0] * n
# Protein with the biggest cd
# First value is the maximum, and the second is the index
maxcd = [0,-1]
for i in range(0, n):
cd[i] += sum(c[:,i])
cd[i] /= n-1
if(cd[i] > maxcd[0]):
maxcd[1] = i
maxcd[0] = cd[i]
print("La protéine avec le plus grand degré est la protéine : ")
print(b[maxcd[1]])
savetxt('cd_matrix', cd, delimiter=' ', fmt='%.5f')