%%%%%%%%%%第三个文件：提取窗口为15的正负序列片段%%%%%%%%%%
clc
clear
close all
% load set.mat
% l=length(set);
% window=15;
% SSpositive=[];
% SSnegative=[];
% ct=1;
% nt=1;
% positive=[];
% negative=[];
% for i=1:l
%     SSdata=[];
%     Pid=[];
%     for j=1:window
%        Pid =[Pid 'X'];
%        SSdata=[SSdata; 0 0 0];
%     end
%     Pid=[Pid set(i,1).Sequence];
%     SSdata=[SSdata; set(i,1).SS];
%     for j=1:window
%         Pid=[Pid 'X'];
%         SSdata=[SSdata; 0 0 0];
%     end
%     kposition=find(Pid=='K');
%     num=length(kposition);
%     for j=1:num
%         temp=Pid((kposition(j)-window):(kposition(j)+window));
%         if ~isempty(find(set(i,1).Position==(kposition(j)-window)))
%             positive=[positive;temp];
%             SSpositive(:,:,ct)=SSdata((kposition(j)-window):(kposition(j)+window),:);
%             ct=ct+1;
%         else
%             negative=[negative;temp];
%             SSnegative(:,:,nt)=SSdata((kposition(j)-window):(kposition(j)+window),:);
%             nt=nt+1;
%         end
%     end
% end
% save('SSpositive.mat','SSpositive');
% save('SSnegative.mat','SSnegative');
% save('Positive.mat','positive');
% save('Negative.mat','negative');
%%%%%%%%%%%%%data save%%%%%%%%%%%%
load Positive.mat;
load Negative.mat;
fid1=fopen('positive.txt','wt');
fid2=fopen('negative.txt','wt');
n=size(positive,1);
m=size(negative,1);
for i=1:n
    fprintf(fid1,'%s\n',positive(i,:));
end
for j=1:m
    fprintf(fid2,'%s\n',negative(j,:));
end
fclose(fid1);
fclose(fid2);