From fe9b338324735f6a86c7e761d9e19ff690b9557f Mon Sep 17 00:00:00 2001 From: Bryan Roessler Date: Tue, 30 Jul 2024 12:29:13 -0400 Subject: [PATCH] More EASYconsole work --- workflow/apps/matlab/easy/DMPexcel2mat.m | 1 - workflow/apps/matlab/easy/EASYconsole.m | 10 +- .../apps/matlab/ezview/EZinterAgingDev0.m | 212 +++++++-------- workflow/apps/matlab/ezview/EZvInitLoad.m | 20 +- workflow/apps/matlab/ezview/EZviewGui.m | 7 +- workflow/qhtcp-workflow | 256 +++++++++--------- 6 files changed, 263 insertions(+), 243 deletions(-) diff --git a/workflow/apps/matlab/easy/DMPexcel2mat.m b/workflow/apps/matlab/easy/DMPexcel2mat.m index 87a5f7c0..0c3ea837 100755 --- a/workflow/apps/matlab/easy/DMPexcel2mat.m +++ b/workflow/apps/matlab/easy/DMPexcel2mat.m @@ -196,7 +196,6 @@ if ~exist(drugMediaFile, 'file') || isempty(drugMediaFile) sortedFiles=dmFiles{sortedIndices}; drugMediaFile=sortedFiles{1}; fprintf('Using newest DrugMedia file: %s, skipping directory selection\n', drugMediaFile); - end catch Me % This can be silent, not really an error diff --git a/workflow/apps/matlab/easy/EASYconsole.m b/workflow/apps/matlab/easy/EASYconsole.m index 5a4d1ecc..c0d9ba88 100644 --- a/workflow/apps/matlab/easy/EASYconsole.m +++ b/workflow/apps/matlab/easy/EASYconsole.m @@ -65,10 +65,10 @@ function varargout = EASYconsole(varargin) fprintf('WARNING: Running in standalone mode without PROJECT or PROJECT_SCANS_DIR environment variables (not recommended)\n'); fprintf('Beginning parent scans directory search\n'); dirsToScan={ - fullfile(parentDir, '..', '..', 'scans'), - fullfile(parentDir, '..', '..', 'ExpJobs'), - fullfile('mnt','data','scans'), - fullfile('mnt','data', 'ExpJobs'), + fullfile(parentDir, '..', '..', 'scans') + fullfile(parentDir, '..', '..', 'ExpJobs') + fullfile('mnt','data','scans') + fullfile('mnt','data', 'ExpJobs') fullfile(parentDir, '..', '..', 'templates', 'scans-demo') }; for i=1:length(dirsToScan) @@ -78,7 +78,7 @@ function varargout = EASYconsole(varargin) pattern='^\d{6}_.*_.*'; matchedDirs={dirs(regexp(subDirs.name, pattern)).name}; if ~isempty(matchedDirs) - fprintf('Found a non-empty scans directory in our list: %s\n', char(d); + fprintf('Found a non-empty scans directory in our list: %s\n', char(d)); fprintf('Setting scansDir to %s\n', char(d)); scansDir=fullfile(d); end diff --git a/workflow/apps/matlab/ezview/EZinterAgingDev0.m b/workflow/apps/matlab/ezview/EZinterAgingDev0.m index 40fee1da..ec469cbb 100755 --- a/workflow/apps/matlab/ezview/EZinterAgingDev0.m +++ b/workflow/apps/matlab/ezview/EZinterAgingDev0.m @@ -6,7 +6,7 @@ function EZinterAgingDev0 AgMPDM=load(fullfile(scansDir,'MasterPlateFiles','MPDMmat.mat')); for i=1:size(openExpfile,2) - ExpOutmat{i}= fullfile(scansDir,openExpfile{i}); + ExpOutmat{i}=fullfile(scansDir,openExpfile{i}); EScan{i}=load(ExpOutmat{1}); end @@ -29,20 +29,20 @@ function EZinterAgingDev0 defaultanswer={'80','60','1','N','39','Y'}; answer=inputdlg(prompt,name,numlines,defaultanswer); - negPercent= str2double(cell2mat(answer(1))); - posPercent= str2double(cell2mat(answer(2))); - DMstr= cell2mat(answer(3)); + negPercent=str2double(cell2mat(answer(1))); + posPercent=str2double(cell2mat(answer(2))); + DMstr=cell2mat(answer(3)); DMcomas=strfind((cell2mat(answer(3))),','); - removInfinL= answer(4); - numBins= str2double(cell2mat(answer(5))); - subplotX= answer(6); - % expN= str2double(cell2mat(answer(7))); + removInfinL=answer(4); + numBins=str2double(cell2mat(answer(5))); + subplotX=answer(6); + % expN=str2double(cell2mat(answer(7))); n=0; - for i= DMcomas, + for i=DMcomas, n=n+1 - DMsel(n)= str2double(DMstr(i-1:i)) - if i== max(DMcomas) - DMsel(n+1)= str2double(DMstr(i:end)) + DMsel(n)=str2double(DMstr(i-1:i)) + if i==max(DMcomas) + DMsel(n+1)=str2double(DMstr(i:end)) end end @@ -57,46 +57,46 @@ function EZinterAgingDev0 for m=1:mpN scnN=j + (dmN*(m-1)) % 1,6,11..; 2,7,12 ..; 3,8,13..; Xn{m,j,:}=Exp(expN).scan(scnN).plate(1).CFout(:,5); % Exp(expN).scan(DM{j}(m)).plate(1).CFout(:,5); - Xn{m,j,:}(Xn{m,j,:}==0)= 140; + Xn{m,j,:}(Xn{m,j,:}==0)=140; Xln{m,j,:}=Exp(expN).scan(scnN).plate(1).CFout(:,11); % Exp(expN).scan(DM{j}(m)).plate(1).CFout(:,11); Xhn{m,j,:}=Exp(expN).scan(scnN).plate(1).CFout(:,12); % Exp(expN).scan(DM{j}(m)).plate(1).CFout(:,12); - intL{m,j,:} = (Xn{m,j,:} - Rn(j)); - intL{m,j,:}(Xn{m,j,:}==140)= 100; - intLhw{m,j,:} = ((Xn{m,1,:}-Xn{m,j,:}) - Rn(1)-Rn(j)); - intLhw{m,j,:}(Xn{m,j,:}==140)= 100; - deltaXR{m,j}(Xn{m,j} >=(Rn(j)+Rs(j)))= ( Xln{m,j}(Xn{m,j} >=(Rn(j)+Rs(j))))- (Rn(j)+Rs(j)); - deltaXR{m,j}(Xn{m,j} < (Rn(j)-Rs(j)))= ( Xhn{m,j}(Xn{m,j} < (Rn(j)-Rs(j))))- (Rn(j)-Rs(j)); - Xneg= Xhn{m,j}- (Rn(j)-Rs(j)); - Xpos= Xln{m,j}- (Rn(j)+Rs(j)); - deltaXR{m,j}= zeros(1,384); + intL{m,j,:}=(Xn{m,j,:} - Rn(j)); + intL{m,j,:}(Xn{m,j,:}==140)=100; + intLhw{m,j,:}=((Xn{m,1,:}-Xn{m,j,:}) - Rn(1)-Rn(j)); + intLhw{m,j,:}(Xn{m,j,:}==140)=100; + deltaXR{m,j}(Xn{m,j} >=(Rn(j)+Rs(j)))=( Xln{m,j}(Xn{m,j} >=(Rn(j)+Rs(j))))- (Rn(j)+Rs(j)); + deltaXR{m,j}(Xn{m,j} < (Rn(j)-Rs(j)))=( Xhn{m,j}(Xn{m,j} < (Rn(j)-Rs(j))))- (Rn(j)-Rs(j)); + Xneg=Xhn{m,j}- (Rn(j)-Rs(j)); + Xpos=Xln{m,j}- (Rn(j)+Rs(j)); + deltaXR{m,j}=zeros(1,384); - for i=1:length(Xpos(:)), - % deltaXR{m,j}(i)= Xpos(i); + for i=1:length(Xpos(:)) + % deltaXR{m,j}(i)=Xpos(i); if deltaXR{m,j}(i)==0 try - if abs(Xpos(i))abs(Xneg(i)), deltaXR{m,j}(i)= Xneg(i); end + if abs(Xpos(i))>abs(Xneg(i)), deltaXR{m,j}(i)=Xneg(i); end catch end end - deltaXR{m,j,:}(Xln{m,j,:}==0)= 100; - deltaXR{m,j,:}(isnan(Xln{m,j,:}))= 120; - deltaXR{m,j,:}(Xhn{m,j,:}==0)= 100; - deltaXR{m,j,:}(isnan(Xhn{m,j,:}))= 120; + deltaXR{m,j,:}(Xln{m,j,:}==0)=100; + deltaXR{m,j,:}(isnan(Xln{m,j,:}))=120; + deltaXR{m,j,:}(Xhn{m,j,:}==0)=100; + deltaXR{m,j,:}(isnan(Xhn{m,j,:}))=120; % Compile all gene related L values for the each pert-DM (j). addend=(1+((m-1)*384)) % ((((m-1)*j)*384)+1); - intLcmp(addend:addend+383,j)= cell2mat(intL(m,j,:)); % ((addend:addend+383),j)= cell2mat(intL(j,m,:)); - intLadjcmp(addend:addend+383,j)= cell2mat(deltaXR(m,j,:)); % ((addend:addend+383),j)= cell2mat(deltaXR(j,m,:)); + intLcmp(addend:addend+383,j)=cell2mat(intL(m,j,:)); % ((addend:addend+383),j)=cell2mat(intL(j,m,:)); + intLadjcmp(addend:addend+383,j)=cell2mat(deltaXR(m,j,:)); % ((addend:addend+383),j)=cell2mat(deltaXR(j,m,:)); end % Remove RFs and Blank (or non annotated ' ') orf data Then % Filter data per user intput @@ -120,13 +120,13 @@ function EZinterAgingDev0 centNegCnt=round(negPercent/100 * length(intLcmpSortLT0)); intLposSel{j}=intLwoRFsorted{j}((length(intLcmpSortLT0)+centPosCnt): end,:); intLnegSel{j}=intLwoRFsorted{j}((1:(length(intLcmpSortLT0)-centNegCnt)),:); - posIntboundryCentralVal(j)= intLcmpSortGT0((centPosCnt),:); % For Histogram use - negIntboundryCentralVal(j)= intLcmpSortLT0(((length(intLcmpSortLT0))-(centNegCnt)),:); % For Histogram use + posIntboundryCentralVal(j)=intLcmpSortGT0((centPosCnt),:); % For Histogram use + negIntboundryCentralVal(j)=intLcmpSortLT0(((length(intLcmpSortLT0))-(centNegCnt)),:); % For Histogram use % Find potential Interactors within selected range if j==DMsel(1) % Intc1, - InterslstPos{1}= intLposSel{DMsel(1)}(:,2) % intLcmpposInd{Intc1} - InterslstNeg{1}= intLnegSel{DMsel(1)}(:,2) % intLcmpnegInd{Intc1} + InterslstPos{1}=intLposSel{DMsel(1)}(:,2) % intLcmpposInd{Intc1} + InterslstNeg{1}=intLnegSel{DMsel(1)}(:,2) % intLcmpnegInd{Intc1} elseif sum(ismember(DMsel,j))==1 %Intc1 && j<=IntcLst InterslstPos{1}=(intersect(InterslstPos{1},intLposSel{j}(:,2))); % ,intLcmpposInd{j})) InterslstNeg{1}=(intersect(InterslstNeg{1},intLnegSel{j}(:,2))); % ,intLcmpnegInd{j})) @@ -137,28 +137,28 @@ function EZinterAgingDev0 intLposDIndx{j}(:,2)=ceil((intLposSel{j}(:,2))/384); % mp plate numb column intLposDIndx{j}(:,3)=(rem(intLposSel{j}(:,2),384)); nn=(intLposDIndx{j}(:,3)==0); - intLposDIndx{j}(nn,3)= 384; - intLposDIndx{j}(:,1)= j + (dmN*((intLposDIndx{j}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); + intLposDIndx{j}(nn,3)=384; + intLposDIndx{j}(:,1)=j + (dmN*((intLposDIndx{j}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); intLnegDIndx{j}(:,2)=ceil((intLnegSel{j}(:,2))/384); % mp plate numb column intLnegDIndx{j}(:,3)=(rem(intLnegSel{j}(:,2),384)); nn=(intLposDIndx{j}(:,3)==0); - intLnegDIndx{j}(nn,3)= 384; - intLnegDIndx{j}(:,1)= j + (dmN*((intLnegDIndx{j}(:,2))-1)); % scan numb + intLnegDIndx{j}(nn,3)=384; + intLnegDIndx{j}(:,1)=j + (dmN*((intLnegDIndx{j}(:,2))-1)); % scan numb % ADJUSTED L for Reference Standard deviation(More conservative) Interaction List compilation intLadjwoRFs{j}(1,:)=intLadjcmp(Exp(expN).mutSpotIndx.woRFs,j); - intLadjwoRFs{j}(2,:)= Exp(expN).mutSpotIndx.woRFs; % intLadjcmp(385:(mpN-1)*384,j); %intLadjcmp(Exp(expN).mutSpotIndx.woRFs,j); + intLadjwoRFs{j}(2,:)=Exp(expN).mutSpotIndx.woRFs; % intLadjcmp(385:(mpN-1)*384,j); %intLadjcmp(Exp(expN).mutSpotIndx.woRFs,j); if strcmpi(removInfinL,'Y') - intLadjwoRFs0{j}(1,:)= intLadjwoRFs{j}(1,(intLadjwoRFs{j}(1,:)~= 100)) ; %intLcmp(Exp(1).mutSpotIndx.woRFs,j); - intLadjwoRFs0{j}(2,:)= intLadjwoRFs{j}(2,(intLadjwoRFs{j}(1,:)~= 100)) ; % Remove Index where spots are infinite (=100); + intLadjwoRFs0{j}(1,:)=intLadjwoRFs{j}(1,(intLadjwoRFs{j}(1,:)~=100)) ; %intLcmp(Exp(1).mutSpotIndx.woRFs,j); + intLadjwoRFs0{j}(2,:)=intLadjwoRFs{j}(2,(intLadjwoRFs{j}(1,:)~=100)) ; % Remove Index where spots are infinite (=100); clear intLadjwoRFs - intLadjwoRFs{j}(1,:)= intLadjwoRFs0{j}(1,:); - intLadjwoRFs{j}(2,:)= intLadjwoRFs0{j}(2,:); + intLadjwoRFs{j}(1,:)=intLadjwoRFs0{j}(1,:); + intLadjwoRFs{j}(2,:)=intLadjwoRFs0{j}(2,:); end - intLwoRFsortedAdj{j}= sortrows(intLadjwoRFs{j}',1); + intLwoRFsortedAdj{j}=sortrows(intLadjwoRFs{j}',1); clear intLadjSortGT0 intLadjSortLT0 tempIntLadj=intLwoRFsortedAdj{j}(:,1); intLadjSortGT0=tempIntLadj((tempIntLadj) >=0); @@ -171,8 +171,8 @@ function EZinterAgingDev0 negIntboundryCentralValAdj(j)=intLadjSortLT0(((length(intLadjSortLT0))-(centNegCntAdj)),:); if j==DMsel(1) % Intc1 - InterslstPosAdj{1}= intLposSelAdj{DMsel(1)}(:,2) % intLcmpposInd{Intc1} - InterslstNegAdj{1}= intLnegSelAdj{DMsel(1)}(:,2) % intLcmpnegInd{Intc1} + InterslstPosAdj{1}=intLposSelAdj{DMsel(1)}(:,2) % intLcmpposInd{Intc1} + InterslstNegAdj{1}=intLnegSelAdj{DMsel(1)}(:,2) % intLcmpnegInd{Intc1} elseif sum(ismember(DMsel,j))==1 % j>Intc1 && j<=IntcLst InterslstPosAdj{1}=(intersect(InterslstPosAdj{1},intLposSelAdj{j}(:,2))); % ,intLcmpposInd{j})) InterslstNegAdj{1}=(intersect(InterslstNegAdj{1},intLnegSelAdj{j}(:,2))); % ,intLcmpnegInd{j})) @@ -183,14 +183,14 @@ function EZinterAgingDev0 intLposDIndxAdj{j}(:,2)=ceil((intLposSelAdj{j}(:,2))/384); % mp plate numb column intLposDIndxAdj{j}(:,3)=(rem(intLposSelAdj{j}(:,2),384)); nn=(intLposDIndxAdj{j}(:,3)==0); - intLposDIndx{j}(nn,3)= 384; - intLposDIndxAdj{j}(:,1)= j + (dmN*((intLposDIndxAdj{j}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); + intLposDIndx{j}(nn,3)=384; + intLposDIndxAdj{j}(:,1)=j + (dmN*((intLposDIndxAdj{j}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); intLnegDIndxAdj{j}(:,2)=ceil((intLnegSelAdj{j}(:,2))/384); % mp plate numb column intLnegDIndxAdj{j}(:,3)=(rem(intLnegSelAdj{j}(:,2),384)); nn=(intLposDIndxAdj{j}(:,3)==0); - intLnegDIndxAdj{j}(nn,3)= 384; - intLnegDIndxAdj{j}(:,1)= j + (dmN*((intLnegDIndxAdj{j}(:,2))-1)); % scan numb + intLnegDIndxAdj{j}(nn,3)=384; + intLnegDIndxAdj{j}(:,1)=j + (dmN*((intLnegDIndxAdj{j}(:,2))-1)); % scan numb end % Get interaction values for each DM drugmedia agar type @@ -199,56 +199,56 @@ function EZinterAgingDev0 IntersValsPosAdj=intLadjcmp(InterslstPosAdj{1},DMsel); IntersValsNegAdj=intLadjcmp(InterslstNegAdj{1},DMsel); - %Build 'genelist' data sheet for interactors + % Build 'genelist' data sheet for interactors selIntPx{1}(:,6)=InterslstPos{1}; selIntPx{1}(:,2)=ceil((InterslstPos{1})/384); % mp plate numb column selIntPx{1}(:,3)=(rem(InterslstPos{1},384)); nn=(selIntPx{1}(:,3)==0); - selIntPx{1}(nn,3)= 384; - selIntPx{1}(:,4)= ceil(selIntPx{1}(:,3)/24); % row numb - selIntPx{1}(:,5)= rem(selIntPx{1}(:,3),24); + selIntPx{1}(nn,3)=384; + selIntPx{1}(:,4)=ceil(selIntPx{1}(:,3)/24); % row numb + selIntPx{1}(:,5)=rem(selIntPx{1}(:,3),24); mm=(selIntPx{1}(:,5)==0); - selIntPx{1}(mm,5)= 24; - selIntPx{1}(:,1)= j + (dmN*((selIntPx{1}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); - selIntP= cell2mat(selIntPx); + selIntPx{1}(mm,5)=24; + selIntPx{1}(:,1)=j + (dmN*((selIntPx{1}(:,2))-1)); % scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); + selIntP=cell2mat(selIntPx); selIntNx{1}(:,6)=InterslstNeg{1}; selIntNx{1}(:,2)=ceil((InterslstNeg{1})/384); % mp plate numb column selIntNx{1}(:,3)=(rem(InterslstNeg{1},384)); nn=(selIntNx{1}(:,3)==0); - selIntNx{1}(nn,3)= 384; - selIntNx{1}(:,4)= ceil(selIntNx{1}(:,3)/24); % row numb - selIntNx{1}(:,5)= rem(selIntNx{1}(:,3),24); + selIntNx{1}(nn,3)=384; + selIntNx{1}(:,4)=ceil(selIntNx{1}(:,3)/24); % row numb + selIntNx{1}(:,5)=rem(selIntNx{1}(:,3),24); mm=(selIntNx{1}(:,5)==0); - selIntNx{1}(mm,5)= 24; - selIntNx{1}(:,1)= j + (dmN*((selIntNx{1}(:,2))-1)); % scan numb - selIntN= cell2mat(selIntNx); + selIntNx{1}(mm,5)=24; + selIntNx{1}(:,1)=j + (dmN*((selIntNx{1}(:,2))-1)); % scan numb + selIntN=cell2mat(selIntNx); for i=1:size(selIntP,1) IPgene(i)=Exp(expN).MP(selIntP(i,2)).genename{1}(selIntP(i,3)); - IPorf(i)= Exp(expN).MP(selIntP(i,2)).orf{1}(selIntP(i,3)); - IPstrain(i)= Exp(expN).MP(selIntP(i,2)).strain{1}(selIntP(i,3)); + IPorf(i)=Exp(expN).MP(selIntP(i,2)).orf{1}(selIntP(i,3)); + IPstrain(i)=Exp(expN).MP(selIntP(i,2)).strain{1}(selIntP(i,3)); IPspecifics(i)=Exp(expN).MP(selIntP(i,2)).specifics{1}(selIntP(i,3)); IPorfRep(i)=Exp(expN).MP(selIntP(i,2)).orfRep{1}(selIntP(i,3)); % Bad this is the L data for only the last selected DM perturbation % Would need to calculate each scan# for each DMsel value - ipL(i)= Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),5); - ipLlower(i)= Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),11); - ipLupper(i)= Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),12); + ipL(i)=Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),5); + ipLlower(i)=Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),11); + ipLupper(i)=Exp(expN).scan(selIntP(i,1)).plate(1).CFout(selIntP(i,3),12); end for i=1:size(selIntN,1) INgene(i)=Exp(expN).MP(selIntN(i,2)).genename{1}(selIntN(i,3)); - INorf(i)= Exp(expN).MP(selIntN(i,2)).orf{1}(selIntN(i,3)); - INstrain(i)= Exp(expN).MP(selIntN(i,2)).strain{1}(selIntN(i,3)); + INorf(i)=Exp(expN).MP(selIntN(i,2)).orf{1}(selIntN(i,3)); + INstrain(i)=Exp(expN).MP(selIntN(i,2)).strain{1}(selIntN(i,3)); INspecifics(i)=Exp(expN).MP(selIntN(i,2)).specifics{1}(selIntN(i,3)); INorfRep(i)=Exp(expN).MP(selIntN(i,2)).orfRep{1}(selIntN(i,3)); % Bad this is the L data for only the last selected DM perturbation % Would need to calculate each scan# for each DMsel value - inL(i)= Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),5); - inLlower(i)= Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),11); - inLupper(i)= Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),12); + inL(i)=Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),5); + inLlower(i)=Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),11); + inLupper(i)=Exp(expN).scan(selIntN(i,1)).plate(1).CFout(selIntN(i,3),12); end % ADJUSTED with STD and curve fit boundaries to produce more conservative interaction values @@ -256,48 +256,48 @@ function EZinterAgingDev0 selIntPxAdj{1}(:,2)=ceil((InterslstPosAdj{1})/384); %mp plate numb column selIntPxAdj{1}(:,3)=(rem(InterslstPosAdj{1},384)); nn=(selIntPxAdj{1}(:,3)==0); - selIntPxAdj{1}(nn,3)= 384; - selIntPxAdj{1}(:,4)= ceil(selIntPxAdj{1}(:,3)/24); %row numb - selIntPxAdj{1}(:,5)= rem(selIntPxAdj{1}(:,3),24); + selIntPxAdj{1}(nn,3)=384; + selIntPxAdj{1}(:,4)=ceil(selIntPxAdj{1}(:,3)/24); %row numb + selIntPxAdj{1}(:,5)=rem(selIntPxAdj{1}(:,3),24); mm=(selIntPxAdj{1}(:,5)==0); - selIntPxAdj{1}(mm,5)= 24; - selIntPxAdj{1}(:,1)= j + (dmN*((selIntPxAdj{1}(:,2))-1)); %scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); - selIntPAdj= cell2mat(selIntPxAdj); + selIntPxAdj{1}(mm,5)=24; + selIntPxAdj{1}(:,1)=j + (dmN*((selIntPxAdj{1}(:,2))-1)); %scan numb column %intLposDIndx(:,2)* intLposDIndx(:,3); + selIntPAdj=cell2mat(selIntPxAdj); selIntNxAdj{1}(:,2)=ceil((InterslstNegAdj{1})/384); %mp plate numb column selIntNxAdj{1}(:,3)=(rem(InterslstNegAdj{1},384)); nn=(selIntNxAdj{1}(:,3)==0); - selIntNxAdj{1}(nn,3)= 384; - selIntNxAdj{1}(:,4)= ceil(selIntNxAdj{1}(:,3)/24); %row numb - selIntNxAdj{1}(:,5)= rem(selIntNxAdj{1}(:,3),24); + selIntNxAdj{1}(nn,3)=384; + selIntNxAdj{1}(:,4)=ceil(selIntNxAdj{1}(:,3)/24); %row numb + selIntNxAdj{1}(:,5)=rem(selIntNxAdj{1}(:,3),24); mm=(selIntNxAdj{1}(:,5)==0); - selIntNxAdj{1}(mm,5)= 24; - selIntNxAdj{1}(:,1)= j + (dmN*((selIntNxAdj{1}(:,2))-1)); %scan numb - selIntNAdj= cell2mat(selIntNxAdj); + selIntNxAdj{1}(mm,5)=24; + selIntNxAdj{1}(:,1)=j + (dmN*((selIntNxAdj{1}(:,2))-1)); %scan numb + selIntNAdj=cell2mat(selIntNxAdj); for i=1:size(selIntPAdj,1) IPgeneAdj(i)=Exp(expN).MP(selIntPAdj(i,2)).genename{1}(selIntPAdj(i,3)); - IPorfAdj(i)= Exp(expN).MP(selIntPAdj(i,2)).orf{1}(selIntPAdj(i,3)); - IPstrainAdj(i)= Exp(expN).MP(selIntPAdj(i,2)).strain{1}(selIntPAdj(i,3)); + IPorfAdj(i)=Exp(expN).MP(selIntPAdj(i,2)).orf{1}(selIntPAdj(i,3)); + IPstrainAdj(i)=Exp(expN).MP(selIntPAdj(i,2)).strain{1}(selIntPAdj(i,3)); IPspecificsAdj(i)=Exp(expN).MP(selIntPAdj(i,2)).specifics{1}(selIntPAdj(i,3)); IPorfRepAdj(i)=Exp(expN).MP(selIntPAdj(i,2)).orfRep{1}(selIntPAdj(i,3)); % Bad this is the L data for only the last selected DM perturbation % Would need to calculate each scan# for each DMsel value - ipLAdj(i)= Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),5); - ipLlowerAdj(i)= Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),11); - ipLupperAdj(i)= Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),12); + ipLAdj(i)=Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),5); + ipLlowerAdj(i)=Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),11); + ipLupperAdj(i)=Exp(expN).scan(selIntPAdj(i,1)).plate(1).CFout(selIntPAdj(i,3),12); end for i=1:size(selIntNAdj,1) INgeneAdj(i)=Exp(expN).MP(selIntNAdj(i,2)).genename{1}(selIntNAdj(i,3)); - INorfAdj(i)= Exp(expN).MP(selIntNAdj(i,2)).orf{1}(selIntNAdj(i,3)); - INstrainAdj(i)= Exp(expN).MP(selIntNAdj(i,2)).strain{1}(selIntNAdj(i,3)); + INorfAdj(i)=Exp(expN).MP(selIntNAdj(i,2)).orf{1}(selIntNAdj(i,3)); + INstrainAdj(i)=Exp(expN).MP(selIntNAdj(i,2)).strain{1}(selIntNAdj(i,3)); INspecificsAdj(i)=Exp(expN).MP(selIntNAdj(i,2)).specifics{1}(selIntNAdj(i,3)); INorfRepAdj(i)=Exp(expN).MP(selIntNAdj(i,2)).orfRep{1}(selIntNAdj(i,3)); %Bad this is the L data for only the last selected DM perturbation %Would need to calculate each scan# for each DMsel value - inLAdj(i)= Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),5); - inLlowerAdj(i)= Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),11); - inLupperAdj(i)= Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),12); + inLAdj(i)=Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),5); + inLlowerAdj(i)=Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),11); + inLupperAdj(i)=Exp(expN).scan(selIntNAdj(i,1)).plate(1).CFout(selIntNAdj(i,3),12); end @@ -306,11 +306,11 @@ function EZinterAgingDev0 figure if strcmpi(subplotX,'Y') for j=1:dmN - histLdata= intLwoRFsorted{j}(:,1); % intLcmp(385:(mpN-1)*384,j); + histLdata=intLwoRFsorted{j}(:,1); % intLcmp(385:(mpN-1)*384,j); % histLadjData=intLadjcmp(385:(mpN-1)*384,j); hgLdat{j}=histfitJR(histLdata,numBins,'kernel'); - x{j}= get(hgLdat{j}(2),'xdata'); - y{j}= get(hgLdat{j}(2),'ydata'); + x{j}=get(hgLdat{j}(2),'xdata'); + y{j}=get(hgLdat{j}(2),'ydata'); xb{j}=get(hgLdat{j}(1),'xdata'); yb{j}=get(hgLdat{j}(1),'ydata'); ybpostot{j}=sum(yb{j}(2,(xb{j}(1,:)>=0))); @@ -329,20 +329,20 @@ function EZinterAgingDev0 hold off end scnsize=get(0,'screensize') - pos1= [round(scnsize(3)/40), round(scnsize(4)/2 +(scnsize(3)/80)),... + pos1=[round(scnsize(3)/40), round(scnsize(4)/2 +(scnsize(3)/80)),... round(scnsize(3) -round(scnsize(3)/80)),round(scnsize(4)/2 -round(scnsize(4)/80))] set(gcf,'outerposition',pos1) set(gcf,'Name', 'Interaction Values '); figure for j=1:dmN - histLadjData= intLwoRFsortedAdj{j}(:,1); %intLadjcmp(385:(mpN-1)*384,j); + histLadjData=intLwoRFsortedAdj{j}(:,1); %intLadjcmp(385:(mpN-1)*384,j); hgLadj{j}=subplot(2, 4, j),histfitJR(histLadjData,numBins,'kernel') ; hold %hgLadj{j}=histfit(intLadjcmp(:,j),31,'kernel') subplot(2, 4, j),plot(posIntboundryCentralValAdj(j), 1:3000,'--r') subplot(2, 4, j),plot(negIntboundryCentralValAdj(j), 1:3000,'--g') hold off end - pos2= [round(scnsize(3)/40), round(scnsize(4)/30),... + pos2=[round(scnsize(3)/40), round(scnsize(4)/30),... round(scnsize(3) -scnsize(3)/80),round(scnsize(4)/2 -scnsize(4)/80)] set(gcf,'outerposition',pos2) set(gcf,'Name', 'Interaction Compensated by Standard Deviation and Upper/Lower Curvefit boundaries') @@ -360,8 +360,8 @@ function EZinterAgingDev0 plot(posIntboundryCentralValAdj(j), 1:3000,'--r') plot(negIntboundryCentralValAdj(j), 1:3000,'--g') hold off - x{j}= get(hgL{j}(2),'xdata') - y{j}= get(hgL{j}(2),'ydata'); + x{j}=get(hgL{j}(2),'xdata') + y{j}=get(hgL{j}(2),'ydata'); xb{j}=get(hgL{j}(1),'xdata') yb{j}=get(hgL{j}(1),'ydata') ybpostot{j}=sum(yb{j}(2,(xb{j}(1,:)>=0))) diff --git a/workflow/apps/matlab/ezview/EZvInitLoad.m b/workflow/apps/matlab/ezview/EZvInitLoad.m index f0a19695..30a4f758 100755 --- a/workflow/apps/matlab/ezview/EZvInitLoad.m +++ b/workflow/apps/matlab/ezview/EZvInitLoad.m @@ -5,6 +5,7 @@ global Expbb global userPars global usrExpJobsDir global zonePB +global mpdmFile % Initialize some variables from matlab ezPath=which(mfilename); @@ -22,7 +23,8 @@ end % Set scansDir (project scans directory) intelligently if exist('PROJECT', 'var') && ~isempty(getenv('PROJECT')) - scansDir=getenv('PROJECT'); + project=getenv('PROJECT'); + fprintf('Using project path: %s from environment variable PROJECT\n', scansDir); disp('This usually indicates that we are in standalone mode'); elseif exist('PROJECT_SCANS_DIR', 'var') && ~isempty(getenv('PROJECT_SCANS_DIR')) @@ -76,6 +78,19 @@ else fprintf('Using EZview script directory: %s from hardcoded default\n', ezDir); end +% Allow module to override hardcoded default EASY directory +if exist('EASY_DIR','var') && ~isempty(getenv('EASY_DIR')) + EASY_DIR=fullfile(getenv('EASY_DIR')); + if ~strcmp(easyDir, EASY_DIR) % sanity check + disp("WARNING: EASY_DIR does not match this script's hardcoded EASY location"); + disp("This is probably OK but if strange beahvior arises, we'll need to fix it in code"); + easyDir=EASY_DIR; + end + fprintf('Using EASY script directory: %s from environment variable EASY_DIR\n', easyDir); +else + fprintf('Using EASY script directory: %s from hardcoded default\n', easyDir); +end + userPars.BPdefault={'on','on','0.3','8','45','1000'}; userPars.boxplotFlg=1; userPars.BPoutliers='On'; @@ -90,9 +105,6 @@ userPars.kfiltLim=str2double(userPars.BPdefault(6)); - - - % Generate the Exp arrays numExps=3; for i=1:numExps diff --git a/workflow/apps/matlab/ezview/EZviewGui.m b/workflow/apps/matlab/ezview/EZviewGui.m index 0fa418e2..155fe371 100755 --- a/workflow/apps/matlab/ezview/EZviewGui.m +++ b/workflow/apps/matlab/ezview/EZviewGui.m @@ -20,11 +20,6 @@ function varargout = EZviewGui(varargin) % % See also: GUIDE, GUIDATA, GUIHANDLES - - - - - gui_Singleton = 0; gui_State = struct( ... 'gui_Name', mfilename, ... @@ -66,7 +61,7 @@ function EZviewGui_OpeningFcn(hObject, eventdata, handles, varargin) % so window can get raised using EZviewGui. if strcmp(get(hObject,'Visible'),'off') - %plot(rand(5)); + %plot(rand(5)); end % Special disabling of version for this later install of Matlab 2011a: diff --git a/workflow/qhtcp-workflow b/workflow/qhtcp-workflow index 0815bbaa..215caa07 100755 --- a/workflow/qhtcp-workflow +++ b/workflow/qhtcp-workflow @@ -586,32 +586,21 @@ easy() { # TODO will need to play with the -sd startup option to see what works (well) # Skip this step altogether in auto mode since it requires graphical interaction if ! ((YES)) && ask "Start EASY in MATLAB? This requires a GUI."; then - export PROJECT_SCANS_DIR PROJECT_DATE EASY_DIR PROJECT_USER EASY_NAME EASY_SUFFIX EASY_RESULTS_DIR MASTER_PLATE_FILE DRUG_MEDIA_FILE - echo "Hit enter to use the default EASY results directory $PROJECT_SCANS_DIR/Results_${PROJECT_PREFIX}_($PROJECT_SUFFIX)" - (( YES )) || read -r -p "Or enter a custom suffix: " suffix - EASY_RESULTS_DIR="$PROJECT_SCANS_DIR/Results_${PROJECT_PREFIX}_${suffix:-$PROJECT_SUFFIX}" - while [[ -d $EASY_RESULTS_DIR ]]; do - count=1 - if [[ $count -eq 1 ]] && ask "$EASY_RESULTS_DIR already exists, increment dir name (y) or overwrite (N)?"; then - EASY_SUFFIX="${suffix:-$PROJECT_SUFFIX}.$((count++))" - EASY_RESULTS_DIR="$PROJECT_SCANS_DIR/Results_${PROJECT_PREFIX}_${EASY_SUFFIX}" - else - EASY_SUFFIX=${suffix:-$PROJECT_SUFFIX} - fi - done - EASY_SUFFIX=${EASY_SUFFIX:-$suffix:-$PROJECT_SUFFIX} - EASY_NAME="${PROJECT_PREFIX}_${EASY_SUFFIX}" - EASY_RESULTS_DIR="$PROJECT_SCANS_DIR/Results_$EASY_NAME" - [[ -d $PROJECT_SCANS_DIR/MasterPlateFiles ]] || mkdir -p "$PROJECT_SCANS_DIR/MasterPlateFiles" - DRUG_MEDIA_FILE="$PROJECT_SCANS_DIR/MasterPlateFiles/DrugMedia_$PROJECT.xls" - MASTER_PLATE_FILE="$PROJECT_SCANS_DIR/MasterPlateFiles/MasterPlate_$PROJECT.xls" + export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER PROJECT + export EASY_DIR EASY_NAME EASY_SUFFIX EASY_RESULTS_DIR + export MASTER_PLATE_FILE DRUG_MEDIA_FILE + choose_easy_results_dir + + DRUG_MEDIA_FILE="$EASY_RESULTS_DIR/DrugMedia_$PROJECT.xls" + MASTER_PLATE_FILE="$EASY_RESULTS_DIR/MasterPlate_$PROJECT.xls" # Make EASY dirs debug "mkdir -p $EASY_RESULTS_DIR" mkdir -p "$EASY_RESULTS_DIR" dirs=('PrintResults' 'CFfigs' 'Fotos' 'Fotos/BkUp' 'matResults') for d in "${dirs[@]}"; do + debug "mkdir $EASY_RESULTS_DIR/$d" mkdir "$EASY_RESULTS_DIR/$d" done @@ -619,13 +608,12 @@ easy() { rsync -a "$EASY_DIR"/{figs,Ptmats} "$EASY_RESULTS_DIR" # Launch matlab - matlab -nosplash -r "run $script" # matlab -nosplash -sd "$PROJECT_SCANS_DIR" -r "run $script" - + matlab -nosplash -r "run $script" fi # Use the function return code see if we succeeded - get_easy_results "$PROJECT_SCANS_DIR" || return 1 + scan_easy_results "$PROJECT_SCANS_DIR" || (err "No EASY results found in $PROJECT_SCANS_DIR"; return 1) } @@ -635,19 +623,17 @@ module ezview ezview() { debug "Running: ${FUNCNAME[0]}" export PROJECT_SCANS_DIR PROJECT_DATE PROJECT_USER EZVIEW_DIR + export EASY_RESULTS_DIR EZVIEW_DIR="$APPS_DIR/matlab/ezview" script="$EZVIEW_DIR/EZviewGui.m" + # Try to load EASY output dir fromENV or easy module + # Then scan for EASY results + [[ -z $EASY_RESULTS_DIR ]] && choose_easy_results_dir + # Make EZview dirs - debug "mkdir -p $EZVIEW_DIR" - - - - matlab -nosplash -r "run $script" - - echo "$EZVIEW_DIR" } @@ -714,12 +700,7 @@ module qhtcp qhtcp() { debug "Running: ${FUNCNAME[0]}" - OUT_DIR="/mnt/data/out/qhtcp" - STUDIES_ARCHIVE_FILE="$OUT_DIR/StudiesDataArchive.txt" - QHTCP_PROJECT_DIR="$OUT_DIR/$PROJECT" - QHTCP_TEMPLATE_DIR="$TEMPLATES_DIR/qhtcp" - STUDY_TEMPLATE_DIR="$TEMPLATES_DIR/exp" - STUDY_INFO_FILE="$QHTCP_PROJECT_DIR/StudyInfo.csv" + if [[ -d $QHTCP_PROJECT_DIR ]]; then echo "A project already exists at $QHTCP_PROJECT_DIR" @@ -790,27 +771,8 @@ qhtcp() { unset STUDY_DIR # Replacing ExpFrontend.m - get_easy_results "$PROJECT_SCANS_DIR" || (err "No EASY results found in $PROJECT_SCANS_DIR"; return 1) - - # Set the right results directory - # TODO eventually we could run this on multiple results dirs simultaneously with some refactoring - if ((YES)) || [[ ${#EASY_RESULTS_DIRS[@]} -eq 1 ]]; then - # In automatic mode just choose the first OUT DIR in the list - EASY_RESULT_DIR="${EASY_RESULTS_DIRS[0]}" # TODO right now just choose the frist one - else - echo "Multiple EASY results dirs found in $PROJECT_SCANS_DIR" - echo "Here is a list: " - for (( i=0; i<${#EASY_RESULTS_DIRS[@]}; i++ )); do - printf "%d. %s\n" "$((i+1))" "${EASY_RESULTS_DIRS[i]}" - done - printf "%s\n" "${EASY_RESULTS_DIRS[@]}" - read -r -p "Enter the item number to select: " response - response=$(( response - 1 )) # bash arrays use zero indexing - EASY_RESULTS_DIR="${EASY_RESULTS_DIRS[$response]}" - fi + choose_easy_results_dir - # TODO probably broken - EASY_RESULTS_FILES=("$EASY_RESULTS_DIR/"*"/PrintResults/!!"*) # Create studies archive file if missing if ! [[ -d $STUDIES_ARCHIVE_FILE ]]; then header=(StudyDate tStudyName StudyPath ExpNum ExpDate ExpPath ResultFile) @@ -823,7 +785,7 @@ qhtcp() { # Trying to match old ExpFrontend formatting printf "%s\t" \ "${DATE//_/}" "$PROJECT" "$QHTCP_PROJECT_DIR" "Exp$s" \ - "$PROJECT_DATE" "$PROJECT_SCANS_DIR" "$EASY_RESULT_DIR" "${f##*/}" \ + "$PROJECT_DATE" "$PROJECT_SCANS_DIR" "$EASY_RESULTS_DIR" "${f##*/}" \ >> "$STUDIES_ARCHIVE_FILE" done done @@ -1126,43 +1088,43 @@ r_gta_heatmaps() { -submodule mat_exp_frontend -# @description Run the ExpFrontend.m program -# This submodule: -# * Pushes into the Study template directory (ExpTemplate) -# * Prompts the user to run ExpFrontend.m -# * Pops out -# NOTES: -# * ExpFrontend.m should be or is being rewritten -mat_exp_frontend() { - debug "Running: ${FUNCNAME[0]}" - cat <<-EOF - ExpFrontend.m was made for recording into a spreadsheet - ('StudiesDataArchive.txt') the date and files used (i.e., directory paths to the - !!Results files used as input for Z-interaction script) for each multi-experiment study. +# submodule mat_exp_frontend +# # @description Run the ExpFrontend.m program +# # This submodule: +# # * Pushes into the Study template directory (ExpTemplate) +# # * Prompts the user to run ExpFrontend.m +# # * Pops out +# # NOTES: +# # * ExpFrontend.m should be or is being rewritten +# mat_exp_frontend() { +# debug "Running: ${FUNCNAME[0]}" +# cat <<-EOF +# ExpFrontend.m was made for recording into a spreadsheet +# ('StudiesDataArchive.txt') the date and files used (i.e., directory paths to the +# !!Results files used as input for Z-interaction script) for each multi-experiment study. - Run the front end MATLAB programs in the correct order (e.g., run front end in "exp1" - folder to call the !!Results file for the experiment you named as exp1 in the StudyInfo.csv file) - The GTA and pairwise, TSHeatmaps, JoinInteractions and GTF Heatmap scripts use this table - to label results and heatmaps in a meaningful way for the user and others. - The BackgroundSD and ZscoreJoinSD fields will be filled automatically according to user - specifications, at a later step in the QHTCP study process. +# Run the front end MATLAB programs in the correct order (e.g., run front end in "exp1" +# folder to call the !!Results file for the experiment you named as exp1 in the StudyInfo.csv file) +# The GTA and pairwise, TSHeatmaps, JoinInteractions and GTF Heatmap scripts use this table +# to label results and heatmaps in a meaningful way for the user and others. +# The BackgroundSD and ZscoreJoinSD fields will be filled automatically according to user +# specifications, at a later step in the QHTCP study process. - COpen MATLAB and in the application navigate to each specific /Exp folder, - call and execute ExpFrontend.m by clicking the play icon. - Use the "Open file" function from within Matlab. - Do not double-click on the file from the directory. - When prompted, navigate to the ExpJobs folder and the PrintResults folder within the correct job folder. - Repeat this for every Exp# folder depending on how many experiments are being performed. - The Exp# folder must correspond to the StudyInfo.csv created above. - EOF +# COpen MATLAB and in the application navigate to each specific /Exp folder, +# call and execute ExpFrontend.m by clicking the play icon. +# Use the "Open file" function from within Matlab. +# Do not double-click on the file from the directory. +# When prompted, navigate to the ExpJobs folder and the PrintResults folder within the correct job folder. +# Repeat this for every Exp# folder depending on how many experiments are being performed. +# The Exp# folder must correspond to the StudyInfo.csv created above. +# EOF - script="ExpFrontend.m" - if ! ((YES)) && - ask "Start MATLAB to run $script? This requires a GUI."; then - matlab -nosplash -r "$script" - fi -} +# script="ExpFrontend.m" +# if ! ((YES)) && +# ask "Start MATLAB to run $script? This requires a GUI."; then +# matlab -nosplash -r "$script" +# fi +# } submodule r_interactions @@ -1417,37 +1379,76 @@ get_studies() { } -submodule get_easy_results # lol -# @description Gets info about EASY output in the project's scans directory +submodule choose_easy_results_dir # +# @description Chooses an EASY scans directory if the information is undefined # TODO: Standardize EASY output, it's hard to understand -# @exitcode 0 if at least one results directory exists -# @exitcode 1 if no results directories exist -# @set EASY_RESULTS_DIRS array Globbed results files from PROJECT_SCANS_DIR/ -# @set EASY_RESULTS_FILES array Globbed results files from PROJECT_SCANS_DIR/ -# @arg $1 string Project scans -get_easy_results() { +# TODO eventually we could run this on multiple results dirs simultaneously with some refactoring +# @exitcode 0 if successfully choose an EASY results dir +# @set EASY_RESULTS_DIR string The working EASY output directory +choose_easy_results_dir() { debug "Running: ${FUNCNAME[0]}" - # Glob EASY output dirs - shopt -s nullglob - EASY_RESULTS_DIRS=( "$1"/Results*/ ) # TODO this is probably broken - [[ ${#EASY_RESULTS_DIRS} -ge 1 ]] || (echo "Missing EASY output"; return 1) - shopt -u nullglob + declare -g EASY_RESULTS_DIR EASY_OUT_DIR - # This section is mostly to provide some example globbing - declare -a EASY_RESULTS_ARRAY=() - for EASY_RESULTS_DIR in "${EASY_RESULTS_DIRS[@]}"; do - [[ -d $EASY_RESULTS_DIR ]] && echo "Found EASY Results directory: $EASY_RESULTS_DIR" - EASY_PRINT_RESULTS_DIR="$EASY_RESULTS_DIR/PrintResults" - [[ -d $EASY_PRINT_RESULTS_DIR ]] && echo "Found EASY PrintResults directory: $EASY_PRINT_RESULTS_DIR" - EASY_PRINT_RESULTS_FILES=( - "$EASY_PRINT_RESULTS_DIR/!!"* - "$EASY_PRINT_RESULTS_DIR"/NoGrowth_*.txt - "$EASY_PRINT_RESULTS_DIR"/GrowthOnly_*.txt - ) - EASY_RESULTS_ARRAY+=("$EASY_RESULTS_DIR" "$EASY_PRINT_RESULTS_DIR" "${EASY_PRINT_RESULTS_FILES[@]}") - done - [[ ${#EASY_RESULTS_DIRS[@]} -gt 0 ]] # TODO may need to change this to something more specific + EASY_OUT_DIR="$QHTCP_PROJECT_DIR/easy/" + + # Don't override env + if [[ -n $EASY_RESULTS_DIR && ! -d $EASY_RESULTS_DIR ]]; then + mkdir -p "$EASY_RESULTS_DIR" + return 0 + fi + + local default_easy_results_dir="$EASY_OUT_DIR/$PROJECT" + + if [[ -n $PROJECT ]]; then + if [[ ! -d $default_easy_results_dir ]]; then + EASY_RESULTS_DIR="$default_easy_results_dir" + mkdir -p "$EASY_RESULTS_DIR" + return 0 + fi + fi + + # Always backup existing output + # This would happen if you ran the same experiment twice in one day, for instance + if [[ -d $default_easy_results_dir ]] ; then + backup_dir="$default_easy_results_dir" + while [[ -d $default_easy_results_dir ]]; do + count=1 + backup_dir="$backup_dir.$((count++))" + done + echo "Backing up existing output from $default_easy_results_dir to $backup_dir" + debug "rsync -a $default_easy_results_dir $backup_dir" + rsync -a "$default_easy_results_dir" "$backup_dir" && + EASY_RESULTS_DIR="$default_easy_results_dir" + fi + + # echo "Hit enter to use the default EASY results directory: $default_easy_results_dir" + # if ! (( YES )); then + # read -r -p "Or enter a custom directory name, example: $PROJECT" dirname + # [[ -z $dirname ]] && EASY_RESULTS_DIR="$default_easy_results_dir" && return 0 + # fi + # ((YES)) && return 0 + # # Let's get a little fancy + # shopt -s nullglob + # declare -la easy_results_dirs=( "$easy_out_dir/"*/ ) + # shopt -u nullglob + # # Sort the dirs + # mapfile -t easy_results_dirs < <(printf '%s\n' "${easy_results_dirs[@]}" | sort) + # last_index=$(( ${#easy_results_dirs} - 1 )) + # ((YES)) && EASY_RESULTS_DIR="${easy_results_dirs[$last_index]}" && return 0 + # echo "Multiple EASY results dirs found in $PROJECT_SCANS_DIR" + # echo "Here is a list: " + # for i in "${!easy_results_dirs[@]}"; do + # printf "%d. %s\n" "$((i+1))" "${easy_results_dirs[i]}" + # done + # printf "%s\n" "${easy_results_dirs[@]}" + # last_index=$(( ${#easy_results_dirs} - 1 )) + # read -r -p "Enter the item number to select EASY results directory, default ($last_index): " response + # [[ -z $response ]] && response=$last_index + # response=$(( response - 1 )) # bash arrays use zero indexing + # EASY_RESULTS_DIR="${easy_results_dirs[$response]}" + # EASY_RESULTS_FILES=("$EASY_RESULTS_DIR/"*"/PrintResults/!!"*) + # [[ ${#easy_results_dirs[@]} -gt 0 ]] } @@ -1482,13 +1483,20 @@ main() { SCRIPT_DIR=$(dirname "$SCRIPT") # Global directory variables + local out_heirarchy=("$OUT_DIR" "$SCRIPT_DIR/out" "/mnt/data/out") + for d in "${out_heirarchy[@]}"; do + if [[ -d $d ]]; then + debug "Using output directory: $d" + OUT_DIR="$d" + fi + done TEMPLATES_DIR="$SCRIPT_DIR/templates" APPS_DIR="$SCRIPT_DIR/apps" DATE="$(date +%Y%m%d)" # change in EASYConsole.m to match - SCANS_HEIRARCHY=("./scans" "/mnt/data/scans" "/mnt/data/ExpJobs" "./scans") - SCANS_HEIRARCHY=("./scans" "/mnt/data/scans" "/mnt/data/ExpJobs" "./scans") # search for a scans dir in this order (and fall back to default) + # scans_heirarchy=("./scans" "/mnt/data/scans" "/mnt/data/ExpJobs" "./scans") + local scans_heirarchy=( "$SCANS_DIR" "./scans" "/mnt/data/scans" "./scans") # TODO change back for production, avoid actual scan dirs during testing # Find a scans directory - [[ -z $SCANS_DIR ]] && for d in "${SCANS_HEIRARCHY[@]}"; do + [[ -z $SCANS_DIR ]] && for d in "${scans_heirarchy[@]}"; do if [[ -d $d ]]; then SCANS_DIR="$d" fi @@ -1555,11 +1563,17 @@ main() { done # Loop over projects - for PROJECT in "${PROJECTS[@]}"; do + for PROJECT in "${PROJECTS[@]}"; do + declare -g PROJECT PROJECT_SCANS_DIR="$SCANS/$PROJECT" PROJECT_DATE="${PROJECT%"${PROJECT#????????}"}" # e.g. 20240723 PROJECT_SUFFIX="${PROJECT#????????_*_}" PROJECT_USER="${PROJECT#????????_}"; PROJECT_USER="${PROJECT_USER%%_*}" + STUDIES_ARCHIVE_FILE="$OUT_DIR/StudiesDataArchive.txt" + QHTCP_PROJECT_DIR="$OUT_DIR/$PROJECT" + QHTCP_TEMPLATE_DIR="$TEMPLATES_DIR/qhtcp" + STUDY_TEMPLATE_DIR="$TEMPLATES_DIR/exp" + STUDY_INFO_FILE="$QHTCP_PROJECT_DIR/StudyInfo.csv" # Run selected modules for m in "${MODULES[@]}"; do ask "Run $m?" && "$m"