Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
25412bf
Draft biomodels tables
stellaprins Nov 13, 2024
65000c0
improve file compatibility check
stellaprins Nov 13, 2024
c234a50
improve handling of engine_list input and make it possible to modify …
stellaprins Nov 14, 2024
111577e
WiP for modifying SED-ML file outputTimes
stellaprins Nov 14, 2024
4779933
update BIOMD0000000001 SED-ML and plot (x log scale)
stellaprins Nov 14, 2024
e66eed2
update BIOMD0000000001 jsons and add BIOMD0000000138 table and plots …
stellaprins Nov 14, 2024
a47c9a1
update plots and SED-ML files in attempt to replicate curated figures
stellaprins Nov 14, 2024
8c4586e
Merge branch 'development' into feat-57-biomodels
stellaprins Nov 14, 2024
047fba1
remove autogen_curve_for_task1_vk from list of curves and plots
stellaprins Nov 17, 2024
b4c8cc5
increase dt in SED-ML of BIOMD0000000001
stellaprins Nov 19, 2024
be8c55e
remove unnecessary comments
stellaprins Nov 19, 2024
20c9186
increase max_wait_time to 600 seconds and update results tables and …
stellaprins Nov 19, 2024
6bd4c70
Merge branch 'development' into feat-57-biomodels
stellaprins Nov 19, 2024
77d6de4
remove spaces from omex filenames before submitting to docker
stellaprins Nov 20, 2024
9157782
add BIOMD0000001077
stellaprins Nov 20, 2024
edcd9e1
add BIOMD0000000724
stellaprins Nov 21, 2024
5476363
add BIOMD0000000724 SED-ML and SBML files
stellaprins Nov 21, 2024
e4a1ea7
Merge branch 'development' into feat-87-2-test-more-biomodels
stellaprins Nov 26, 2024
6be00e9
Merge branch 'development' into feat-87-2-test-more-biomodels
stellaprins Nov 27, 2024
bea9bfc
only remove omex_file if it exists in __init__.py
stellaprins Nov 27, 2024
0d3ed06
remove_spaces_from_filename returns filepath
stellaprins Nov 27, 2024
c6c46f8
add ValueError to remove_spaces_from_filename if dir contains spaces.…
stellaprins Dec 2, 2024
7210ece
fix temp SED-ML file handling bug in add_xmlns_sbml_attribute and ad…
stellaprins Dec 2, 2024
4db251f
tweak XFAIL message and update plots and tables
stellaprins Dec 2, 2024
f54a784
Merge branch 'development' into feat-87-2-test-more-biomodels
stellaprins Dec 2, 2024
6e62f56
update test_suite tables
stellaprins Dec 2, 2024
7be5c56
Merge branch 'feat-87-2-test-more-biomodels' of https://github.com/Op…
stellaprins Dec 2, 2024
9eb9bae
update SBML table
stellaprins Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

150 changes: 75 additions & 75 deletions BioModels/BIOMD0000000001/tests/results_local.json

Large diffs are not rendered by default.

216 changes: 108 additions & 108 deletions BioModels/BIOMD0000000001/tests/results_remote.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,519 changes: 222 additions & 1,297 deletions BioModels/BIOMD0000000138/tests/results_local.json

Large diffs are not rendered by default.

1,398 changes: 172 additions & 1,226 deletions BioModels/BIOMD0000000138/tests/results_remote.json

Large diffs are not rendered by default.

1,156 changes: 1,156 additions & 0 deletions BioModels/BIOMD0000000724/Theinmozhi_2018.sedml

Large diffs are not rendered by default.

4,400 changes: 4,400 additions & 0 deletions BioModels/BIOMD0000000724/Theinmozhi_2018.xml

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

3,265 changes: 3,265 additions & 0 deletions BioModels/BIOMD0000000724/tests/results_local.json

Large diffs are not rendered by default.

3,984 changes: 3,984 additions & 0 deletions BioModels/BIOMD0000000724/tests/results_remote.json

Large diffs are not rendered by default.

702 changes: 702 additions & 0 deletions BioModels/BIOMD0000001077/Adlung2021 _model_jakstat_pa.sedml

Large diffs are not rendered by default.

2,574 changes: 2,574 additions & 0 deletions BioModels/BIOMD0000001077/Adlung2021 _model_jakstat_pa.xml

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

