Bonjour à tous
Voici un extrait de mon fichier sur lequel je travaille:
HS3ST1 GPC5 0 0 0 0 96 900 387 939
HS3ST1 GPC1 0 0 0 61 96 900 470 948 ---> EXP
HS3ST1 GPC4 0 0 0 0 96 900 462 947
SEMA3F PLXNA4 0 0 0 0 188 600 433 799
SEMA3F PLXNA3 0 0 0 62 188 600 900 965 ---> EXP
SEMA3F PLXNA1 0 0 0 111 188 600 904 968 ---> EXP
SEMA3F NRP1 0 0 0 0 478 800 839 981
SEMA3F PLXNA2 0 0 0 88 188 600 431 809 ---> EXP
CFTR PSMC2 0 0 0 62 59 900 50 905 ---> EXP
CFTR PSMD11 0 0 0 62 103 900 41 908 ---> EXP
CFTR DVL2 0 0 0 62 52 900 514 951 ---> EXP
CFTR CBL 0 0 0 0 379 900 207 946
CFTR PSMD4 0 0 0 0 51 900 87 905
CFTR EGFR 0 0 0 0 51 900 383 936
Voici mon script:
Prot1 = différents noms de protéines, par exemple:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 from collections import defaultdict Dprot1 = defaultdict(set) Dprot2 = defaultdict(set) Dinter = defaultdict(dict) couple = [] with open("C:/Users/lveillat/Desktop/Données stage/Données/resultats_matrice_avec_scores_sans_localisation.txt","r") as f1: for ligne in f1: lp = ligne.rstrip('\n').split(" ") if lp[-1] == "EXP": #Si il y a présence d'une coexpression prot1 = lp[0] #prot1=la première proteine prot2 = lp[1] #prot2=la seconde proteine if prot1 not in Dprot1: #Si la prot n'est pas dans mon dico on la rajout (pas de doublons comme ça) Dprot1[prot1].add(prot1) if prot2 not in Dprot2: #Idem pour prot 2 Dprot2[prot2].add(prot2) Dinter[prot1][prot2]=1 #Si interaction entre 2 prot on marque 1 #print (Dinter) f1.close() for i in Dprot1: #On parcours tout les elements de Dprot2 for j in Dprot2: #On parcours tout les elements de Dprot2 if Dinter[i][j]: #Si i=prot1 et j=prot2 print ("1") else: print("0")
KDGHZ
DFGF
SDFET
SDGFT
SDDZ
BJJU
DAA
INS
ect ...
Prot2 = identique
KQV
SHYZ
CKZ
YSC5E
2FQT
SGY2
ect…
Dinter [prot1] [prot2] = 1 : A comme première clé une protéine en seconde clé toutes les protéines avec lesquelles elle interagit et en valeur 1. Extrait:
F5': {'SPTBN2': 1, 'ARFGAP1': 1, 'ANK2': 1, 'COPZ2': 1, 'KIF15': 1, 'KIF2B': 1, 'KIF25': 1, 'KDELR2': 1, 'RAB1B': 1, 'TMED10': 1, 'KIF3B': 1, 'GBF1': 1, 'CAPZB': 1, 'KIF3C': 1, 'COPA': 1, 'YKT6': 1, 'COPB1': 1, 'KIF20A': 1, 'RAB1A': 1, 'ACTR1A': 1, 'CAPZA2': 1, 'CAPZA1': 1, 'SPTBN5': 1, 'USO1': 1, 'CENPE': 1, 'KIFC1': 1, 'KIF9': 1, 'ARF1': 1, 'KIF6': 1, 'KIF18B': 1, 'KIF26A': 1, 'KIF5A': 1, 'KIF20B': 1, 'ANK1': 1, 'KIF18A': 1, 'KIF19': 1, 'KIF23': 1, 'BET1': 1, 'KDELR1': 1, 'ANK3': 1, 'SPTBN1': 1, 'KIF5B': 1, 'COPB2': 1, 'KIF11': 1, 'KIF2C': 1, 'ARCN1': 1, 'DYNLL2': 1, 'COPG2': 1, 'KIFC2': 1, 'COPG1': 1, 'KIF26B': 1, 'DYNLL1': 1, 'ARFGAP2': 1, 'KIF2A': 1, 'KIF22': 1, 'KIF12': 1, 'SEC22B': 1, 'ARFGAP3': 1, 'KDELR3': 1, 'KIF3A': 1, 'COPZ1': 1, 'COPE': 1, 'DCTN1': 1}, 'FKBP4': {'HSF1': 1, 'PPP5C': 1, 'ACTR1A': 1, 'HSPA1A': 1, 'PPID': 1, 'HSPA2': 1, 'PTGES3': 1, 'HSP90AA1': 1, 'HSP90AB1': 1, 'STIP1': 1, 'HSPA8': 1, 'EP300': 1, 'FOXA1': 1, 'HSPA1L': 1, 'ESR2': 1, 'MAPK3': 1, 'HSPA1B': 1, 'DCTN1': 1}
Je suis coincé à la fin de mon script (a partir de "for i in Dprot1") , il faudrait que mon algorithme teste toutes les paires de protéines possibles dans mon fichier et qu'il me printe 1 s'il y a une interaction entre les deux protéines ou 0 s'il n'y en a pas.
Pour ce faire, dans les dernières lignes de mon algorithme, je dois comparer la paire i et j, correspondant à toutes les paires de protéines possibles (une paire n'est pas forcément une interaction) à mon dictionnaire Dinter qui contient toutes les interactions possibles. Ainsi si la paire i,j correspond a une paire de protéine dans mon dictionnaire alors il me printe 1 si non, 0.
Malheureusement cela ne fonctionne pas avec mon algorithme, pouvez-vous m'aider?
Je vous remercie
Partager