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
|
import networkx as nx
from collections import defaultdict
dd=defaultdict(set)
P=[]
#Fichier contentant tout les couples (point de dpépart, point d'arrivée) à tester
with open("3080_interactions_pour_736.txt","r") as f0:
for lignes0 in f0:
lignes0=lignes0.rstrip('\n').split(" ")
prot1=lignes0[0]
prot2=lignes0[1]
couple=prot1,prot2
P.append(list(couple))
#print(P)
#Fichier contenant toutes les interactions binaires composant mon graphe
with open("736(int_connues_avec_scores_sup_0).txt","r") as f1:
for lignes in f1:
if lignes.startswith('9606'):
lignes=lignes.rstrip('\n').split(" ")
proteine1=lignes[2]
proteine2=lignes[3]
dd[proteine1].add(proteine2)
#Pour chaque couple de mon premier fichier, j'applique le module des plus courtes chaines:
for couples in P:
prot1=couples[0]
prot2=couples[1]
Lchaines=([p for p in nx.all_shortest_paths(dd, source=prot1, target=prot2, weight=None)])
print("")
print("The first protein in the chain is", prot1)
print("The last protein in the chain is", prot2)
print("")
print("Minimal size chain(s):")
print("")
for chaines in Lchaines:
#Pour avoir des chaines de taille 11 maximum
if len(chaines) <= 0:
print("Pas de chaines")
if len(chaines) <= 11:
print(' '.join(chaines))
else :
print('ERROR - The minimum size of the chains exceeds the limit')
break
print("")
print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") |
Partager