psctb.modeltools package

Submodules

psctb.modeltools._paths module

psctb.modeltools._paths.get_model_name(mod)[source]

Returns the file name of a pysces model object sans the file extension.

Parameters:
mod : PysMod

Model of interest.

Returns:
str

File name of a mod sans extension.

psctb.modeltools._paths.make_path(mod, analysis_method, subdirs=[])[source]

Creates paths based on model name and analysis type.

This function is used to create directories (in the case where they don’t already exist) to write analysis results to and return the path name. Subdirectories can also be created.

/path/to/Pysces/model_name/analysis_method/subdir1/subdir2/

Parameters:
mod : PysMod

The model being analysed.

analysis_method : str

The name of the tool being used to analyse the model.

subdirs : list of str

An optional list of subdirectories where each additional entry in the list will create a subdirectory in the previous directories.

Returns:
str

The directory string

Examples

>>> print make_path(mod, 'analysis_method', subdirs = ['subdir1', subdir2])
'/path/to/Pysces/model_name/analysis_method/subdir1/subdir2/'
psctb.modeltools._paths.next_suffix(directory, base_name, ext=None)[source]

Returns the number of the next suffix to be appended to a base file name when saving a file.

This function checks a directory for files containing base_name and returns a number that is equal to the suffix of a file named base_name with the largest suffix plus one.

Parameters:
directory : str

The directory to inspect for files.

base_name : str

The base name (sans suffix) to check for.

Returns:
int

The next suffix to write

psctb.modeltools._paths.get_file_path(working_dir, internal_filename, fmt, fixed=None, file_name=None, write_suffix=True)[source]

An heuristic for determining the correct file name.

This function determines the file name according to the information supplied by the user and the internals of a specific class.

Parameters:
working_dir : str

The working dir of the specific class (where files are saved if no file name is supplied)

internal_filename : str

The default base name (sans numbered suffix) of files when no other details are provided.

fmt : str

The format (extension) that the file should be saved in. This is used both in determining file name if no file name is provided as well as when a file name without extension is provided.

fixed : str, Optional (Default

In the case that a metabolite is fixed, files will be saved in a subdirectory of the working directory that corresponds to the fixed metabolite.

file_name : str, Optional (Default : None)

If a file name is supplied it overwrites all other options except fmt in the case where no extension is supplied.

Returns
——-
str

The final file name

psctb.modeltools._paths.get_fmt(file_name)[source]

Gets the extension (fmt) from a file name.

Parameters:
file_name : str

The file to get an extension from

Returns:
str

The extension string

psctb.modeltools._pscmanipulate module

psctb.modeltools._pscmanipulate.psc_to_str(name)[source]

Takes a filename and returns a path of where this file should be found.

Parameters:
name : str

A string containing a filename.

Returns:
str

A string indicating the path to a psc file.

psctb.modeltools._pscmanipulate.mod_to_str(mod)[source]

Converts an instantiated PySCeS model to a string.

Parameters:
mod : PysMod

A Pysces model.

Returns:
str

A string representation of the contents of a PySCeS model file.

psctb.modeltools._pscmanipulate.strip_fixed(fstr)[source]

Take a psc file string and return two strings: (1) The file header containing the “FIX: ” line and (2) the remainder of file.

Parameters:
fstr : str

String representation of psc file.

Returns:
tuple of str

1st element contains file header, second the remainder of the file.

psctb.modeltools._pscmanipulate.augment_fix_sting(OrigFix, fix)[source]

Adds a species to a psc file header.

Parameters:
OrigFix : str

A psc file header

fix : str

Additional species to add to psc file header.

Returns:
str

A new psc file header that contains the contents of the original together with the new fixed species.

psctb.modeltools._pscmanipulate.fix_metabolite(mod, fix, model_name=None)[source]

Fix a metabolite in a model and return a new model with the fixed metabolite.

Parameters:
mod : PysMod

The original model.

fix : str

The metabolite to fix.

model_name : str, optional (Default

The file name to use when saving the model (in psc/orca). If None it defaults to original_model_name_fix.

Returns:
PysMod

A new model instance with an additional fixed species.

psctb.modeltools._pscmanipulate.fix_metabolite_ss(mod, fix, model_name=None)[source]

Fix a metabolite at its steady state in a model and return a new model with the fixed metabolite.

Parameters:
mod : PysMod

The original model.

fix : str

The metabolite to fix.

model_name : str, optional (Default

The file name to use when saving the model (in psc/orca). If None it defaults to original_model_name_fix.

Returns:
PysMod

A new model instance with an additional fixed species.

See also

fix_metabolite

Module contents