% Author: Elsa W. Birch, ewbirch@stanford.edu, Covert Lab - Stanford Bioengineering
% Date: July 27th 2012
% Version: associated with production of the figures for Birch et al. 2012
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% Summary: This function loops through the .mat files in a specified folder and calls functions 
% 			to write them to text output in another specified folder
% 
%
% Inputs: 	folderReadStr - A string contianing the folder path from which files are to be read.
%			folderSaveStr - A string with the path to where output is to be saved
%			outputProgress - Logical specifiying whether or not to write text output for the number of parsed and total files.
%
% Outputs: text format table saved in <fileSaveStr>
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
%
% Notes: > Hard specification of which viral concentrations to pass to parser 
%		 > Should include more catches for non-existance of files folders, so currently not very robust to errors.
%
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function [] = FORMAT_EB_parseFilesInFolderTo(folderStr, folderSaveStr, outputProgress)

% add checks that folders exist!!

filesInFolder = dir( fullfile( folderStr ) );
nFilesInFolder = length( filesInFolder );

cFile = 0;
for iFileCheck = 1 : nFilesInFolder
    name = filesInFolder( iFileCheck ).name;
    if ~filesInFolder( iFileCheck ).isdir && strcmp( name(end-3:end), '.mat')
        cFile = cFile + 1;
        files{cFile} = name(1:end-4);
    end
end



viralConcentrations = {'vgp10a', 'vT7', 'vPROCAPSID','vgp1','vMRNA10a','vMRNA1','vGENOME', 'vDNTPS',...
    'vgp2o5','vgp5','vgp4A'};
simFields = {'biomass', 'growth','status'};

nFile = length( files );
for iFile = 1: nFile

    fileString = files{iFile} ;
    folderReadStr = folderStr;
    FORMAT_EB_mat2textFluxes( folderReadStr, fileString, folderSaveStr, viralConcentrations, simFields)

    if outputProgress
        disp(['  Parsing simulation file ',num2str(iFile),'/',num2str(nFile),' in ',folderStr])
    end
    
end


