Skip to content
Snippets Groups Projects
Commit f9a29877 authored by FAGES Timothee's avatar FAGES Timothee
Browse files

Upload New File

parent 32e9e7bf
No related branches found
No related tags found
No related merge requests found
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
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