%mCheckBPOrder.m
if ~isempty(ListInputData)
    %Don't reverse, only set ThisInteraction
    a=find(ListInputData(:,2)==LN2);
    b=find(ListInputData(:,1)==LN1);
    if ~isempty(a)
        if ~isempty(b)
            ind=find(a==b); %Since there may be several hits which do not belong to the same BP
            if ~isempty(ind)
                for s=1:length(ind)

if length(a)>=ind %This was added to prevent error
                    if strfind(lower(OrganismName{1}),lower(ListOrganismName{a(ind(s))}))
                        ThisInteraction=ListInteraction{a(ind(s))};%%%This is the index, which is equal to B(ind)
                    end
else %This was added to color in case upper statement is wrong, which caused error before
                    if strfind(lower(OrganismName{1}),lower(ListOrganismName{b(ind(s))}))
                        ThisInteraction=ListInteraction{b(ind(s))};%%%???
                    end
end

                end
            end
        end
    end
    %Reverse, and set ThisInteraction
    A=find(ListInputData(:,1)==LN2);
    B=find(ListInputData(:,2)==LN1);
    if ~isempty(A)
        if ~isempty(B)
            ind=find(A==B); %Since there may be several hits which do not belong to the same BP
            if ~isempty(ind)
                for s=1:length(ind)
                    
if length(A)>=ind %This was added to prevent error                    
                    if strfind(lower(OrganismName{1}),lower(ListOrganismName{A(ind(s))}))
                        ThisInteraction=ListInteraction{A(ind(s))};%%%This is the index, which is equal to B(ind)
                        ln2=LN2;LN2=LN1;LN1=ln2;%%%Reversed
                    end
else %This was added to color in case upper statement is wrong, which caused error before
                    if strfind(lower(OrganismName{1}),lower(ListOrganismName{B(ind(s))}))
                        ThisInteraction=ListInteraction{B(ind(s))};%%%???
                        ln2=LN2;LN2=LN1;LN1=ln2;%%%Reversed
                    end
end

                end
            end
        end
    end
end

if ~exist('ThisInteraction','var')
    ThisInteraction='';
end

if strcmpi(ThisInteraction,'cHW')||strcmpi(ThisInteraction,'tHW')||strcmpi(ThisInteraction,'cSW')||strcmpi(ThisInteraction,'tSW')||strcmpi(ThisInteraction,'cSH')||strcmpi(ThisInteraction,'tSH')||strcmp(ThisInteraction,'chH')||strcmp(ThisInteraction,'tsS')
    ThisInteraction=[ThisInteraction(1),ThisInteraction(3),ThisInteraction(2)]; %This means reverse order of letters
    ln2=LN2;LN2=LN1;LN1=ln2;%%%Reversed (again if needed)
end


