%%%%%%%%%第四个文件：计算氨基酸在正负序列片段出现的频率%%%%
clc
clear
close all
load Positive.mat;
load Negative.mat;
window=15;
letter=['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'];

PM=[];
NM=[];
%%%%%%positive%%%%%%%%%%%%%%%
num=size(positive,2);
m=size(positive,1);
for i=1:num
    temp=[];
    for j=1:length(letter)
        temp=[temp length(find(positive(:,i)==letter(j)))];
    end
    PM=[PM;temp];
end   
% PM=PM/m;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%negative%%%%%%%%%%%%%%%
num=size(negative,2);
m=size(negative,1);
for i=1:num
    temp=[];
    for j=1:length(letter)
        temp=[temp length(find(negative(:,i)==letter(j)))];
    end
    NM=[NM;temp];
end   
% NM=NM/m;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% save('Mpositive.mat','PM');
% save('Mnegative.mat','NM');
%%%%%%%%%%%%%%%
AM=PM+NM;
NM=NM/size(negative,1);
PM=PM/size(positive,1);
AM=AM/(size(positive,1)+size(negative,1));
p=[];
for i=1:size(positive,2)
    for j=1:20
    p=[p; signrank(PM(i,j),AM(i,j))];
    end
end
p1=[];
for i=1:size(positive,2)
    p1=[p; signrank(PM(i,:),NM(i,:))];
end