2,015 changes: 2,015 additions & 0 deletions BioModels/BIOMD0000001077/tests/results_local.json

Large diffs are not rendered by default.

2,482 changes: 2,482 additions & 0 deletions BioModels/BIOMD0000001077/tests/results_remote.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions BioModels/test_biomodels_compatibility_biosimulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,8 @@ def main():

if __name__ == "__main__":
use_original_files = False
biomodel_id_list = ["BIOMD0000000001","BIOMD0000000138"]
main()
biomodel_id_list = ["BIOMD0000000001",
"BIOMD0000000138",
"BIOMD0000000724",
"BIOMD0000001077"]
main()
46 changes: 23 additions & 23 deletions SBML/tests/results_compatibility_biosimulators.md

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions test_suite/test_00001/tests/results_compatibility_biosimulators.md

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions test_suite/test_01186/tests/results_compatibility_biosimulators.md

Large diffs are not rendered by default.

115 changes: 78 additions & 37 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,39 @@ def get_entry_format(file_path, file_type):

return file_entry_format

def temp_sedml_file_if_not_empty(sedml_filepath, temp_sedml_filepath):
"""
If the temp_sedml_filepath is not empty, return its content, otherwise return the original content of the sedml file
"""
sedstr = ""

def add_xmlns_sbml_attribute(sedml_filepath, sbml_filepath, output_filepath=None):
if temp_sedml_filepath:
if os.path.exists(temp_sedml_filepath):
with open(temp_sedml_filepath, 'r') as file:
sedstr = file.read()

if sedstr == "":
with open(sedml_filepath, 'r') as file:
sedstr = file.read()

return sedstr

def add_xmlns_sbml_attribute(sedml_filepath, sbml_filepath, temp_sedml_filepath=None):
'''
add an xmlns:sbml attribute to the sedml file that matches the sbml file
raise an error if the attribute is already present
output fixed file to output_filepath which defaults to sedml_filepath

If no temp_sedml_filepath is provided, the original sedml file is overwritten.
'''

# read the sedml file as a string
with open(sedml_filepath, 'r') as file:
sedstr = file.read()
sed_str = temp_sedml_file_if_not_empty(sedml_filepath, temp_sedml_filepath)

m = re.search(r'<sedML[^>]*>', sedstr)
m = re.search(r'<sedML[^>]*>', sed_str)

if m == None:
raise ValueError(f'Invalid SedML file: main <sedML> tag not found in {sedml_filepath}')

# read the sbml file as a string to add the xmlns attribute if it is missing
if "xmlns:sbml" in m.group():
raise ValueError(f'xmlns:sbml attribute already present in file {sedml_filepath}')

