From 2d5ce7564d6238dc643f5166c8e1209df45d466e Mon Sep 17 00:00:00 2001 From: Waldir Leoncio Date: Thu, 8 Aug 2024 13:02:15 +0200 Subject: [PATCH] Replaced dialog windows with console inputs (#8) --- greedyMix/process_FASTA_data.m | 14 +++++------- spatial/handleIndiFastaCase.m | 41 ++++++++++++++++------------------ 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/greedyMix/process_FASTA_data.m b/greedyMix/process_FASTA_data.m index e5d71fd..a6793ea 100644 --- a/greedyMix/process_FASTA_data.m +++ b/greedyMix/process_FASTA_data.m @@ -36,15 +36,13 @@ clear h0; clear inp; clear file; clear filename2; clear pathname1; clear pathname2; - input_pops = questdlg(['When using data which are in FASTA-format, '... + input_pops = input(['When using data which are in FASTA-format, '... 'you can specify the sampling populations of the individuals by '... 'giving two additional files: one containing the names of the '... 'populations, the other containing the indices of the first '... 'individuals of the populations. Do you wish to specify the '... - 'sampling populations?'], ... - 'Specify sampling populations?',... - 'Yes', 'No', 'No'); - if isequal(input_pops,'Yes') + 'sampling populations? (y/N)'], 's'); + if isequal(input_pops,'y') [namefile, namepath] = uigetfile('*.txt', 'Load population names'); if namefile==0 kysyToinen = 0; @@ -79,10 +77,8 @@ cc.coordinates = coordinates; format_type = 'FASTA'; - save_preproc = questdlg('Do you wish to save pre-processed data?',... - 'Save pre-processed data?',... - 'Yes','No','Yes'); - if isequal(save_preproc,'Yes') + save_preproc = input('Do you wish to save pre-processed data? (y/N)', 's'); + if isequal(save_preproc,'y') [filename, pathname] = uiputfile('*.mat','Save pre-processed data as'); kokonimi = [pathname filename]; save(kokonimi,'cc','dist','Z','format_type','-v7.3'); % added by Lu Cheng, 08.06.2012 diff --git a/spatial/handleIndiFastaCase.m b/spatial/handleIndiFastaCase.m index da1424d..0871b72 100644 --- a/spatial/handleIndiFastaCase.m +++ b/spatial/handleIndiFastaCase.m @@ -4,10 +4,9 @@ function handleIndiFastaCase(cc,dist,Z) OUTPUT_FILE = 'baps6_output.baps'; -teksti = 'Input upper bound to the number of populations (only one value): '; -npopstextExtra = inputdlg(teksti ,'Input maximum number of populations',1,{'20'}); +npopstextExtra = input('Input maximum number of populations', 's'); if isempty(npopstextExtra) % Painettu Cancel:ia - return + nMaxPops = 20; else nMaxPops = str2num(npopstextExtra{1}); nMaxPops = nMaxPops(1); @@ -75,16 +74,15 @@ function handleIndiFastaCase(cc,dist,Z) names{i} = namesInCell; end end -vorPlot(vorPoints, vorCells, partition, pointers, coordinates, names); +vorPlot(vorPoints, vorCells, partition, pointers, coordinates, names); -talle = questdlg(['Do you want to save the mixture populations ' ... +talle = input(['Do you want to save the mixture populations ' ... 'so that you can use them later in admixture analysis or plot ' ... - 'additional images?'], ... - 'Save results?','Yes','No','Yes'); -if isequal(talle,'Yes') + 'additional images? (y/N) '], 's'); +if isequal(talle,'y') %%waitALittle; % Hetki odotusta, jotta muistaa kysy?.. [filename, pathname] = uiputfile('*.mat','Save results as'); - + if (filename == 0) & (pathname == 0) % Cancel was pressed return @@ -94,7 +92,7 @@ function handleIndiFastaCase(cc,dist,Z) delete(OUTPUT_FILE) end end - + % added by Lu Cheng, 05.12.2012 tmpFile = [pathname filename '.mapfile.txt']; fid = fopen(tmpFile,'w+'); @@ -111,7 +109,7 @@ function handleIndiFastaCase(cc,dist,Z) end end fclose(fid); - + % save([pathname filename], 'c'); format_type = 'FASTA'; save([pathname filename], 'cc','dist','Z','format_type','-v7.3'); @@ -168,20 +166,20 @@ function writeMixtureInfo(c) end for m=1:npops indsInM = find(partition==m); - + if isempty(indsInM) continue; end - + length_of_beginning = 11 + floor(log10(m)); cluster_size = length(indsInM); - + text = ['Cluster ' num2str(m) ': {' char(popnames{indsInM(1)})]; for k = 2:cluster_size text = [text ', ' char(popnames{indsInM(k)})]; end; text = [text '}']; - + while length(text)>58 %Take one line and display it. new_line = takeLine(text,58); @@ -196,7 +194,7 @@ function writeMixtureInfo(c) text = []; end; end; - + if ~isempty(text) disp(text); if (fid ~= -1) @@ -214,7 +212,7 @@ function writeMixtureInfo(c) disp(' '); disp(' '); disp('Changes in log(marginal likelihood) if indvidual i is moved to cluster j:'); - + if (fid ~= -1) fprintf(fid, '%s \n', ' '); fprintf(fid, '\n'); fprintf(fid, '%s \n', 'Changes in log(marginal likelihood) if indvidual i is moved to cluster j:'); fprintf(fid, '\n'); @@ -225,19 +223,19 @@ function writeMixtureInfo(c) tmpstr = sprintf('\t%10s',num2str(ii)); text = [text tmpstr]; end - + disp(text); if (fid ~= -1) fprintf(fid, '%s \n', text); end - + for ii = 1:ninds text = sprintf('%10s',popnames{ii}); for jj = 1:npops tmpstr = sprintf('\t%10s',num2str(logmldiff(ii,jj),'%10.6f')); text = [text tmpstr]; end - + if ii<100 disp(text); elseif ii==101 @@ -246,7 +244,7 @@ function writeMixtureInfo(c) end if (fid ~= -1) fprintf(fid, '%s \n', text); - end + end text = []; end end @@ -304,4 +302,3 @@ function writeMixtureInfo(c) n = n+1; end; newline = description(1:n); -