From 01af3a10a5731c6b131703fa30298f29ab3de10a Mon Sep 17 00:00:00 2001
From: local_comparaison <mathieu.umec@inrae.fr>
Date: Mon, 7 Aug 2023 14:19:53 +0200
Subject: [PATCH] Just one out_file with 3 sheet

---
 tool_of_mapping_results_treatments.py | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/tool_of_mapping_results_treatments.py b/tool_of_mapping_results_treatments.py
index f065923..6299bc5 100644
--- a/tool_of_mapping_results_treatments.py
+++ b/tool_of_mapping_results_treatments.py
@@ -20,9 +20,8 @@ import csv
 Pathways_a_enlever=['Metabolic pathways','Biosynthesis of secondary metabolites','Microbial metabolism in diverse environments','Carbon metabolism','2-Oxocarboxylic acid metabolism','Fatty acid metabolism','Biosynthesis of amino acids','Biosynthesis of nucleotide sugars','Biosynthesis of cofactors','Degradation of aromatic compounds','Carbohydrate metabolism','Energy metabolism','Lipid metabolism','Nucleotide metabolism','Amino acid metabolism','Metabolism of other amino acids','Glycan biosynthesis and metabolism','Metabolism of cofactors and vitamins','Metabolism of terpenoids and polyketides','Biosynthesis of other secondary metabolites','Xenobiotics biodegradation and metabolism','Chemical structure transformation maps','Genetic Information Processing','Transcription','Translation','Folding, sorting and degradation','Replication and repair','Information processing in viruses','Environmental Information Processing','Membrane transport','Signal transduction','Signaling molecules and interaction','Cellular Processes','Transport and catabolism','Cell growth and death','Cellular community - eukaryotes','Cellular community - prokaryotes','Cell motility','Immune system','Organismal Systems','Endocrine system','Circulatory system','Digestive system','Excretory system','Nervous system','Sensory system','Development and regeneration','Aging','Environmental adaptation','Human Diseases','Cancer: overview''Cancer: specific types','Infectious disease: viral','Infectious disease: bacterial','Infectious disease: parasitic','Immune disease','Neurodegenerative disease','Substance dependence','Cardiovascular disease','Endocrine and metabolic disease','Drug resistance: antimicrobial','Drug resistance: antineoplastic','Drug Development','Chronology: Antiinfectives','Chronology: Antineoplastics','Chronology: Nervous system agents','Chronology: Other drugs','Target-based classification: G protein-coupled receptors','Target-based classification: Nuclear receptors','Target-based classification: Ion channels','Target-based classification: Transporters','Target-based classification: Enzymes','Structure-based classification','Skeleton-based classification']
 
 Fichier_a_traiter="C:\\Users\\mumec\\Desktop\\Dossier_gitlab_local\\MetExplore_R22_L100_Pathways_avec_metabolites_pour_programme.csv"
-Sortie_Resemblance_des_pathways="C:\\Users\\mumec\\Desktop\\Dossier_gitlab_local\\table_de_resemblance_R22_L100.xlsx"
-Sortie_fréquence_des_metabolites="C:\\Users\\mumec\\Desktop\\Dossier_gitlab_local\\frequence_des_metabolites_R22_L100.xlsx"
-Sortie_pathways_de_chaque_metabolites="C:\\Users\\mumec\\Desktop\\Dossier_gitlab_local\\Metabolites_et_leurs_pathways_R22_L100.xlsx"
+Nom_fichier_de_Sortie="C:\\Users\\mumec\\Desktop\\Dossier_gitlab_local\\table_de_resemblance_R22_L100.xlsx"
+
 
 ### Function initialization
 
@@ -166,7 +165,7 @@ def traitement_des_pathways (file,sep=";"):
     return(Noms_des_Pathways,tableau_approximatif,Frequences_des_metabolites , Pathways_de_chaque_metabolites)
 
 
-def traitement_totale_couverture_pathways_et_métabolites(file,Fichier1,Fichier2,Fichier3):
+def traitement_totale_couverture_pathways_et_métabolites(file,Fichier_de_Sortie):
     Noms_des_Pathways,tableau_de_resemblance,Frequences_des_metabolites , Les_metabolites_et_leurs_pathways = traitement_des_pathways (file,sep=";")    
     
     Les_metabolites_et_leurs_pathways = pd.DataFrame(data=Les_metabolites_et_leurs_pathways)
@@ -182,19 +181,13 @@ def traitement_totale_couverture_pathways_et_métabolites(file,Fichier1,Fichier2
     
     Frequences_des_metabolites = pd.DataFrame(data=Frequences_des_metabolites)
  
-    excel_file1 = pd.ExcelWriter(Fichier1)
-    resemblance_des_pathways.to_excel(excel_file1)
-    excel_file1.close()
-
-    excel_file2 = pd.ExcelWriter(Fichier2)
-    Frequences_des_metabolites.to_excel(excel_file2)
-    excel_file2.close()
-
-    excel_file3 = pd.ExcelWriter(Fichier3)
-    Les_metabolites_et_leurs_pathways.to_excel(excel_file3)
-    excel_file3.close()
+    excel_file = pd.ExcelWriter(Fichier_de_Sortie)
+    resemblance_des_pathways.to_excel(excel_file, sheet_name="tables de ressemblance")
+    Frequences_des_metabolites.to_excel(excel_file,sheet_name="Fréquence des métabolites")
+    Les_metabolites_et_leurs_pathways.to_excel(excel_file,sheet_name='metabolites et leurs P')
+    excel_file.close()
 
 ###Ligne de commande pour obtenir les résultats : nécessite 1 fichier de résultat et 3 noms des fichiers de sorties
 
-traitement_totale_couverture_pathways_et_métabolites(Fichier_a_traiter,Sortie_Resemblance_des_pathways,Sortie_fréquence_des_metabolites,Sortie_pathways_de_chaque_metabolites)
+traitement_totale_couverture_pathways_et_métabolites(Fichier_a_traiter,Nom_fichier_de_Sortie)
 
-- 
GitLab