Expand All @@ -254,13 +269,13 @@ def add_xmlns_sbml_attribute(sedml_filepath, sbml_filepath, output_filepath=None
sbml_xmlns = re.search(r'xmlns="([^"]*)"', sbml_str).group(1)
missing_sbml_attribute = 'xmlns:sbml="' + sbml_xmlns + '"'

sedstr = re.sub(r'<sedML ', r'<sedML ' + missing_sbml_attribute + ' ', sedstr)
sed_str = re.sub(r'<sedML ', r'<sedML ' + missing_sbml_attribute + ' ', sed_str)

if output_filepath == None:
output_filepath = sedml_filepath
if temp_sedml_filepath == None:
temp_sedml_filepath = sedml_filepath

with open(output_filepath,"w") as fout:
fout.write(sedstr)
with open(temp_sedml_filepath,"w") as fout:
fout.write(sed_str)

def add_xmlns_fbc_attribute(sedml_filepath, sbml_filepath, temp_sedml_filepath=None):
'''
Expand All @@ -270,16 +285,7 @@ def add_xmlns_fbc_attribute(sedml_filepath, sbml_filepath, temp_sedml_filepath=N
this instead of the original SED-ML file is used.
'''

sedstr = ""

if temp_sedml_filepath:
if os.path.exists(temp_sedml_filepath):
with open(temp_sedml_filepath, 'r') as file:
sedstr = file.read()

if sedstr == "":
with open(sedml_filepath, 'r') as file:
sedstr = file.read()
sedstr = temp_sedml_file_if_not_empty(sedml_filepath, temp_sedml_filepath)

m = re.search(r'<sedML[^>]*>', sedstr)

Expand All @@ -293,13 +299,11 @@ def add_xmlns_fbc_attribute(sedml_filepath, sbml_filepath, temp_sedml_filepath=N
fbc_xmlns = re.search(r'xmlns:fbc="([^"]*)"', sbml_str).group(1)
missing_fbc_attribute = 'xmlns:fbc="' + fbc_xmlns + '"'
sedstr = sedstr[:location] + ' ' + missing_fbc_attribute + sedstr[location:]


if temp_sedml_filepath == None:
temp_sedml_filepath = sedml_filepath

with open(temp_sedml_filepath,"w") as fout:

fout.write(sedstr)


Expand Down Expand Up @@ -347,6 +351,24 @@ def get_temp_file():
'''
return f"tmp{random.randrange(1000000)}"

def remove_spaces_from_filename(file_path):
'''
create another file with the same content but with filename spaces replaced by underscores
'''
dir_name = os.path.dirname(file_path)
if ' ' in dir_name:
raise ValueError(f'File directory path should not contain spaces: {dir_name}')
old_filename = os.path.basename(file_path)
if ' ' not in old_filename:
return file_path
if ' ' in old_filename:
new_filename = old_filename.replace(' ', '_')
new_file_path = os.path.join(dir_name, new_filename)
shutil.copy(file_path, new_file_path)
return new_file_path



def create_omex(sedml_filepath, sbml_filepath, omex_filepath=None, silent_overwrite=True, add_missing_xmlns=True):
'''
wrap a sedml and an sbml file in a combine archive omex file
Expand All @@ -367,13 +389,17 @@ def create_omex(sedml_filepath, sbml_filepath, omex_filepath=None, silent_overwr
os.remove(omex_filepath)

tmp_sedml_filepath = get_temp_file()

if add_missing_xmlns:
if xmlns_sbml_attribute_missing(sedml_filepath):
xmlns_sbml_missing = xmlns_sbml_attribute_missing(sedml_filepath)
xmlns_fbc_missing = xmlns_fbc_attribute_missing(sbml_filepath,sedml_filepath)
if xmlns_sbml_missing:
add_xmlns_sbml_attribute(sedml_filepath, sbml_filepath, tmp_sedml_filepath)
if xmlns_fbc_attribute_missing(sbml_filepath,sedml_filepath):
if xmlns_fbc_missing:
add_xmlns_fbc_attribute(sedml_filepath, sbml_filepath, tmp_sedml_filepath)

sedml_filepath = tmp_sedml_filepath
if xmlns_sbml_missing or xmlns_fbc_missing:
sedml_filepath = tmp_sedml_filepath

sbml_file_entry_format = get_entry_format(sbml_filepath, 'SBML')
sedml_file_entry_format = get_entry_format(sedml_filepath, 'SEDML')

Expand All @@ -397,7 +423,7 @@ def create_omex(sedml_filepath, sbml_filepath, omex_filepath=None, silent_overwr
)
om.to_omex(Path(omex_filepath))

if tmp_sedml_filepath:
if os.path.exists(tmp_sedml_filepath):
os.remove(tmp_sedml_filepath)

return omex_filepath
Expand Down Expand Up @@ -529,24 +555,29 @@ def check_file_compatibility_test(engine, model_filepath, experiment_filepath):
if file_extensions in engine_filetypes_tuple_list:
return 'pass', (f"The file extensions {file_extensions} suggest the input file types are {filetypes_strings}.<br><br> {unique_compatible_filetpyes_strings} are compatible with {engine_name}.")


if 'xml' in file_extensions:
model_sbml = 'sbml' in model_filepath
model_sedml = 'sedml' in model_filepath
experiment_sbml = 'sbml' in experiment_filepath
experiment_sedml = 'sedml' in experiment_filepath

if model_sbml and experiment_sbml and experiment_sedml and not model_sedml:

file_types_tuple = ('sbml', 'sedml')
file_types = [TYPES[i] for i in file_types_tuple]
filetypes_strings = ', '.join(file_types[:-1]) + ' and ' + file_types[-1] if len(file_types) > 1 else file_types[0]
if file_types_tuple in engine_filetypes_tuple_list:
return 'pass', (f"The filenames '{model_filepath}' and '{experiment_filepath}' suggest the input files are {filetypes_strings} which is compatible with {engine_name}.<br><br>{unique_compatible_filetpyes_strings} are compatible with {engine_name}.")
else:
return 'FAIL', (f"The filenames '{model_filepath}' and '{experiment_filepath}' suggest the input files are {filetypes_strings} which is not compatible with {engine_name}.<br><br>{unique_compatible_filetpyes_strings} are compatible with {engine_name}.")
else:
return 'unsure', (f"The file extensions {file_extensions} suggest the input file types may not be compatibe with {engine_name}.<br><br>{unique_compatible_filetpyes_strings} are compatible with {engine_name}.")
else:
return 'unsure', (f"The file extensions {file_extensions} suggest the input file types may not be compatibe with {engine_name}.<br><br>{unique_compatible_filetpyes_strings} are compatible with {engine_name}.")



def collapsible_content(content, title='Details'):
"""
Create a collapsible content section in markdown format
Expand Down Expand Up @@ -609,8 +640,9 @@ def run_biosimulators_remote(engine,sedml_filepath,sbml_filepath):
results_urls = biosimulations.submit_simulation_archive(\
archive_file=omex_file_name,\
sim_dict=sim_dict)

os.remove(omex_filepath)

if os.path.exists(omex_filepath):
os.remove(omex_filepath)

return results_urls

Expand Down Expand Up @@ -673,7 +705,8 @@ def run_biosimulators_docker(engine,sedml_filepath,sbml_filepath,output_dir='out
detailed_error_log_dict['status'] = 'FAIL'
detailed_error_log_dict['error_message'] = "Runtime Exception"

os.remove(omex_filepath)
if os.path.exists(omex_filepath):
os.remove(omex_filepath)

return {"exception_message":exception_message,"log_yml":log_yml_dict, "detailed_error_log":detailed_error_log_dict}

Expand All @@ -689,9 +722,12 @@ def biosimulators_core(engine,omex_filepath,output_dir=None):
output_dir: folder to write the simulation outputs to
'''

omex_filepath_no_spaces = remove_spaces_from_filename(omex_filepath)

#directory containing omex file needs mapping into the container as the input folders
omex_dir = os.path.dirname(os.path.abspath(omex_filepath))
omex_file = os.path.basename(os.path.abspath(omex_filepath))
omex_dir = os.path.dirname(os.path.abspath(omex_filepath_no_spaces))
omex_file = os.path.basename(os.path.abspath(omex_filepath_no_spaces))

mount_in = docker.types.Mount("/root/in",omex_dir,type="bind",read_only=True)

#we want the output folder to be different to the input folder
Expand All @@ -705,8 +741,11 @@ def biosimulators_core(engine,omex_filepath,output_dir=None):
client = docker.from_env()
client.containers.run(f"ghcr.io/biosimulators/{engine}",
mounts=[mount_in,mount_out],
command=f"-i /root/in/{omex_file} -o /root/out",
command=f"-i '/root/in/{omex_file}' -o /root/out",
auto_remove=True)

if os.path.exists(omex_filepath_no_spaces):
os.remove(omex_filepath_no_spaces)

def test_engine(engine,filename,error_categories=error_categories):
'''
Expand Down Expand Up @@ -1167,8 +1206,10 @@ def create_results_table(results, sbml_filepath, sedml_filepath, output_dir):
# add xfail to engines that do not support sbml
sbml_incompatible_ENGINES = [e for e in ENGINES.keys() if 'sbml' not in ENGINES[e]['formats'][0]]
for e in sbml_incompatible_ENGINES:
compatibility = check_file_compatibility_test(e, sbml_filepath, sedml_filepath)
compatibility_content = f'EXPECTED FAIL<br><br>{compatibility[1]}'
engine_name = ENGINES[e]['name']
unique_compatible_filetpyes_strings = ', '.join([TYPES[i] for i in ENGINES[e]['formats'][0] if i in list(TYPES.keys())])
compatibility = (f"Only {unique_compatible_filetpyes_strings} are compatible with {engine_name}.")
compatibility_content = f'EXPECTED FAIL<br><br>{compatibility}'
results_table.loc[results_table[ENGINE] == e, COMPAT] = collapsible_content(compatibility_content, title=f'{xfail_html}')
results_table.loc[results_table[ENGINE] == e, PASS_FAIL] = f'{xfail_html}'

Expand Down Expand Up @@ -1387,4 +1428,4 @@ def run_biosimulators_remotely_and_locally(engine_keys,
d1_plots_remote_dir=d1_plots_remote_dir,
test_folder=test_folder)

return results_table
return results_table