function [emmision,transmat]=update_probabilities(all_ungap_sequences,emmision,transmat,transmat11,emmision11,a)
   Q=6;
   criteria=0;
   while criteria <2
         AA=zeros(3*Q+3,3*Q+3);
         for k=1:3*Q+3
           for l=1:3*Q+3
               if transmat11(k,l)~=0
                   AA(k,l)=1;
               end
           end
         end
         EE=zeros(3*Q+3,20);
         for s=1:3*Q+3
            for t=1:20
               if emmision11(s,t)~=0
                   EE(s,t)=1;
               end
            end
         end 
           for w=1:size(a,2);
                 observation=all_ungap_sequences(a(w),find(all_ungap_sequences(a(w),:)>0));
                 [alpha1]=compute_alpha(observation,emmision,transmat);
                 [beta1]=compute_beta(observation,emmision,transmat);
                 [EE,AA]=Baum_Welch(observation,emmision,transmat,alpha1,beta1,EE,AA);  
           end
         [emmision,transmat]=normalizing_total_count(AA,EE);   
         criteria=criteria+1;   
    end