From f9a29877ef652cb1d39650c3354028737c5fae7c Mon Sep 17 00:00:00 2001 From: FAGES Timothee <timothee.fages@univ-lorraine.fr> Date: Fri, 3 May 2024 17:22:58 +0000 Subject: [PATCH] Upload New File --- TIRAMISU/Main_exe_1.py | 75 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 TIRAMISU/Main_exe_1.py diff --git a/TIRAMISU/Main_exe_1.py b/TIRAMISU/Main_exe_1.py new file mode 100644 index 0000000..59c5982 --- /dev/null +++ b/TIRAMISU/Main_exe_1.py @@ -0,0 +1,75 @@ +import time +import datetime +import pickle +import sys +import os +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) +from TIRAMISU import read_model_new as rm +from TIRAMISU import make_translation as mt +from TIRAMISU import add_and_write_mechanism as awm +with open(sys.argv[1], 'r') as file_input : + file = file_input.readlines() +# with open("0.txt", 'r') as file_input : +# file = file_input.readlines() +file=[x for x in file if x.strip()[0] != '!'] +core_path=file[0].strip() +translate_path=file[1].strip() +name_core=os.path.basename(core_path) +name_translate=os.path.basename(translate_path) +output=file[2].strip() +n=10000 +n_find=False +do_translation=True +translation_find=False +for line in file : + if "n=" in line[:2].strip() : + n_find=True + n=int(line.strip()[2:]) + if "translation=" in line.strip()[:12] : + translation_find=True + tmp_bool=(line.strip()[12:]).casefold() + if 'true' in tmp_bool : + do_translation=True + elif 'false'in tmp_bool : + do_translation=False + else : + raise Exception('Error: translation keyword not True nor False.') + +if n_find is False : + print('No maximum number of permutation specified (n=). Default is n=10000.') +if translation_find is False : + print('No boolean for translation (translation=True or False). Default is translation=True.') +print(f'\ntranslation={do_translation}') + + +path_mech_core=f'{core_path}.mech' +path_therm_core=f'{core_path}.therm' +path_trans_core=f'{core_path}.trans' + +path_mech_to_translate=f'{translate_path}.mech' +path_therm_to_translate=f'{translate_path}.therm' +path_trans_to_translate=f'{translate_path}.trans' + +time_start = time.time() + +model_to_translate=rm.Model(path_mech_to_translate, path_therm_to_translate, output, path_trans_to_translate,verbose=False) +model_core=rm.Model(path_mech_core, path_therm_core, output, path_trans_core, verbose=False) + +time_end = time.time() + +print(f'\nTotal time for model compilation = {time_end-time_start} seconds or {datetime.timedelta(seconds=(time_end-time_start))} ') +print( f'\nmodel_to_translate Species = {len(model_to_translate.reactions[1])} Reactions = {len(model_to_translate.reactions[2])}') +print( f'\nmodel_core Species = {len(model_core.reactions[1])} Reactions = {len(model_core.reactions[2])}') + +with open(f'{output}{name_translate}.pick', 'wb') as m1 : + pickle.dump( model_to_translate, m1) +with open(f'{output}{name_core}.pick', 'wb') as m2 : + pickle.dump(model_core, m2) + +if do_translation is True : + time_start = time.time() + stock=mt.models_translation(model_to_translate, model_core, output, 350, n) + time_end=time.time() + print(f'\nTotal time = {time_end-time_start} seconds or {datetime.timedelta(seconds=(time_end-time_start))} ') + +print('\n\nOpen and complete translation in "tmp_species_traduction.tmp". Then change name to "tmp_species_traduction.inp".\nEND OF PART 1') \ No newline at end of file -- GitLab