function [emmision,transmat]=update_probabilities(all_ungap_sequences,emmision,transmat,transmat11,emmision11,a)
 Q=6;
 criteria=0;
   while criteria <3
       transition_num=zeros(3*Q+3,3*Q+3);
       emmision_num=zeros(3*Q+3,20);
           for q=1:size(a,2)
                 observation=all_ungap_sequences(a(q),find(all_ungap_sequences(a(q),:)>0));
                 [alpha1]=compute_alpha(observation,emmision,transmat);
                 [simulated_hidden_path]=simulating_hidden_states(observation,transmat,emmision,alpha1);
                 [transition_num,emmision_num]=count_emmision_transition(simulated_hidden_path,observation,transition_num,emmision_num);
           end
         [transmat,emmision]=sampling_parameters(transition_num,emmision_num,transmat11,emmision11);   
         criteria=criteria+1;   
   end