Skip to content

Commit

Permalink
Add remove_output option to and modify biomodels script
Browse files Browse the repository at this point in the history
  • Loading branch information
stellaprins committed Nov 12, 2024
1 parent 7f0a1da commit a8bf029
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
7 changes: 5 additions & 2 deletions BioModels/test_biomodels_compatibility_biosimulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,18 @@ def main():
if not sedml_file: continue # no further tests possible

test_folder = 'tests'
engine_list = list(utils.ENGINES.keys())
# engine_list = list(utils.ENGINES.keys())

utils.run_biosimulators_remotely_and_locally(engine_list,
os.path.basename(sedml_file),
os.path.basename(sbml_file),
os.path.join(test_folder,'d1_plots_remote'),
os.path.join(test_folder,'d1_plots_local'),
test_folder=test_folder)
test_folder=test_folder,
remove_output=remove_output)

if __name__ == "__main__":
cases = ["BIOMD0000000001","BIOMD0000000138"]
remove_output = False
engine_list = ['copasi']
main()
30 changes: 18 additions & 12 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,8 @@ def run_biosimulators_remotely(engine_keys,
sedml_file_name,
sbml_file_name,
d1_plots_remote_dir,
test_folder='tests'):
test_folder='tests',
remove_output_remote=True):

""" run with directory pointing towards the location of the sedml and sbml files"""

Expand Down Expand Up @@ -1220,18 +1221,19 @@ def run_biosimulators_remotely(engine_keys,
file_paths = find_files(remote_output_dir, '.pdf')
move_d1_files(file_paths, d1_plots_remote_dir)

# remove the remote results directory
if os.path.exists(remote_output_dir):
shutil.rmtree(remote_output_dir)
print('Removed ' + remote_output_dir + ' folder')
if remove_output_remote == True:# remove the remote results directory
if os.path.exists(remote_output_dir):
shutil.rmtree(remote_output_dir)
print('Removed ' + remote_output_dir + ' folder')

return results_remote

def run_biosimulators_locally(engine_keys,
sedml_file_name,
sbml_file_name,
d1_plots_local_dir,
test_folder='tests'):
test_folder='tests',
remove_output_local=True):

engines = {k: v for k, v in ENGINES.items() if k in engine_keys}
results_local = {}
Expand All @@ -1250,9 +1252,10 @@ def run_biosimulators_locally(engine_keys,
move_d1_files(file_paths, d1_plots_local_dir)

# if it exists remove the output folder
if os.path.exists(local_output_dir):
shutil.rmtree(local_output_dir)
print('Removed ' + local_output_dir + ' folder')
if remove_output_local == True:
if os.path.exists(local_output_dir):
shutil.rmtree(local_output_dir)
print('Removed ' + local_output_dir + ' folder')

return results_local

Expand Down Expand Up @@ -1316,19 +1319,22 @@ def run_biosimulators_remotely_and_locally(engine_keys,
sbml_file_name,
d1_plots_remote_dir,
d1_plots_local_dir,
test_folder='tests'):
test_folder='tests',
remove_output=True):

results_remote = run_biosimulators_remotely(engine_keys,
sedml_file_name=sedml_file_name,
sbml_file_name=sbml_file_name,
d1_plots_remote_dir=d1_plots_remote_dir,
test_folder=test_folder)
test_folder=test_folder,
remove_output_remote = remove_output)

results_local = run_biosimulators_locally(engine_keys,
sedml_file_name=sedml_file_name,
sbml_file_name=sbml_file_name,
d1_plots_local_dir=d1_plots_local_dir,
test_folder=test_folder)
test_folder=test_folder,
remove_output_local = remove_output)

results_table = create_combined_results_table(results_remote,
results_local,
Expand Down

0 comments on commit a8bf029

Please sign in to comment.