function alignment = create_consensus_seq(alignment)

%---------------------------DESCRIPTION-----------------------------------%
%This method create consensus sequence for further global alignment.
%Consensus sequence is based on frequency of nucleotides in currently
%examined column. In case two or more nucleotides has same number of
%occurency we will advance in order A, C, G and T
%-------------------------------------------------------------------------%

temp_array = [];
nucleotides = [];
consensus_seq = [];

for i = 1 : length(alignment.multiple_seq_alignment{1,1})
    
    nucleotides = [];

    for j = 1 : length(alignment.multiple_seq_alignment) 

        temp_array = alignment.multiple_seq_alignment{j};
        
        nucleotides = [nucleotides temp_array(i)];

    end
    
    num_a = sum(nucleotides == 'A');
    num_c = sum(nucleotides == 'C');
    num_t = sum(nucleotides == 'T');
    num_g = sum(nucleotides == 'G');
    
    value_set = [num_a num_c num_g num_t];
    
    [value, position] = max(value_set);
    
    switch position
        
        case 1
            consensus_seq = [consensus_seq 'A'];
        case 2
            consensus_seq = [consensus_seq 'C'];
        case 3
            consensus_seq = [consensus_seq 'G'];
        case 4
            consensus_seq = [consensus_seq 'T'];
                            
    end

end

alignment.consensus_seq = consensus_seq;