%mMutualCounter_IF_OneOrganism.m

if isfield(handles, 'SEQNAME')
    handles.SEQNAME=[];%clear previous values
end

% NSeq_all    =   zeros(1,length(ChosenDomains));                                       %Optimized for Speed%
% NSeq        =   zeros(1,length(ChosenDomains));
Count(length(BPs),length(BPs),length(ListInputData(:,1)),length(ChosenDomains))   =   0;  %Optimized for Speed%

Percent(length(BPs),length(BPs),length(ListInputData(:,1)),length(ChosenDomains)) =   0;  %Optimized for Speed%
SumTotal    =   zeros(length(ListInputData(:,1)),length(ChosenDomains));                  %Optimized for Speed%


HitCount=0;

P=ChosenDomains;
% NSeq_all(P) = DomainLimits(P+1)-DomainLimits(P);



SEQNAME{length(ListInputData(:,1)),length(BPs),length(BPs)}=[];%initiation --- can't initiate a cell array
x(length(BPs),length(BPs))=0;
for n=1:length(ListInputData(:,1))
    if ListTable(n)==ChosenTable
        HitCount=HitCount+1;
        for a=1:length(BPs)
            for b=1:length(BPs)
                Count(a,b,n,P)      =   sum(strcmp(BPs(a,b),ListPosArray(OrgInd(1),:,n)));      %Optimized for Speed%
                Percent(a,b,n,P)    =   100*Count(a,b,n,P);%%%%%%%NSeq(P)



                if Count(a,b,n,P)>0 %it can only be 0 or 1!
                    x(a,b)=x(a,b)+1;
                    SEQNAME{x(a,b),a,b} = strcat(num2str(ListInputData(n,1)),'-',num2str(ListInputData(n,2)));
                end





            end
        end
    end
end

if HitCount~=0,
    if PercentsCounts == 2,
        VALUE=sum(Count,3);
    else VALUE=sum(Percent,3)/HitCount;
        VALUE=round(Rounding*VALUE)/Rounding;
    end
else VALUE=zeros(length(BPs));

end












