
function [TP_num, FP_num, FDR2, TP_Protein, FP_Protein,TP_Label, FP_Label] = Split(p1,p,n,X,Y,protein,digest_index,theta,part)
   
tic;

L = length(Y)/part;

TP_temp = []; FP_temp = []; TN_temp = []; FN_temp = []; True_label = cell(1,n); False_label = cell(1,n);


for index = 1:part
    Xtemp = X(L*(index-1)+1:L*index,:);
    Ytemp = Y(L*(index-1)+1:L*index);
    digest_index_temp = digest_index(L*(index-1)+1:L*index);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     [TP4_label,FP4_label,TP,TN,FP,FN] = MK(Xtemp,Ytemp,p1,p,digest_index_temp,theta);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   

    TP_temp = [TP_temp; TP]; FP_temp = [FP_temp; FP]; 
    TN_temp = [TN_temp; TN]; FN_temp = [FN_temp; FN]; 

    for kk = 1:n
    TP_label{index,kk} = TP4_label{1,kk}+L*(index-1);
    FP_label{index,kk} = FP4_label{1,kk}+L*(index-1);
     
    True_label{1,kk} = [True_label{1,kk};TP_label{index,kk}];
    False_label{1,kk} = [False_label{1,kk};FP_label{index,kk}];
    end
end
TP_num = sum(TP_temp); TN_num = sum(TN_temp); FP_num = sum(FP_temp); FN_num = sum(FN_temp); 
TPR = TP_num./(TP_num+FN_num); 
SPC = TN_num./(FP_num+TN_num); 
MS_FDR = 2*FP_num./(TP_num+FP_num);

TP_Label = True_label;
FP_Label = False_label;
TP_Protein = zeros(1,n);
FP_Protein = zeros(1,n);FDR2 = zeros(1,n);
for ii = 1:n
    TP(1,ii) = length(TP_Label{1,ii});
    FP(1,ii) = length(FP_Label{1,ii});
    TP_Protein(1,ii) = length(unique(protein(TP_Label{1,ii})));
    FP_Protein(1,ii) = length(unique(protein(FP_Label{1,ii})));
    FDR2(1,ii) = 2*FP_Protein(1,ii)/(FP_Protein(1,ii) + TP_Protein(1,ii));
end
toc;