% Author: Elsa W. Birch, ewbirch@stanford.edu, Covert Lab - Stanford Bioengineering
% Date: 4/24/2011
% Version: associated with production of the figures for Birch et al. 2012 
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% Summary: definition of options of simulations to run for paper
% 			** THIS IS THE VERSION USED WHEN FLUX BOUNDS ARE SPECIFICLALY PURTURBED TO EXPLORE THE LIMITING FACTORS OF VIRAL REPLICATION **
%
% Inputs: below
%
% Outputs: saved simulations, and writtingprogress output if requested
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% Notes: ** THIS IS THE VERSION USED WHEN FLUX BOUNDS ARE SPECIFICLALY PURTURBED TO EXPLORE THE LIMITING FACTORS OF VIRAL REPLICATION **
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

% organismModels: Names of parsed .mat files, must be exact, (and in this folder)
%
% organismIDs: Name of the field/structure of simulation that contains information about
%              the model and simulation. This should be unique if mutliple instances of
%              one model is to be used in one simulation/environemnt/coculture
%
% organismInitialBiomass: initial concentration of cells, in gDCW/L
%
% initializerHandles: function to initialize organism state
%                               - FBA_EB_intitializerPreculture
%
% fluxConstraintHandles: function to limit host fluxes ( by media, regulation)
%                               - FBA_EB_rFBAapplyConstraints
%
% accumulationSetHandles: function that allows accumulation of some (if any) metabolites
%                               - FBA_EB_accumulationViralHostMetConnect
%                               - FBA_EB_accumulationNoHostPooling
%
% viralConstraintHandles: function to call in the case that the virus draws sufficient
%                         recourse to cause glpk failure, this determines how resources are
%                         allocated to the virus
%                               - FBA_EB_limitViralMetToMaxViralPseudoBiomass
%                               - FBA_EB_limitViralMetToMaxHostBiomass
%                               - FBA_EB_limitViralMetToMaxViralFluxes
%                               - FBA_EB_limitViralFluxesToMaxViralPseudoBiomass
%                               - FBA_EB_limitViralFluxesToMaxViralFluxes
%
% media: media file, .txt, including exhaustable and replenished nutrients. Don't include
%        "Media" part of name nameMedia.
%
% viralOutputSubSteps: number of time data points to save for viral runs in between each
%                      FBA run. 
%
% viralODEsolverHandles: matlab ODE solver
%                               - see matlab documentation
% tTotal
% tStepSec
% mediaAllocationHandle
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function [] = FBA_EB_batchRun_fluxBoundSet( showProgress )


% User options:
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% organismModels, organismIDs (or now set to models?), media, tTotal, tStep, organismInitialBiomass,
% viralOutputSubSteps, viralConstraintHandles, accumulationSetHandles, initializerHandles, 
% fluxConstraintHandles, viralODEsolverHandles, viralOutputIDs, mediaAllocationHandle, dynamicFlag

batchName = 'simulationsMatlab';

