psamm.datasource.native
– Native data format parser¶
Module for reading and writing native formats.
These formats are either table-based or YAML-based. Table-based formats are space-separated and empty lines are ignored. Comments starting with pound (#). YAML-based formats are structured data following the YAML specification.
-
class
psamm.datasource.native.
CompoundEntry
(compound_id, properties, filemark=None)¶ Representation of a compound entry in a native model
-
class
psamm.datasource.native.
NativeModel
(model_from, context=None)¶ Represents a model specified using the native data formats
The model is created from a model file or from a directory containing a model file using the default file name (model.yaml or model.yml). This file can specify the model fully or refer to other files within the same directory subtree that specifies part of the model.
-
create_metabolic_model
()¶ Create a
psamm.metabolicmodel.MetabolicModel
.
-
get_biomass_reaction
()¶ Return the biomass reaction specified by the model
-
get_default_flux_limit
()¶ Return the default flux limit specified by the model
-
get_extracellular_compartment
()¶ Return the extracellular comparment specified by the model.
-
get_name
()¶ Return the name specified by the model
-
has_model_definition
()¶ Return True when the list of model reactions is set in the model.
-
classmethod
load_model_from_path
(path)¶ Create a model from specified path.
-
parse_compounds
()¶ Yield CompoundEntries for defined compounds
-
parse_limits
()¶ Yield tuples of reaction ID, lower, and upper bound flux limits
-
parse_medium
()¶ Yield tuples of medium compounds.
Each medium compound is a tuple of compound, reaction ID, lower and upper flux limits.
-
parse_model
()¶ Yield reaction IDs of model reactions
-
parse_reactions
()¶ Yield tuples of reaction ID and reactions defined in the model
-
-
exception
psamm.datasource.native.
ParseError
¶ Exception used to signal errors while parsing
-
class
psamm.datasource.native.
ReactionEntry
(id, properties, filemark=None)¶ Representation of a reaction entry in a native model
-
psamm.datasource.native.
parse_compound
(compound_def, context=None)¶ Parse a structured compound definition as obtained from a YAML file
Returns a CompoundEntry.
-
psamm.datasource.native.
parse_compound_file
(path, format)¶ Open and parse reaction file based on file extension or given format
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_compound_list
(path, compounds)¶ Parse a structured list of compounds as obtained from a YAML file
Yields CompoundEntries. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_compound_table_file
(path, f)¶ Parse a tab-separated file containing compound IDs and properties
The compound properties are parsed according to the header which specifies which property is contained in each column.
-
psamm.datasource.native.
parse_compound_yaml_file
(path, f)¶ Parse a file as a YAML-format list of compounds
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_limit
(limit_def)¶ Parse a structured flux limit definition as obtained from a YAML file
Returns a tuple of reaction, lower and upper bound.
-
psamm.datasource.native.
parse_limits_file
(path)¶ Parse a file as a list of reaction flux limits
The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_limits_list
(path, limits)¶ Parse a structured list of flux limits as obtained from a YAML file
Yields tuples of reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_limits_table_file
(f)¶ Parse a space-separated file containing reaction flux limits
The first column contains reaction IDs while the second column contains the lower flux limits. The third column is optional and contains the upper flux limit.
-
psamm.datasource.native.
parse_limits_yaml_file
(path, f)¶ Parse a file as a YAML-format flux limits definition
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_medium
(medium_def)¶ Parse a structured medium definition as obtained from a YAML file
Returns in iterator of compound, reaction, lower and upper bounds.
-
psamm.datasource.native.
parse_medium_file
(path)¶ Parse a file as a list of medium compounds with flux limits
The file format is detected and the file is parsed accordingly. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_medium_list
(path, medium)¶ Parse a structured medium list as obtained from a YAML file.
Yields tuples of compound, reaction ID, lower and upper flux bounds. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_medium_table_file
(f)¶ Parse a space-separated file containing medium compound flux limits
The first two columns contain compound IDs and compartment while the third column contains the lower flux limits. The fourth column is optional and contains the upper flux limit.
-
psamm.datasource.native.
parse_medium_yaml_file
(path, f)¶ Parse a file as a YAML-format medium definition
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_model_file
(path)¶ Parse a file as a list of model reactions
The file format is detected and the file is parsed accordinly. The file is specified as a file path that will be opened for reading. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_model_group
(path, group)¶ Parse a structured model group as obtained from a YAML file
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_model_group_list
(path, groups)¶ Parse a structured list of model groups as obtained from a YAML file
Yields reaction IDs. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_model_table_file
(path, f)¶ Parse a file as a list of model reactions
Yields reactions IDs. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_model_yaml_file
(path, f)¶ Parse a file as a YAML-format list of model reaction groups
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_reaction
(reaction_def, context=None)¶ Parse a structured reaction definition as obtained from a YAML file
Returns a ReactionEntry.
-
psamm.datasource.native.
parse_reaction_equation
(equation_def)¶ Parse a structured reaction equation as obtained from a YAML file
Returns a Reaction.
-
psamm.datasource.native.
parse_reaction_file
(path)¶ Open and parse reaction file based on file extension
Path can be given as a string or a context.
-
psamm.datasource.native.
parse_reaction_list
(path, reactions)¶ Parse a structured list of reactions as obtained from a YAML file
Yields tuples of reaction ID and reaction object. Path can be given as a string or a context.
-
psamm.datasource.native.
parse_reaction_table_file
(path, f)¶ Parse a tab-separated file containing reaction IDs and properties
The reaction properties are parsed according to the header which specifies which property is contained in each column.
-
psamm.datasource.native.
parse_reaction_yaml_file
(path, f)¶ Parse a file as a YAML-format list of reactions
Path can be given as a string or a context.
-
psamm.datasource.native.
resolve_format
(format, path)¶ Looks at a file’s extension and format (if any) and returns format.
-
psamm.datasource.native.
whendefined
(func, value)¶ Apply func to value if value is not None
-
psamm.datasource.native.
yaml_load
(stream)¶ Load YAML file using safe loader.