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

successfulMCMC=0;
successfulfreq=0;
successfulMCMC2=0;
successfulfreq2=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)==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)) 
                successfulMCMC2= successfulMCMC2+1;
                elseif ( times_in_model(SNP)==sorted_TIM(7)) 
                successfulMCMC2= successfulMCMC2+1;
                elseif ( times_in_model(SNP)==sorted_TIM(8)) 
                successfulMCMC2= successfulMCMC2+1;
                elseif ( times_in_model(SNP)==sorted_TIM(9)) 
                successfulMCMC2= successfulMCMC2+1;
                elseif ( times_in_model(SNP)==sorted_TIM(10)) 
                successfulMCMC2= successfulMCMC2+1;
            end
            
            sorted_freq= sort(frequentist_log_likelihood, 'descend');
            
            if ( frequentist_log_likelihood(SNP)== sorted_freq(1))
                successfulfreq=successfulfreq+1;
            elseif ( frequentist_log_likelihood(SNP)== sorted_freq(2))
                successfulfreq=successfulfreq+1;
            elseif ( frequentist_log_likelihood(SNP)== sorted_freq(3))
                successfulfreq=successfulfreq+1;
            elseif ( frequentist_log_likelihood(SNP)== sorted_freq(4))
                successfulfreq=successfulfreq+1;
            elseif ( frequentist_log_likelihood(SNP)== sorted_freq(5))
                successfulfreq=successfulfreq+1;
                elseif ( frequentist_log_likelihood(SNP)== sorted_freq(6))
                successfulfreq2=successfulfreq2+1;
                elseif ( frequentist_log_likelihood(SNP)== sorted_freq(7))
                successfulfreq2=successfulfreq2+1;
                elseif ( frequentist_log_likelihood(SNP)== sorted_freq(8))
                successfulfreq2=successfulfreq2+1;
                elseif ( frequentist_log_likelihood(SNP)== sorted_freq(9))
                successfulfreq2=successfulfreq2+1;
                elseif ( frequentist_log_likelihood(SNP)== sorted_freq(10))
                successfulfreq2=successfulfreq2+1;
            end
 end

end

