6.1.1.3. pytfa.io
¶
6.1.1.3.1. Submodules¶
6.1.1.3.2. Package Contents¶
6.1.1.3.2.1. Classes¶
We define an encoder that takes care of the serialization of numpy types, |
6.1.1.3.2.2. Functions¶
|
Convert at matlab cobra_model to a pyTFA cobra_model, with Thermodynamic values |
|
|
|
Writes the Thermo Model to a Matlab-compatible structure |
|
Dumps the thermodynamic information in a mat-compatible dictionary |
|
Transforms reaction variable pairs from ('ACALD','ACALD_reverse_xxxxx') to |
|
Dumps the the MILP formulation for TFA in a mat-compatible dictionary |
|
Returns the generalized stoichiomatric matrix used for TFA |
|
Load a thermodynamic database |
|
Print the LP file corresponding to the cobra_model |
|
Write the LP file of the specified cobra_model to the file indicated by path. |
|
Writes a csv file in the format : |
|
Converts a lexicon into annotation for the metabolites |
|
|
|
|
|
|
|
6.1.1.3.2.3. Attributes¶
- pytfa.io.BIGM_DG = 1000.0¶
- pytfa.io.import_matlab_model(path, variable_name=None)[source]¶
Convert at matlab cobra_model to a pyTFA cobra_model, with Thermodynamic values
- Parameters
variable_name –
path (string) – The path of the file to import
- Returns
The converted cobra_model
- Return type
cobra.thermo.model.Model
- pytfa.io.write_matlab_model(tmodel, path, varname='tmodel')[source]¶
Writes the Thermo Model to a Matlab-compatible structure
- Parameters
varname –
tmodel –
path –
- Returns
None
- pytfa.io.create_thermo_dict(tmodel)[source]¶
Dumps the thermodynamic information in a mat-compatible dictionary (similar to the output of cobra.io.mat.create_mat_dict)
- Parameters
tmodel – pytfa.thermo.tmodel.ThermoModel
- Returns
dict object
- pytfa.io.varnames2matlab(name, tmodel)[source]¶
Transforms reaction variable pairs from (‘ACALD’,’ACALD_reverse_xxxxx’) to (‘F_ACALD’,’B_ACALD’) if it is a reaction, else leaves is as is
- Returns
- pytfa.io.create_problem_dict(tmodel)[source]¶
Dumps the the MILP formulation for TFA in a mat-compatible dictionary (similar to the output of cobra.io.mat.create_mat_dict)
- Parameters
tmodel – pytfa.thermo.tmodel.ThermoModel
:ret
- pytfa.io.create_generalized_matrix(tmodel, array_type='dense')[source]¶
Returns the generalized stoichiomatric matrix used for TFA
- Parameters
array_type –
tmodel – pytfa.ThermoModel
- Returns
matrix.
- pytfa.io.load_thermoDB(path)[source]¶
Load a thermodynamic database
- Parameters
path (string) – The path of the file to load
- Returns
The thermodynamic database
- Return type
- pytfa.io.printLP(model)[source]¶
Print the LP file corresponding to the cobra_model
- Parameters
model (cobra.thermo.model.Model) – The cobra_model to output the LP file for
- Returns
The content of the LP file
- Return type
Usually, you pass the result of this function to
file.write()
to write it on disk. If you prefer, you can usepytfa.io.writeLP()
to write the result directly to a file.
- pytfa.io.writeLP(model, path=None)[source]¶
Write the LP file of the specified cobra_model to the file indicated by path.
- Parameters
model (cobra.thermo.model.Model) – The COBRApy cobra_model to write the LP file for
path (string) – Optional The path of the file to be written. If not specified, the name of the COBRApy cobra_model will be used.
- class pytfa.io.MyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)¶
Bases:
json.JSONEncoder
We define an encoder that takes care of the serialization of numpy types, which are not handled by json by default
- default(self, obj)¶
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- pytfa.io.write_lexicon(tmodel, filepath)[source]¶
- Writes a csv file in the format :
seed_id
13BDglcn_c cpd11791 13dpg_c cpd00203 2pg_c cpd00482 3pg_c cpd00169 4abut_c cpd00281
Useful for exporting an annotation
- Parameters
tmodel (pytfa.core.ThermoModel) –
filepath –
- Returns
- pytfa.io.annotate_from_lexicon(model, lexicon)[source]¶
Converts a lexicon into annotation for the metabolites
- Parameters
model (cobra.Model) –
lexicon –
- Returns