Skip to content

Commit

Permalink
Flag SBML as master, not SEDML files.
Browse files Browse the repository at this point in the history
Also, export list of SBML Master files, so that list can be used when uploading to biomodels.
  • Loading branch information
luciansmith committed Jul 9, 2024
1 parent 02892e8 commit a80c460
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
9 changes: 5 additions & 4 deletions create_omex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

def process(project_id, project_path, omex_dir, write_omex, sbml_master = None):
manifest_filename = os.path.join(project_path, 'manifest.xml')
sedml_filenames = glob.glob(os.path.join(project_path, '**', '*.sedml'), recursive=True)
sedml_locations = [os.path.relpath(path, project_path) for path in sedml_filenames]
# sedml_filenames = glob.glob(os.path.join(project_path, '**', '*.sedml'), recursive=True)
# sedml_locations = [os.path.relpath(path, project_path) for path in sedml_filenames]
master_files = []
if sbml_master:
sedml_locations.append(sbml_master)
master_files.append(sbml_master)
if os.path.exists(manifest_filename):
#Have to do this, otherwise build_combine_archive creates a new one!
os.remove(manifest_filename)
archive = build_combine_archive(project_path, sedml_locations)
archive = build_combine_archive(project_path, master_files)
if write_omex:
combine_writer.run(archive, project_path, omex_dir + "/" + project_id + ".omex")
#Write the new manifest.xml file:
Expand Down
17 changes: 16 additions & 1 deletion fix-entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
import tempfile
import warnings
import math
import json

MANUALLY_FIXED_ENTRIES_DIR = os.path.join(os.path.dirname(__file__), 'manual-fixes')
FINAL_ENTRIES_DIR = os.path.join(os.path.dirname(__file__), 'final')
OMEX_DIR = os.path.join(os.path.dirname(__file__), 'omex_files')

global_sbml_validation_errors = []

all_masters = {}
only_masters = False


def get_entry_ids():
""" Get the ids of the entries of BioModels
Expand Down Expand Up @@ -165,7 +169,13 @@ def fix_entry(id, convert_files=False, guess_file_name=None, validate_sbml=False
remove_initial_rdf_file.run(rdf_filenames)
remove_failed_pdfs.run(pdf_filenames)
remove_non_sbml.run(id, sbml_filenames)

master_sbml = rename_sbml_files.run(id, sbml_filenames, master_sbml)
all_masters[id] = master_sbml

if only_masters:
return

rename_xpp_to_ode.run(xpp_filenames)

# SED-ML files: recreate from COPASI, then fix the model sources.
Expand Down Expand Up @@ -254,7 +264,7 @@ def fix_entry(id, convert_files=False, guess_file_name=None, validate_sbml=False

###################################################
# Build manifest and create OMEX file
create_omex.process(id, temp_entry_dir, OMEX_DIR, False)
create_omex.process(id, temp_entry_dir, OMEX_DIR, False, master_sbml)

###################################################
# Move temporary directory to final location
Expand Down Expand Up @@ -371,3 +381,8 @@ def fix_entry(id, convert_files=False, guess_file_name=None, validate_sbml=False
git_add_file.write("git add final/" + id + "/*\n")
git_add_file.write("git add good_pmids.p\n")
git_add_file.close()

if only_masters:
with open('all_masters.json', 'w') as f:
json.dump(all_masters, f)

0 comments on commit a80c460

Please sign in to comment.