Home > functions > internal > dsUnzipDemoData.m

dsUnzipDemoData

PURPOSE ^

dsUnzipDemoData - Unzips demo data (utility function)

SYNOPSIS ^

function study_dir = dsUnzipDemoData(zipfname,overwrite_flag,verbose_flag)

DESCRIPTION ^

dsUnzipDemoData - Unzips demo data (utility function)

 Purpose: Restores demo data to the appropriate folder incase the user
 deleted it.

 Usage:
   study_dir = dsUnzipDemoData(zipfname,overwrite_flag)

 Inputs:
   zipfname: string with name of zipped file. Can be either a full path or
       just the filename, since DynaSim knows where to look for its
       demo zip files.
   overwrite_flag: {0,1} - Flag to force overwrite if directory already
       exists.
   verbose_flag: {0,1} - verbose flag

 Outputs:
   study_dir: input 

 Examples:
   study_dir = unDemoData('demo_sPING_100cells_3x3.zip')
   study_dir = unDemoData('/Users/davestanley/Dropbox/git/DynaSimSherfey/demos/demo_zips/demo_sPING_100cells_3x3.zip')
       (both return same result)
 
 Author:
   David Stanley, stanleyd@bu.edu, March 2017

 See also: ZipDemoData, demos_generate_data.m (demo script)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function study_dir = dsUnzipDemoData(zipfname,overwrite_flag,verbose_flag)
0002 %dsUnzipDemoData - Unzips demo data (utility function)
0003 %
0004 % Purpose: Restores demo data to the appropriate folder incase the user
0005 % deleted it.
0006 %
0007 % Usage:
0008 %   study_dir = dsUnzipDemoData(zipfname,overwrite_flag)
0009 %
0010 % Inputs:
0011 %   zipfname: string with name of zipped file. Can be either a full path or
0012 %       just the filename, since DynaSim knows where to look for its
0013 %       demo zip files.
0014 %   overwrite_flag: {0,1} - Flag to force overwrite if directory already
0015 %       exists.
0016 %   verbose_flag: {0,1} - verbose flag
0017 %
0018 % Outputs:
0019 %   study_dir: input
0020 %
0021 % Examples:
0022 %   study_dir = unDemoData('demo_sPING_100cells_3x3.zip')
0023 %   study_dir = unDemoData('/Users/davestanley/Dropbox/git/DynaSimSherfey/demos/demo_zips/demo_sPING_100cells_3x3.zip')
0024 %       (both return same result)
0025 %
0026 % Author:
0027 %   David Stanley, stanleyd@bu.edu, March 2017
0028 %
0029 % See also: ZipDemoData, demos_generate_data.m (demo script)
0030 
0031     if nargin < 2
0032         overwrite_flag = 0;
0033     end
0034     
0035     if nargin < 3
0036         verbose_flag = 1;
0037     end
0038 
0039     ds_root_path = dsGetConfig('ds_root_path');
0040     demos_path = dsGetConfig('demos_path');
0041     demo_zips_path = dsGetConfig('demos_zips_path');
0042 
0043     mkdirSilent(demos_path);
0044     
0045     % Make sure zipfname ends in zip and doesn't have any other crap in
0046     % front of it
0047     [path, zipfilename_only, ext] = fileparts(zipfname);
0048     zipfname = [zipfilename_only, '.zip'];
0049     
0050     % Verify the source (zip file) exists; if not, download it from web!
0051     if ~exist(fullfile(demo_zips_path,zipfname),'file')
0052      
0053         dsDownloadFiles(fullfile(demo_zips_path,zipfname));
0054 
0055     end
0056     
0057     % Get the destination directory
0058     study_dir = fullfile(demos_path,zipfilename_only);
0059 
0060     % Unzip
0061     if ~exist(study_dir,'dir')
0062         if verbose_flag; fprintf('Unzipping demo data to %s.\n',study_dir); end
0063         unzip(fullfile(demo_zips_path,zipfname),demos_path);
0064     elseif exist(study_dir,'dir') && overwrite_flag
0065         if verbose_flag; fprintf('Demo data folder %s already exists. Overwriting \n',study_dir); end
0066         unzip(fullfile(demo_zips_path,zipfname),demos_path);
0067     else
0068         if verbose_flag; fprintf('Demo data folder %s already exists. Skipping \n',study_dir); end
0069     end
0070     
0071     
0072 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005