psctb.modeltools package¶
Submodules¶
psctb.modeltools._paths module¶
- 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_dirstr
The working dir of the specific class (where files are saved if no file name is supplied)
- internal_filenamestr
The default base name (sans numbered suffix) of files when no other details are provided.
- fmtstr
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.
- fixedstr, Optional (DefaultNone)
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_namestr, Optional (DefaultNone)
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_namestr
The file to get an extension from
- Returns
- str
The extension string
- psctb.modeltools._paths.get_model_name(mod)[source]¶
Returns the file name of a pysces model object sans the file extension.
- Parameters
- modPysMod
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
- modPysMod
The model being analysed.
- analysis_methodstr
The name of the tool being used to analyse the model.
- subdirslist 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 containingbase_name
and returns a number that is equal to the suffix of a file namedbase_name
with the largest suffix plus one.- Parameters
- directorystr
The directory to inspect for files.
- base_namestr
The base name (sans suffix) to check for.
- Returns
- int
The next suffix to write
psctb.modeltools._pscmanipulate module¶
- psctb.modeltools._pscmanipulate.augment_fix_sting(OrigFix, fix)[source]¶
Adds a species to a psc file header.
- Parameters
- OrigFixstr
A psc file header
- fixstr
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
- modPysMod
The original model.
- fixstr
The metabolite to fix.
- model_namestr, optional (Defaultnone)
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
- modPysMod
The original model.
- fixstr
The metabolite to fix.
- model_namestr, optional (Defaultnone)
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
- psctb.modeltools._pscmanipulate.mod_to_str(mod)[source]¶
Converts an instantiated PySCeS model to a string.
- Parameters
- modPysMod
A Pysces model.
- Returns
- str
A string representation of the contents of a PySCeS model file.
- psctb.modeltools._pscmanipulate.psc_to_str(name)[source]¶
Takes a filename and returns a path of where this file should be found.
- Parameters
- namestr
A string containing a filename.
- Returns
- str
A string indicating the path to a psc 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
- fstrstr
String representation of psc file.
- Returns
- tuple of str
1st element contains file header, second the remainder of the file.
See also