function seq = pos2sym(pos)

%POS2SYM   Convert from integer indices to amino acid symbols
%  SEQ = pos2sym(POS) converts numerical indices corresponding
%  to each amino acid symbol into 1-letter amino acid symbols,
%  according to the standard ordering 'ARNDCQEGHILKMFPSTWYV'.
%  0 will be converted to a gap ('-'), and anything <0 or >20
%  will be converted to 'U', a generic unrecognized character.
%
%  See also SYM2POS

% The standard order of amino acids
symbols = 'ARNDCQEGHILKMFPSTWYV';

% Retrieve the amino acid corresponding to each index
N = length(pos);
seq = blanks(N);
for i=1:N
  if (pos(i) == 0)
    seq(i) = '-';
  elseif (pos(i)<0 | pos(i)>length(symbols))
    seq(i) = 'U';
  else
    seq(i) = symbols(pos(i));
  end
end

