sbmlsim.combine.omex

COMBINE Archive helper functions and classes based on libCOMBINE.

Here common operations with COMBINE archives are implemented, like extracting archives, creating archives from entries or directories, adding metadata, listing content of archives.

When working with COMBINE archives these wrapper functions should be used.

Module Contents

Classes

Creator

Helper class to store the creator information.

Entry

Helper class to store content to create an OmexEntry.

Omex

Combine archive class

Attributes

logger

sbmlsim.combine.omex.logger[source]
class sbmlsim.combine.omex.Creator(given_name, family_name, organization, email)[source]

Helper class to store the creator information.

FIXME: reuse sbmlutils creators

Parameters
  • given_name (str) –

  • family_name (str) –

  • organization (str) –

  • email (str) –

class sbmlsim.combine.omex.Entry(location, format=None, format_key=None, master=False, description=None, creators=None)[source]

Helper class to store content to create an OmexEntry.

Parameters
  • location (str) –

  • format (str) –

  • format_key (str) –

  • master (bool) –

  • description (str) –

  • creators (Iterator[Creator]) –

__str__(self)[source]

String representation of entry.

Return type

str

class sbmlsim.combine.omex.Omex(omex_path, working_dir)[source]

Combine archive class

Parameters
  • omex_path (pathlib.Path) –

  • working_dir (pathlib.Path) –

__repr__(self)[source]

Get representation string.

Return type

str

__str__(self)[source]

Get contents of archive string.

Return type

str

_omex_init(self)[source]

Initialize omex from archive.

Call omex.cleanUp after finishing.

Return type

libcombine.CombineArchive

classmethod from_directory(cls, omex_path, directory, creators=None)[source]

Creates a COMBINE archive from a given folder.

The file types are inferred, in case of existing manifest or metadata information this should be reused.

For all SED-ML files in the directory the master attribute is set to True.

Parameters
  • directory (pathlib.Path) – Directory to compress

  • omex_path (pathlib.Path) – Output path for omex directory

  • creators – List of creators

Returns

Return type

Omex

classmethod from_entries(cls, omex_path, entries, working_dir)[source]

Creates combine archive from given entries.

Overwrites existing combine archive at omex_path.

Parameters
  • omex_path (pathlib.Path) – Path of archive

  • entries (Iterable[Entry]) –

  • working_dir (pathlib.Path) –

Returns

Return type

Omex

_from_entries(self, entries, add_entries)[source]

Create archive from given entries.

Parameters
  • entries (Iterable[Entry]) – entries which should be in the archive.

  • add_entries (bool) – boolean flag to add entries or create new archive

Returns

extract(self, output_dir=None, method='zip')[source]

Extract combine archive to working directory.

The zip method extracts all entries in the zip, the omex method only extracts the entries listed in the manifest. In some archives not all content is listed in the manifest.

Parameters
  • output_dir (pathlib.Path) – output directory

  • method (str) – method to extract content, either ‘zip’ or ‘omex’

Returns

Return type

None

locations_by_format(self, format_key=None, method='omex')[source]

Get locations to files with given format in the archive.

Uses the libcombine KnownFormats for formatKey, e.g., ‘sed-ml’ or ‘sbml’. Files which have a master=True have higher priority and are listed first.

Parameters
  • omex_path

  • format_key (str) –

  • method

Returns

list_contents(self, method='omex')[source]

Returns list of contents of the combine archive.

Parameters
  • omexPath

  • method – method to extract content, only ‘omex’ supported

Returns

list of contents

Return type

List[List[Any]]