optionsSim = {...
... simulationLocation(folder, name),                   organismModels,          organismIDs(not used),	media,      tTotal, tStepSec,   ...InitialBiomass,      viral...SubSteps,       viralConstraintHandles,                             accumulationSetHandles,                   viralRequestHandle,        modelarSingleStepHandle           
... Growth rate variation by flux bound set - increased growth cprrelations
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-5, -17],[1.5]; % mu=0.44?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-8, -17],[1.5]; % mu=0.72?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-6, -17],[1.5]; % mu=0.53?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7, -17],[1.5]; % mu=0.6?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-4, -17],[1.5]; % mu=0.34?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-3, -17],[1.5]; % mu=0.25?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-10, -17],[1.5]; % mu=0.89?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-12, -17],[1.5]; % mu=0.98?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -10],[1.5]; % mu=0.52?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -8],[1.5]; % mu=0.44?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -6],[1.5]; % mu=0.35?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -4],[1.5]; % mu=0.26?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-19],[1.25]; % mu=1.6?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-17],[1.25]; % mu=1.5?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-15],[1.25]; % mu=1.39?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-13],[1.25]; % mu=1.29?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-11],[1.25]; % mu=1.18?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-9],[1.25]; % mu=1?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-7],[1.25]; % mu=0.96?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-5],[1.25]; % mu=0.84?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-3],[1.25]; % mu=0.72?
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_succinateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-17],[1.5]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_acetateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-17],[1.5]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-2, -17],[1.5]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-1.5, -17],[1.5]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-1, -17],[1.5]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-2],[1.5]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-1],[1.5]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_succinateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-5],[1.5]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_metabolicLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_acetateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-5],[1.5]; % normal
... % the simulations for integrated and mechinery limit
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-5, -17],[1]; % mu=0.44?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-8, -17],[1]; % mu=0.72?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-6, -17],[1]; % mu=0.53?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7, -17],[1]; % mu=0.6?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-4, -17],[1]; % mu=0.34?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-3, -17],[1]; % mu=0.25?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-10, -17],[1]; % mu=0.89?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-12, -17],[1]; % mu=0.98?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -10],[1]; % mu=0.52?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -8],[1]; % mu=0.44?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -6],[1]; % mu=0.35?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-7.3, -4],[1]; % mu=0.26?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-19],[1]; % mu=1.6?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-17],[1]; % mu=1.5?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-15],[1]; % mu=1.39?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-13],[1]; % mu=1.29?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-11],[1]; % mu=1.18?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-9],[1]; % mu=1?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-7],[1]; % mu=0.96?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-5],[1]; % mu=0.84?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-3],[1]; % mu=0.72?
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_succinateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-17],[1]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_acetateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-17],[1]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-2, -17],[1]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-1.5, -17],[1]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_glucoseAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eGLC','eO2'},[-1, -17],[1]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-2],[1]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_tryptoneAerobic',        0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'}, { {} },{'eO2'},[-1],[1]; % mu=
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_succinateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-5],[1]; % normal
{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},      {'Ecoli_EB_T7_37Growth_EB_'},         {'ecoliEB'},           'Media_EB_acetateAerobic',    	0.4,     	10,         {0.05},                5,                	{'FBA_EB_limitViralMetToMaxDNTPsAfterMaxHostBiomass'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestMax'}, {'FBA_EB_modularSingleStepPremtiveLimit'},{ {} },{'eO2'},[-5],[1]; % normal


... short, uninfected
   ...{'simulationsMatlab','tryptoneUninfectedSimulation'},    {'Ecoli_EB_'},	{'ecoliEB'},	'Media_EB_tryptoneAerobic',     0.1,         60,         {0.0039},                 5,                	{'FBA_EB_limitViralMetToMaxHostBiomassAndDNTPs'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestAverage'}, {'FBA_EB_modularSingleStep'}, { {} };
   ...{fullfile('simulationsMatlab','fluxBoundsSet_mechineryLimit')},     {'Ecoli_EB_'},	{'ecoliEB'},	'Media_EB_glucoseAerobic',      0.1,         60,         {0.0025},                 5,                	{'FBA_EB_limitViralMetToMaxHostBiomassAndDNTPs'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestAverage'}, {'FBA_EB_modularSingleStep'}, { {} },{'eGLC','eO2'},[-5, -19],[1];
   ...{'simulationsMatlab','acetateUninfectedSimulation'},     {'Ecoli_EB_'},	{'ecoliEB'},	'Media_EB_acetateAerobic',      7,         60,         {0.0122},                 5,                	{'FBA_EB_limitViralMetToMaxHostBiomassAndDNTPs'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestAverage'}, {'FBA_EB_modularSingleStep'}, { {} };
   ...{'simulationsMatlab','succinateUninfectedSimulation'},   {'Ecoli_EB_'},	{'ecoliEB'},	'Media_EB_succinateAerobic',	7,         60,         {0.0084},                 5,                	{'FBA_EB_limitViralMetToMaxHostBiomassAndDNTPs'},    {'FBA_EB_accumulationViralHostMetConnect'}, {'FBA_EB_viralRequestAverage'}, {'FBA_EB_modularSingleStep'}, { {} };
   };

nSim = size( optionsSim, 1 );  

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

fileLabels = optionsSim(:,1);
optionsSim = optionsSim(:,2:end);

% Folder for storage
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
% data information 
timeVect = clock;
% prepare month string
if timeVect(2) < 10
    monthStr = ['0',num2str(timeVect(2))];
else
    monthStr = num2str(timeVect(2));
end
% prepare day string
if timeVect(3) < 10
    dayStr = ['0',num2str(timeVect(3))];
else
    dayStr = num2str(timeVect(3));
end
% prepare date string
dateStr = [ num2str(timeVect(1)), monthStr, dayStr ];

folderStr = [ dateStr, strrep(batchName, ' ', '') ];

noLabel = false;
for iLabel = 1 :nSim
    noLabel = noLabel || isempty( fileLabels{iLabel} );
end

if ~exist(folderStr,'dir') && noLabel
    mkdir(folderStr)
end % if folder does not exist

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



% Viral reffernce runs
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 



% Loop through entering options in simulation form
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
parfor iSim = 1 : nSim
   
    runOneSim(fileLabels, optionsSim, showProgress, folderStr, iSim)
    
end % iSim

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

end % main function

function [] = runOneSim( fileLabels, optionsSim, showProgress, folderStr, iSim)  
    
        % options fromuser input
    simulation.setup.organismModels = optionsSim{iSim, 1 };
    simulation.setup.organismIDs = optionsSim{iSim, 1 }; % replaceIDs entered with model names
    simulation.setup.media = optionsSim{iSim, 3 };
    simulation.tTotal = optionsSim{iSim, 4 };
    simulation.tStep = optionsSim{iSim, 5 } / 60 / 60; % sec to hour
    simulation.setup.organismInitialBiomass = optionsSim{iSim, 6 };
    simulation.setup.viralOutputSubSteps = optionsSim{iSim, 7 };
    simulation.setup.viralConstraintHandles = optionsSim{iSim, 8 };
    simulation.setup.accumulationSetHandles = optionsSim{iSim, 9 };
    simulation.setup.viralRequestHandle = optionsSim{iSim, 10 };
    simulation.setup.modularSingleStepHandle = optionsSim{iSim, 11 };
    simulation.setup.knockouts = optionsSim{iSim, 12 };
    
    % options that do not change between runs
    simulation.setup.initializerHandles = { 'FBA_EB_intitializerPreculture' };
    simulation.setup.fluxConstraintHandles = { 'FBA_EB_applyRegulationAndBounds' };
    simulation.setup.viralOutputIDs = { {'vMRNA3o5','vGP1','vGP10A','vGenome','vProcapsid','vT7'} };
    simulation.setup.viralODEsolverHandles = { 'ode15s' };
    simulation.mediaAllocationHandle = @FBA_EB_mediaAllocateSimpleProportion;
    simulation.dynamicFlag = true;
    
    % deal with viral reffernce runs
    simulation.setup.viralReferenceRunFlag = [ true ];
    
    
    % reset flux bounds
    fluxBoundsResetStrings = optionsSim{iSim, 13 };
    fluxBoundsResetValues = optionsSim{iSim, 14 };
    growthFactorResetValue = optionsSim{iSim, 15 };
    
    % run it
    folderPath = folderStr; 
    if showProgress
       nUpdates = 10;
    else
       nUpdates = 0;
    end
       
    
    FBA_EB_simulationPrepRunSave_fluxBoundSet(simulation, folderPath, nUpdates, fileLabels{iSim}, ...
                                                showProgress,fluxBoundsResetStrings,fluxBoundsResetValues,growthFactorResetValue);
    
end % % function runOneSim