Skip to content

Commit

Permalink
Replaced dialog windows with console inputs (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
wleoncio committed Aug 8, 2024
1 parent d420da0 commit 2d5ce75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
14 changes: 5 additions & 9 deletions greedyMix/process_FASTA_data.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
41 changes: 19 additions & 22 deletions spatial/handleIndiFastaCase.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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+');
Expand All @@ -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');
Expand Down Expand Up @@ -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);
Expand All @@ -196,7 +194,7 @@ function writeMixtureInfo(c)
text = [];
end;
end;

if ~isempty(text)
disp(text);
if (fid ~= -1)
Expand All @@ -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');
Expand All @@ -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
Expand All @@ -246,7 +244,7 @@ function writeMixtureInfo(c)
end
if (fid ~= -1)
fprintf(fid, '%s \n', text);
end
end
text = [];
end
end
Expand Down Expand Up @@ -304,4 +302,3 @@ function writeMixtureInfo(c)
n = n+1;
end;
newline = description(1:n);

0 comments on commit 2d5ce75

Please sign in to comment.