17.1.1.8. cobra.test

17.1.1.8.2. Package Contents

17.1.1.8.2.1. Functions

read_sbml_model(filename, number=float, f_replace=F_REPLACE, **kwargs)

Reads SBML model from given filename.

create_test_model(model_name=’salmonella’)

Returns a cobra model for testing

test_all(args=None)

alias for running all unit-tests on installed cobra

cobra.test.read_sbml_model(filename, number=float, f_replace=F_REPLACE, **kwargs)

Reads SBML model from given filename.

If the given filename ends with the suffix ‘’.gz’’ (for example, ‘’myfile.xml.gz’),’ the file is assumed to be compressed in gzip format and will be automatically decompressed upon reading. Similarly, if the given filename ends with ‘’.zip’’ or ‘’.bz2’,’ the file is assumed to be compressed in zip or bzip2 format (respectively). Files whose names lack these suffixes will be read uncompressed. Note that if the file is in zip format but the archive contains more than one file, only the first file in the archive will be read and the rest ignored.

To read a gzip/zip file, libSBML needs to be configured and linked with the zlib library at compile time. It also needs to be linked with the bzip2 library to read files in bzip2 format. (Both of these are the default configurations for libSBML.)

This function supports SBML with FBC-v1 and FBC-v2. FBC-v1 models are converted to FBC-v2 models before reading.

The parser tries to fall back to information in notes dictionaries if information is not available in the FBC packages, e.g., CHARGE, FORMULA on species, or GENE_ASSOCIATION, SUBSYSTEM on reactions.

Parameters
  • filename (path to SBML file, or SBML string, or SBML file handle) – SBML which is read into cobra model

  • number (data type of stoichiometry: {float, int}) – In which data type should the stoichiometry be parsed.

  • f_replace (dict of replacement functions for id replacement) – Dictionary of replacement functions for gene, specie, and reaction. By default the following id changes are performed on import: clip G_ from genes, clip M_ from species, clip R_ from reactions If no replacements should be performed, set f_replace={}, None

Returns

Return type

cobra.core.Model

Notes

Provided file handles cannot be opened in binary mode, i.e., use
with open(path, “r” as f):

read_sbml_model(f)

File handles to compressed files are not supported yet.

cobra.test.pytest[source]
cobra.test.cobra_directory[source]
cobra.test.cobra_location[source]
cobra.test.data_dir[source]
cobra.test.create_test_model(model_name='salmonella')[source]

Returns a cobra model for testing

model_name: str

One of ‘ecoli’, ‘textbook’, or ‘salmonella’, or the path to a pickled cobra.Model

cobra.test.test_all(args=None)[source]

alias for running all unit-tests on installed cobra