function alignment = pprintAlignment(as1, as2, left, right) %PPRINTALIGNMENT "Pretty-print" an alignment % Prints a sequence alignment, identifying places where % amino acid matches occur. if (length(as1) ~= length(as2)) error('Aligned sequences must have the same length'); end % See if ranges where specified if (nargin < 3) left = 1; end; if (nargin < 4) right = length(as1); end; % Definitions chars_per_line = 60; align_len = right - left + 1; num_lines = floor(align_len+chars_per_line-1)/chars_per_line; num_digits = floor(log10(right)+1); % Identify places where sequences match dots = blanks(length(as1)); for i=left:right if (as1(i) == as2(i)) dots(i) = '.'; end end % Pretty-print the alignment alignment = []; for i = 1:num_lines start_index = left + (i-1) * chars_per_line; end_index = min([start_index+chars_per_line-1, right]); l1 = sprintf('%0*d-%0*d: %s', num_digits, start_index, num_digits, ... end_index, as1(start_index:end_index)); l2 = sprintf('%0*d-%0*d: %s', num_digits, start_index, num_digits, ... end_index, as2(start_index:end_index)); l3 = sprintf('%0*d-%0*d: %s', num_digits, start_index, num_digits, ... end_index, dots(start_index:end_index)); alignment = strvcat(alignment, l1, l2, l3); if (i