function [ successfulMCMC,successfulfreqpval ] = MCMCplotter(SNP, triallength, filename )
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

successfulMCMC=0;
successfulfreq=0;
successfulfreqpval=0;

 for j =1:triallength
            
            trial_name1= num2str(j);
            new_filename1 = [filename trial_name1 ];
            
            load (new_filename1)
            
            sorted_TIM= sort(times_in_model,'descend');
            if(times_in_model(SNP)~=0)
            if ( times_in_model(SNP)==sorted_TIM(1)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(2)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(3)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(4)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(5)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(6)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(7)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(8)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(9)) 
                successfulMCMC= successfulMCMC+1;
            elseif ( times_in_model(SNP)==sorted_TIM(10)) 
                successfulMCMC= successfulMCMC+1;
            end
            end
            cases=ones(1000,1);
            controls=zeros(1000,1);
            indextocases=[cases; controls];
            glm_log_pvals=zeros(1,183);
            maxdev = chi2inv(.95,1);     
            opt = statset('display','iter',...
              'TolFun',maxdev,...
              'TolTypeFun','abs');

[fs,history] = sequentialfs(@critfun,boot,indextocases,...
                       'cv','none',...
                       'nullmodel',true,...
                       'options',opt,...
                       'direction','forward');
            
           
           sorted_pvals=fs;
           
         
            
            if ( fs(SNP)== 1)
                successfulfreqpval=successfulfreqpval+1;
            end
 end

end

