clc
clear
close all
load Fp.mat;
load Fn.mat;
load SSpositive.mat;
load SSnegative.mat;
load phychemical.mat;
load label.mat;
load negativeindex.mat;
load Positive.mat;
load Negative.mat;
fitness=[];
center=16;
top=30;
psize=size(Fp,1);
nsize=size(Fn,1);
mm=psize+negativeindex;
tlabel=[label(1:psize,:);label(mm,:)];
maxline=0;
gtopfeature=[];
PCKSAAP=[];
NCKSAAP=[];
for window=5:15
    temp=[];
    %%%%%%position scoring function%%%%%
    aar=[Fp(:,(center-window):(center+window));Fn(negativeindex,(center-window):(center+window))];
    aar=zscore(aar);
    auc = plotrocs(tlabel, aar ,'-v 10');
    temp=[temp;auc];
    %%%%%%secondary structure%%%%%%%%%%%
    aar=[];
    for i=1:size(SSpositive,3)
        aar=[aar;SSpositive((center-window):(center+window),1,i)' SSpositive((center-window):(center+window),2,i)' SSpositive((center-window):(center+window),3,i)'];
    end
    for i=1:size(negativeindex,2)
        aar=[aar;SSnegative((center-window):(center+window),1,negativeindex(i))' SSnegative((center-window):(center+window),2,negativeindex(i))' SSnegative((center-window):(center+window),3,negativeindex(i))'];
    end
    aar=zscore(aar);
    auc = plotrocs(tlabel, aar ,'-v 10');
    temp=[temp;auc];
    %%%%%%physicochemical properties%%%%
    m=size(phychemical,3);
    m=20;
    aar=[];
    pindex=1:psize;
    pindex=[pindex mm];
    for i=1:m
        aar=[aar phychemical(pindex,(center-window):(center+window),i)];
    end
    aar=zscore(aar);
    auc = plotrocs(tlabel, aar ,'-v 10');
    temp=[temp;auc];
    %%%%%CKSSP%%%%%%%%%%%%%%%%%%%%%%%%%
    [pCK,nCK,topfeature]=CKSSPselect(window,top,tlabel,positive,negative(negativeindex,:));
    aar=[pCK;nCK];
    aar=zscore(aar);
    auc = plotrocs(tlabel, aar ,'-v 10');
    if maxline<auc
        maxline=auc;
        gtopfeature=topfeature;
        PCKSAAP=pCK;
        NCKSAAP=nCK;
    end
    temp=[temp;auc];
    fitness=[fitness temp];
end
 save('gtopfeature.mat','gtopfeature','PCKSAAP','NCKSAAP');
       