This notebook an example for creating a COMBINE archive. A COMBINE archive is a bundled package containing all the necessary documents and relevant information for a modeling and simulation project, ensuring that all components are conveniently stored together. The archive is encoded using the Open Modeling EXchange format (OMEX).
Note: Please change the colab
flag to True
if you are using Google Colab.
colab = False
if colab:
!pip install git+https://github.com/combine-org/combine-notebooks
!git clone https://github.com/combine-org/combine-notebooks
%cd /content/combine-notebooks/notebooks
from pathlib import Path
from pymetadata.console import console
from pymetadata.omex import EntryFormat, ManifestEntry, Omex
from combine_notebooks import RESULTS_DIR
Creating an empty archive and adding entry for SBML.
# Create OMEX archive of resources.
omex = Omex()
Get the file location of our results files. These were generated by other notebooks in this repositiory. The files we will be adding to our OMEX file include:
# Path to our results
results_dir = Path(RESULTS_DIR.stem)
First, lets add our simple SBML file into the COMBINE archieve.
# Add entry for the SBML model
omex.add_entry(
entry=ManifestEntry(
location="./sbml/hello_world_sbml.xml",
format=EntryFormat.SBML_L3V2,
master=False,
),
entry_path=results_dir / "hello_world_sbml.xml",
)
Now we'll add our simple CellML model.
# Add entry for the CellML model
omex.add_entry(
entry=ManifestEntry(
location="./cellml/hello_world_cellml.cellml",
format=EntryFormat.CELLML,
master=False,
),
entry_path=results_dir / "hello_world_cellml.cellml",
)
Next lets add entries for both our SBGN file and the png that it generated.
# Add entry for SBGN file
omex.add_entry(
entry=ManifestEntry(
location="./sbgn/hello_world_sbgn.sbgn",
format=EntryFormat.SBGN,
master=False,
),
entry_path=results_dir / "hello_world_sbgn.sbgn",
)
# Add entry for corresponding png file generated from the SBGN
omex.add_entry(
entry=ManifestEntry(
location="./sbgn/hello_world_sbgn.png",
format=EntryFormat.PNG,
master=False,
),
entry_path=results_dir / "hello_world_sbgn.png",
)
Finally, we will add a SED-ML file to the COMBINE archieve.
# Add entry for the SEDML simulation experiment
omex.add_entry(
entry=ManifestEntry(
location="./sedml/hello_world_sedml.sedml",
format=EntryFormat.SEDML,
master=False,
),
entry_path=results_dir / "hello_world_sedml.sedml"
)
And we're done creating the OMEX file. Now lets save it.
RESULTS_DIR.mkdir(parents=True, exist_ok=True)
omex_path = RESULTS_DIR / "combine_hello_world.omex"
omex.to_omex(omex_path)
We can also use the console.print
function to display the comtent of the OMEX file.
console.print(omex)
[ ManifestEntry(location='.', format='http://identifiers.org/combine.specifications:omex', master=False), ManifestEntry(location='./manifest.xml', format='http://identifiers.org/combine.specifications:omex-manifest', master=False), ManifestEntry(location='./sbml/hello_world_sbml.xml', format='http://identifiers.org/combine.specifications:sbml.level-3.version-2', master=False), ManifestEntry(location='./cellml/hello_world_cellml.cellml', format='http://identifiers.org/combine.specifications:cellml', master=False), ManifestEntry(location='./sbgn/hello_world_sbgn.sbgn', format='http://identifiers.org/combine.specifications:sbgn', master=False), ManifestEntry(location='./sbgn/hello_world_sbgn.png', format='https://purl.org/NET/mediatypes/image/png', master=False), ManifestEntry(location='./sedml/hello_world_sedml.sedml', format='http://identifiers.org/combine.specifications:sed-ml', master=False)]