%%%%%%%%%第一个文件：把Glycation2.elm里数据importdata，生成test2.mat，生成fasta.txt.
clc
clear
close all
load test2data.mat;
sample=[];
L=length(ID);
for i=2:L
    label=0;
    for j=1:length(sample)
        if strcmp(ID{i,1},sample(j).ID)
            sample(j).Position=[sample(j).Position Position(i,1)];
            label=1;
        end
    end
    if label==0
      temp.ID=ID{i,1};
      temp.Sequence=Sequence{i,1};
      temp.Species=Species{i,1};
      temp.Position=[];
      temp.Position=[temp.Position Position(i,1)]; 
      sample=[sample; temp];
    end
end
test2all=sample;
clear sample;
save('test2all.mat','test2all');
%%%%%%%%%%%%%%%%%%%%%%
test2delect=[];
load data1.mat;
n=size(sample,1);
for i=1:n
    for j=1:size(test2all,1)
        if strcmp(sample(i,1).ID,test2all(j,1).ID)
           test2all(j)=[]; 
           break;
        end
    end
end
test2delect=test2all;
save('test2delect.mat','test2delect');
% time=10;
td=1000;
% test2sampleind=[]
% for i=1:time
    m=size(test2all,1);
    randind=randperm(m);
    randind=randind(1:td);
    test2sample1000=test2all(randind,1);
% end
save('test2sample1000.mat','test2sample1000');
% 
% %%%%%%%%%
n=size(test2sample1000,1);
for i=1:n
    nm=['H:\Stest3\',num2str(i),'.txt'];
    fid=fopen(nm,'wt');
    fprintf(fid,'>%s\n',test2sample1000(i).ID);
    fprintf(fid,'%s\n',test2sample1000(i).Sequence);
    fclose(fid);
end