means.io package

Submodules

class means.io.latex.LatexPrintableObject[source]

Bases: object

latex

Returns the latex text that could be printed into .tex document :return:

output_latex(filename_or_file_handle)[source]

Output the file to a latex document :param filename_or_file_handle: filename or already opened file handle to output to :return:

means.io.sbml.read_sbml(filename)[source]

Read the model from a SBML file.

Parameters:filename – SBML filename to read the model from
Returns:A tuple, consisting of Model instance, set of parameter values, and set of initial conditions variables.
class means.io.serialise.MeansDumper(stream, default_style=None, default_flow_style=None, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None)[source]

Bases: yaml.dumper.Dumper

class means.io.serialise.MeansLoader(stream)[source]

Bases: yaml.loader.Loader

class means.io.serialise.SerialisableObject[source]

Bases: yaml.YAMLObject

classmethod from_file(filename_or_file_object)[source]

Create new instance of the object from the file. :param filename_or_file_object: the filename of the file to read from or already opened file buffer :type filename_or_file_object: basestring|file

classmethod from_yaml(loader, node)[source]
to_file(filename_or_file_object)[source]

Save the object to the file, specified by filename file_ or the buffer provided in file_ :param filename_or_file_object: filename of the file to save the object to, or already open file buffer

means.io.serialise.dump(object_)[source]
means.io.serialise.from_file(filename_or_file_object)[source]

Read data from the specified file. :param filename_or_file_object: filename of the file or an opened file buffer to that file :type filename_or_file_object: basestring|file :return:

means.io.serialise.load(data)[source]
means.io.serialise.to_file(data, filename_or_file_object)[source]

Write data to a file specified by either filename of the file or an opened file buffer.

Parameters:
  • data – Object to write to file
  • filename_or_file_object (basestring|file) – filename/or opened file buffer to write to

Module contents

Module for Input/Output operations.

Human Readable Serialisation

The module implements common methods to serialise and deserialise MEANS objects. Namely the module provides functions means.io.dump() and means.io.load() that would serialise and deserialise the said objects into yaml format. These serialised representations can be written to or read from files with the help of means.io.to_file() and means.io.from_file() functions.

For the user’s convenience, the said methods are also attached to all serialisable objects, e.g. means.core.Model.from_file() method would allow the user to read means.core.Model object from file directly.

Binary Serialisation

We do not provide any convenience functions for binary serialisation of the object, because pickle package, which is in the default distribution of Python, has no problems of performing these tasks on MEANS objects.

We recommend using pickle, rather than means.io whenever fast serialisation is preferred to human readability.

SBML

This module also provides support for the input from SBML files. If the libsbml is installed in the user’s system and has the appropriate python bindings, the function means.io.read_sbml() can be used to parse the files in SBML format to means.core.Model objects.