From 3b3ef5a2e2ed4ca0263283424d0cee9724d4e614 Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Sat, 27 Jul 2024 01:14:44 -0400 Subject: [PATCH] DMPexcel2mat.m refactor --- workflow/templates/easy/DMPexcel2mat.m | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/workflow/templates/easy/DMPexcel2mat.m b/workflow/templates/easy/DMPexcel2mat.m index ddc22078..894817a4 100755 --- a/workflow/templates/easy/DMPexcel2mat.m +++ b/workflow/templates/easy/DMPexcel2mat.m @@ -6,7 +6,7 @@ global drugMediaFile global matDir % If we already have mpdmFile, don't recreate -if exist(mpdmFile, 'file') && ~isempty(mpdmFile) +if (exist(mpdmFile, 'file') && ~isempty(mpdmFile)) disp(strcat('The Drug Media/MasterPlate Annotation File: ', mpdmFile, ' exists, skipping DMPexcel2mat.m')); return end @@ -16,9 +16,11 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile) if exist(fullfile(matDir), 'dir') % Try to find the masterPlateFile automatically (newest created first) try - files=dir(matDir) + files=dir(matDir); mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name}; - isempty(mpFiles) && throw(MException('MATLAB:dir', 'No MasterPlate_ files in the default MasterPlate directory')); + if isempty(mpFiles) + throw(MException('MATLAB:dir', 'No MasterPlate_ files in the default MasterPlate directory')); + end % this sorts by date (newest first) [~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend'); sortedFiles=mpFiles(sortedIndices); @@ -37,7 +39,9 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile) dirToScan=uigetdir(); files=dir(dirToScan); mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name}; - isempty(mpFiles) && throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory')) + if isempty(mpFiles) + throw(MException('MATLAB:dir', 'No MasterPlate_ files in directory')) + end % this sorts by date (newest first) [~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend'); sortedFiles=mpFiles{sortedIndices}; @@ -60,7 +64,9 @@ if ~exist(masterPlateFile, 'file') || isempty(masterPlateFile) dirToScan=uigetdir(); files=dir(dirToScan); mpFiles={files(strncmp(files.name, 'MasterPlate_', 12)).name}; - isempty(mpFiles) && throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory')) + if isempty(mpFiles) + throw (MException('MATLAB:dir', 'No MasterPlate_ files in directory')); + end % this sorts by date (newest first) [~, sortedIndices]=sort(datenum({files(strncmp(mpFiles.name, 'MasterPlate_', 12)).date}), 'descend'); sortedFiles=mpFiles{sortedIndices}; @@ -182,7 +188,9 @@ if ~exist(drugMediaFile, 'file') || isempty(drugMediaFile) % Try to find the DrugMedia file automatically (newest created first) files=dir(matDir) dmFiles={files(strncmp(files.name, 'DrugMedia_', 10)).name}; - isempty(dmFiles) && throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory')) + if isempty(dmFiles) + throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory')); + end % this sorts by date (newest first) [~, sortedIndices]=sort(datenum({files(strncmp(dmFiles.name, 'DrugMedia_', 10)).date}), 'descend'); sortedFiles=dmFiles{sortedIndices}; @@ -204,7 +212,9 @@ if ~exist(drugMediaFile, 'file') || isempty(drugMediaFile) dirToScan=uigetdir(); files=dir(dirToScan) dmFiles={files(strncmp(files.name, 'DrugMedia_', 10)).name}; - isempty(dmFiles) && throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory')) + if isempty(dmFiles) + throw (MException('MATLAB:dir', 'No DrugMedia_ files in directory')); + end % this sorts by date (newest first) [~, sortedIndices]=sort(datenum({files(strncmp(dmFiles.name, 'DrugMedia_', 10)).date}), 'descend'); sortedFiles=dmFiles{sortedIndices};