function v = doRNAclass(D, pos_ix, neg_ix, oligo_ix)
%doRNAclass - do the RNA classifications
%
% V = doRNAclass(D, POS_IX, NEG_IX, OLIGO_IX)
%
% This function computes the discriminant values for the six
% different RNA subcategories.
%
% INPUTS
%  D - data matrix, each column is an experiment and each row
%      corresponds to a oligo on the RNA array.  ie. D(J,K) is the
%      value of oligo J in experiment K.
%  POS_IX - cell array of index vectors of the positive mutants.
%           POS_IX{I} is the vector of the indices of the
%           experiments run on mutants that are positive for RNA class I.
%  NEG_IX - cell array of index vectors of the negative mutants.
%  OLIGO_IX - cell array of index vector of the relevant oligos in
%             each RNA subcategory.  OLIGO_IX{I} are the indices of
%             all oligos associated with subcategory I.
%
%  Note that the matrices: D(OLIGO_IX{I}, POS_IX{I}) and
%    D(OLIGO_IX{I}, NEG_IX{I}) are the training set for RNA subcategory I.
%
% OUTPUTS
%  V - cell array of discriminant values, V{I}(J) is the
%      discriminant value for the J-th experiment in RNA
%      subcategory I

for ii = 1:length(pos_ix)
  fprintf('Task %d\n', ii);
  fprintf('# negatives %d\n', length(neg_ix{ii}));
  fprintf('# positives %d\n', length(pos_ix{ii}));
  fprintf('# oligos %d\n', length(oligo_ix{ii}));
  tic;
  Neg = D(oligo_ix{ii}, neg_ix{ii});
  Pos = D(oligo_ix{ii}, pos_ix{ii});
  [negscore, posscore] = loocv('kdeClass', Neg, Pos);
  fprintf('That took %f seconds\n', toc);

  tic;
  [v{ii}, sneg, spos] = kdeClass(D(oligo_ix{ii},:), Neg, Pos);
  fprintf('That took %f seconds\n', toc);
  v{ii}(pos_ix{ii}) = posscore;
  v{ii}(neg_ix{ii}) = negscore;
end
