Differentiate time integration and printing results to files / remove redundant column from result_FBA / use preallocated numpy arrays
So far, Time_integration
computes the dFBA and outputs 3 data structures as results, but it also saves them in tsv files. Saving these results is maybe not the part of Time_integration
and saving should be done by another function.
Consequently, the test test_script_dfba_sampling_1.py
(and 2) should not have to save the results of Time_integration
, load them back and compare them with a ground truth. Instead, the comparison is made before a possible saving of the data.
Next, the data structure result_FBA
is a dict indexed by bacteries, whose values are numpy arrays containing the flux values for each species (metabolites/outputs/bacts). In the case where the YAML file contains two bacts, FBA is run iteratively for each bact (e.g. Styphi and Fprau). The problem is that even though those are separate computations, result_FBA['Styphi'] would still include a column for Fprau and conversely, with this column being full of 0s. This behavior should be removed, and instead of a dict, a Numpy 3D array would be easier to work with later.
Finally, instead of starting with empty lists that are appended and then converted to numpy array, working directly with numpy array (whose size we know in advance, because we have access to timestep/time horizon and number of variables) is more comprehensible, and faster.