function [PCKSAAP,NCKSAAP,Dletter]=CKSSPcal(window,positive,negative)
%     load Positive.mat;
%     load Negative.mat;
    n=size(positive,1);
    m=size(positive,2);
%     window=5;
    letter=['A','R','N','D','C','Q','E','G','H','I','L','K','M','F','P','S','T','W','Y','V','X'];

    Dletter=[];
    for i=1:21
        for j=1:21
            Dletter=[Dletter; letter(1,i) letter(1,j)];
        end
    end
    CKSAAP0=zeros(n,length(Dletter));
    CKSAAP1=zeros(n,length(Dletter));
    CKSAAP2=zeros(n,length(Dletter));
    CKSAAP3=zeros(n,length(Dletter));
    CKSAAP4=zeros(n,length(Dletter));
    for i=1:n
        center=(m-1)/2+1;
        schar=positive(i,(center-window):(center+window));
        D=length(schar);
        for j=1:length(Dletter)
                for k=1:(D-1)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+1)==Dletter(j,2)
                       CKSAAP0(i,j)=CKSAAP0(i,j)+1;
                   end
                end
                for k=1:(D-2)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+2)==Dletter(j,2)
                       CKSAAP1(i,j)=CKSAAP1(i,j)+1;
                   end
                end
                for k=1:(D-3)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+3)==Dletter(j,2)
                       CKSAAP2(i,j)=CKSAAP2(i,j)+1;
                   end
                end
                for k=1:(D-4)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+4)==Dletter(j,2)
                       CKSAAP3(i,j)=CKSAAP3(i,j)+1;
                   end
                end
                for k=1:(D-5)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+5)==Dletter(j,2)
                       CKSAAP4(i,j)=CKSAAP4(i,j)+1;
                   end
                end
        end
    end
    PCKSAAP(:,:,1)=CKSAAP0;
    PCKSAAP(:,:,2)=CKSAAP1;
    PCKSAAP(:,:,3)=CKSAAP2;
    PCKSAAP(:,:,4)=CKSAAP3;
    PCKSAAP(:,:,5)=CKSAAP4;
    n=size(negative,1);
    m=size(negative,2);
    CKSAAP0=zeros(n,length(Dletter));
    CKSAAP1=zeros(n,length(Dletter));
    CKSAAP2=zeros(n,length(Dletter));
    CKSAAP3=zeros(n,length(Dletter));
    CKSAAP4=zeros(n,length(Dletter));
    for i=1:n
        center=(m-1)/2+1;
        schar=negative(i,(center-window):(center+window));
        D=length(schar);
        for j=1:length(Dletter)
                for k=1:(D-1)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+1)==Dletter(j,2)
                       CKSAAP0(i,j)=CKSAAP0(i,j)+1;
                   end
                end
                for k=1:(D-2)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+2)==Dletter(j,2)
                       CKSAAP1(i,j)=CKSAAP1(i,j)+1;
                   end
                end
                for k=1:(D-3)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+3)==Dletter(j,2)
                       CKSAAP2(i,j)=CKSAAP2(i,j)+1;
                   end
                end
                for k=1:(D-4)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+4)==Dletter(j,2)
                       CKSAAP3(i,j)=CKSAAP3(i,j)+1;
                   end
                end
                for k=1:(D-5)
                   if schar(1,k)==Dletter(j,1)&&schar(1,k+5)==Dletter(j,2)
                       CKSAAP4(i,j)=CKSAAP4(i,j)+1;
                   end
                end
        end
    end
    NCKSAAP(:,:,1)=CKSAAP0;
    NCKSAAP(:,:,2)=CKSAAP1;
    NCKSAAP(:,:,3)=CKSAAP2;
    NCKSAAP(:,:,4)=CKSAAP3;
    NCKSAAP(:,:,5)=CKSAAP4;
end
% save('CKSAAP.mat','PCKSAAP','NCKSAAP');
                   