function vseq = vectorize_seq (seq)
% vseq = vectorize_seq (seq)
%
% Turns a sequence (either a vector of 'A', 'C', 'G', 'T', or a vector of
% 1, 2, 3, 4) of length L into a vector of zeros and ones, of length 4*L.
% vseq (4*(i-1) + j) = 1 iff seq(i) = j (where 'A' = 1. 'C' = 2, 'G' = 3,
% 'T' = 4).
%
% The function can also be applied to a matrix (a vector of sequences).

if ischar (seq)
    nseq = seq2nseq (seq);
else
    nseq = seq;
end

seq_count = size (nseq, 1);
if seq_count ~= 1
    vseq = zeros (seq_count, size (nseq, 2)*4);
    for i = 1:seq_count
        vseq (i, :) = vectorize_seq (nseq (i, :));
    end
    return;
end

tmp = [nseq == 1; nseq == 2; nseq == 3; nseq == 4];
vseq = tmp(:);

end