% Binomial_EstimationScript - putting together pairing results

% Embryos to run
if 0
    EmbNames = {'ab11','ab18','ac10','ad2','ad33','as21','be4','cb8','cb15','cb18','cb25','cb29','cb30','cb31','hx8','hx19','hz4','hz12','hz34','iz3','ne1','tu2'};
end

% Loading quantitative data
if 0
    QDs = {};
    for i=1:length(EmbNames)
        disp(EmbNames{i});
        QDs{i} = LoadQuantData_v2(['Binomial_Embryos/',EmbNames{i},'.txt']);
    end
end

% Loading pairs
if 0
    Pairs = {};
    for i=1:length(EmbNames)
        disp(EmbNames{i});
        Pairs{i} = load('-ascii',['Binomial_Embryos/',EmbNames{i},'_pairs.txt']);
    end
end

% Accumulating results
if 0
    Res = cell(14,1);
    for i=1:length(EmbNames)
        for j=1:3
            Gene = GeneNameToNum(QDs{i}.Genes{j});
            NuEsts = (QDs{i}.Data(Pairs{i}(:,1)+1,3+j)- ...
                QDs{i}.Data(Pairs{i}(:,2)+1,3+j)).^2 ./ ...
                (QDs{i}.Data(Pairs{i}(:,1)+1,3+j)+ ...
                QDs{i}.Data(Pairs{i}(:,2)+1,3+j));
            Res{Gene} = [Res{Gene}; NuEsts];
        end
    end
end

% Final, trimmed results
if 0
    for g=1:14
        if ~isempty(Res{g})
            Temp = sort(Res{g});
            Temp = Temp(1:round(0.9*length(Temp)));
            disp([GeneNumToName(g),' ',num2str(mean(Temp)),' ',num2str(255/mean(Temp))]);
        end
    end
end


