psamm.datasource.sbml – SBML model parser

Parser for SBML model files.

class psamm.datasource.sbml.CompartmentEntry(reader, root, filemark=None)

Compartment entry in the SBML file

properties

All compartment properties as a dict.

class psamm.datasource.sbml.FluxBoundEntry(reader, namespace, root)

Flux bound defined with FBC V1.

Flux bounds defined with FBC V2 are instead encoded as upper_flux and lower_flux properties on the ReactionEntry objects.

id

Return ID of flux bound.

name

Return name of flux bound.

operation

Return the operation of the flux bound.

Returns one of LESS_EQUAL, GREATER_EQUAL or EQUAL.

reaction

Return reaction ID that the flux bound pertains to.

value

Return the flux bound value.

class psamm.datasource.sbml.ObjectiveEntry(reader, namespace, root)

Flux objective defined with FBC

exception psamm.datasource.sbml.ParseError

Error parsing SBML file

class psamm.datasource.sbml.ReactionEntry(reader, root, filemark=None)

Reaction entry in SBML file

equation

Reaction equation is a Reaction object

id

Reaction ID

kinetic_law_reaction_parameters

Iterator over the values of kinetic law reaction parameters

name

Reaction name

properties

All reaction properties as a dict

reversible

Whether the reaction is reversible

class psamm.datasource.sbml.SBMLReader(file, strict=False, ignore_boundary=False, context=None)

Reader of SBML model files

The constructor takes a file-like object which will be parsed as XML and then as SBML according to the specification. If the strict parameter is set to False, the parser will revert to a more lenient parsing which is required for many older models. This tries to mimic the inconsistencies employed by COBRA when parsing models.

If ignore_boundary is True, the species that are marked as boundary conditions will simply be dropped from the species list and from the reaction equations, and any boundary compartment will be dropped too.

compartments

Iterator over CompartmentEntry entries.

create_model()

Create model from reader.

Returns:psamm.datasource.native.NativeModel.
flux_bounds

Iterator over FluxBoundEntry

get_compartment(compartment_id)

Return CompartmentEntry corresponding to id.

get_objective(objective_id)

Return ObjectiveEntry corresponding to objective_id

get_reaction(reaction_id)

Return ReactionEntry corresponding to reaction_id

get_species(species_id)

Return SpeciesEntry corresponding to species_id

id

Model ID

name

Model name

objectives

Iterator over ObjectiveEntry

reactions

Iterator over ReactionEntries

species

Iterator over SpeciesEntries

This will not yield boundary condition species if those are ignored.

class psamm.datasource.sbml.SBMLWriter(cobra_flux_bounds=False)

Writer of SBML files

write_model(file, model, pretty=False)

Write a given model to file

class psamm.datasource.sbml.SpeciesEntry(reader, root, filemark=None)

Species entry in the SBML file

boundary

Whether this compound is a boundary condition

charge

Species charge

compartment

Species compartment

formula

Species formula

name

Species name

properties

All species properties as a dict