%mMutualCounter_IF_OnebyOne_NT.m
if ~isdeployed,
%     clc,
end
sss=1;
n=1;
P=ChosenDomains;
NSeq_all(P) = DomainLimits(P+1)-DomainLimits(P);
y = DomainLimits(P)+1; %first sequence in the current DomainLimits (or domain, such as Archaea)
z = DomainLimits(P+1); %Last sequence
REF=PosArray(OrgInd(n),:,n);
[PosArray(y:z,:,n) indices]=sortrows(PosArray(y:z,:,n)); %This is very important, this will allow counts to be printed out in alphabetical order and only once for each combination of letters with hits

while y <= z
    %             y-1+strmatch(PosArray(y,:,n),PosArray(y:z,:,n))
    Count(y,n) = length(strmatch(PosArray(y,:,n),PosArray(y:z,:,n)));
    seqn=1;
    for x=y-DomainLimits(P):y+Count(y,n)-1-DomainLimits(P)
        try SEQNAME(sss,seqn) = FastaOrganismNames(DomainLimits(P)+indices(x));%+DomainLimits(P)+1); %%%%Another needed format to print into One-by-one GUI
        seqn=seqn+1;
        catch fprintf('%g\t',x);%DomainLimits(P)+indices(x)
        end
    end
    Percent(y,n)    =   100*Count(y,n)/NSeq_all(P);
    Percent(y,n)    =   round(Rounding*Percent(y,n))/Rounding;
    if ~isempty(PosArray(y,:,n))
        if PercentsCounts == 2;

            if strcmp(REF,PosArray(y,:,n)) && isempty(regexpi(OrganismName{1},'univ'));
                OUTPUT{sss,n} = strcat(PosArray(y,:,n),'..',num2str(Count(y,n)),'<<<');
            else OUTPUT{sss,n} = strcat(PosArray(y,:,n),'..',num2str(Count(y,n)));
            end
        else
            if strcmp(REF,PosArray(y,:,n)) && isempty(regexpi(OrganismName{1},'univ'));
                OUTPUT{sss,n} = strcat(PosArray(y,:,n),'..',num2str(Percent(y,n)),'<<<');
            else OUTPUT{sss,n} = strcat(PosArray(y,:,n),'..',num2str(Percent(y,n)));
            end
        end
        sss=sss+1;
    end
    y=y+Count(y,n); %This will make the counter jump over the combination if letters that are exactly like the previous "Counted" ones
end
