Skip to content

utils

Utility functions.

FrozenClass

FrozenClass.

After freezing no additional attributes can be added.

contained_path

contained_path(output_dir, location)

Resolve an output filename below its directory, rejecting escapes.

Existing symlinks are resolved too, so they cannot redirect a write out of the output directory.

create_metaid

create_metaid(sbase)

Create a globally unique meta id.

Meta ids are required to store annotations on elements.

create_hash_id

create_hash_id(sbase)

Create hash code.

all_elements

all_elements(sbase)

Yield every element below an element, in the order of getListOfAllElements.

getListOfAllElements returns a linked list, and libsbml answers the python iteration over it with get(i), which walks the list from its head every time: iterating the 115925 elements of Recon3D that way takes 13 s instead of 0.2 s. The list is therefore consumed from its head with remove(0), which takes constant time. The list owns none of its elements, removing one from it leaves the document unchanged.

Parameters:

Name Type Description Default
sbase SBase

the element, e.g. a document or a model, whose elements are walked

required

Yields:

Type Description
SBase

every element below sbase, not sbase itself