-
Notifications
You must be signed in to change notification settings - Fork 0
/
extractAlignment.m
36 lines (33 loc) · 986 Bytes
/
extractAlignment.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%
% This function takes a optimal cost string alignment table S,
% and the two strings, x and y, the table corresponds to and
% returns a sequence of operations that turn x into y
%
function a = extractAlignment(S,x,y)
a = char([]);
i = length(x)+1;
j = length(y)+1;
disp('Trace back coordinates')
fprintf('i = %d j = %d\n', i, j);
% trace back path until the path hits the edge of the table
while (i>1 && j>1)
[a(end+1), i, j] = determineOptimalOp(S, i, j, x, y);
fprintf('i = %d j = %d\n', i, j);
end
disp('finished while loop')
% if i and j are greater than one inser indels until path reaches
% origin of the table
if (i>1)
for k = 1:i-1
fprintf('i = %d j = %d\n', i-k, j);
a(end+1) = 'i';
end
end
if (j>1)
for k = 1:j-1
fprintf('i = %d j = %d\n', 0, j-k);
a(end+1) = 'd';
end
end
a = fliplr(a);
end