function pos = sym2pos(seq)

%SYM2POS Converts amino acid symbols to integer indices
% POS = sym2pos(SEQ) converts a sequence seq consisting of amino
% acid symbols into numerical indices corresponding to each
% symbol, according to the standard amino acid ordering
% 'ARNDCQEGHILKMFPSTWYV'. This is useful if you want to
% efficiently access entries in a scoring matrix.
%
% 0 corresponds to a gap ('-'), and -1 corresponds to any other
% unrecognized character.
%
% See also SYM2POS

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

% Retrieve the position of each symbol
N = length(seq);
pos = zeros(1, N);
for i=1:N
ind = findstr(symbols, seq(i));
if (isempty(ind))
if (seq(i) == '-')
ind = 0;
else
ind = -1;
end
end
pos(i) = ind;
end