% 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: set current conditional flux bounds that are not based on the regulation of 
% 				another genetic elelment but directly on conditions for some reason.
% 
%
% Inputs: 
%
% Outputs: 
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% Notes: 
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function fluxBoundsWithConditions = FBA_EB_setCurrentConditionalFluxBounds( fluxBoundsDefault,...
    fluxBoundsConditional ,currentMedia, tfActivity , geneProductActivity, currentStimuli, currentFlux )


% for the purpose of regulation, round very small media/fluxes to zero
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
zeroThresh = 0.05;

currentFlux = currentFlux .* ( abs( currentFlux ) > zeroThresh );
currentMedia = currentMedia .* ( abs( currentMedia ) > zeroThresh );

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

nCondFluxBounds = size( fluxBoundsConditional, 1 );

if nCondFluxBounds > 0
    
    % loop through conditions applying if condition is true
    for iCond = 1 : nCondFluxBounds
        
        if eval( fluxBoundsConditional{ iCond, 3} )
            
            fluxBoundsDefault( fluxBoundsConditional{ iCond, 1},: ) = fluxBoundsConditional{ iCond, 2};
            
        end
        
    end % for iCond
    
end

fluxBoundsWithConditions = fluxBoundsDefault;
end % function FBA_EB_setCurrentConditionalFluxBounds




