Skip to content
Snippets Groups Projects
Commit 51cedf45 authored by UMEC Mathieu's avatar UMEC Mathieu
Browse files

Adding total and average overlap to the resemblance table

parent 6ddf521d
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ Sortie_pathways_de_chaque_metabolites="C:\\Users\\mumec\\Desktop\\Dossier_gitlab
### Function initialization
def colonne(file, n, sep=";"): # fill opening and recovery
def lecture_colonne(file, n, sep=";"): # fill opening and recovery
with open(file,"r") as f:
r=csv.reader(f, delimiter = sep)
lignes=list(r)
......@@ -71,7 +71,7 @@ def traitement_des_pathways (file,sep=";"):
for p in range (Nombre_de_pathways_totale+len(i_e)):# création d'une variables pour chaque pathways
if (p not in i_e):
transitoire=colonne(file, p, sep=";")
transitoire=lecture_colonne(file, p, sep=";")
Tout_les_pathways[indice_reel]=transitoire[1:len(transitoire)]
indice_reel+=1
......@@ -83,40 +83,33 @@ def traitement_des_pathways (file,sep=";"):
break
tableau_de_resemblance=np.zeros([Nombre_de_pathways_totale,Nombre_de_pathways_totale])
tableau_de_resemblance=np.zeros([Nombre_de_pathways_totale,Nombre_de_pathways_totale+2])
P1=[]
P2=[]
longeur_P1=0
longeur_P2=0
for l in range(Nombre_de_pathways_totale):
for c in range(Nombre_de_pathways_totale) :
if (l==c):
tableau_de_resemblance[l,c]=len(Tout_les_pathways[c])
for ligne in range(Nombre_de_pathways_totale):
somme_liste=0
for colonne in range(Nombre_de_pathways_totale) :
if (ligne==colonne):
tableau_de_resemblance[ligne,colonne]=len(Tout_les_pathways[colonne])
else :
commun=0
P1=Tout_les_pathways[l]
P2=Tout_les_pathways[c]
longeur_P1=len(Tout_les_pathways[l])
longeur_P2=len(Tout_les_pathways[c])
for m in range (min(longeur_P1, longeur_P2)):
if (longeur_P1< longeur_P2):
metabolite_recherche=P1[m]
if (metabolite_recherche in P2):
P1=Tout_les_pathways[ligne]
P2=Tout_les_pathways[colonne]
for metabolite_recherche in (P1):
if (metabolite_recherche in P2):
commun+=1
else :
metabolite_recherche=P2[m]
if (metabolite_recherche in P1):
commun+=1
tableau_de_resemblance[l,c]=commun
tableau_de_resemblance[ligne,colonne]=commun
somme_liste+=commun
tableau_de_resemblance[ligne,Nombre_de_pathways_totale]=somme_liste
tableau_de_resemblance[ligne,Nombre_de_pathways_totale+1]=somme_liste/(Nombre_de_pathways_totale-1)
tableau_approximatif=[]
for line in tableau_de_resemblance:
tableau_approximatif.append(' '.join(map(str, line)))
tableau_approximatif=np.array(tableau_approximatif)
tableau_approximatif
tableau_approximatif=np.array(tableau_approximatif, dtype=object)
print(tableau_approximatif)
ensemble_des_metabolites=[]
nombre_de_metabolites=[]
......@@ -156,6 +149,8 @@ def traitement_totale_couverture_pathways_et_métabolites(file,Fichier1,Fichier2
Les_metabolites_et_leurs_pathways = pd.DataFrame(data=Les_metabolites_et_leurs_pathways)
Noms_des_Pathways.append("recouvrement_totale")
Noms_des_Pathways.append("recouvrement_moyen")
resemblance_des_pathways=[Noms_des_Pathways]
for indice in range(len(tableau_de_resemblance)):
resemblance_des_pathways.append(tableau_de_resemblance[indice])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment