function alignment=pairwise(alignment)

%---------------------------DESCRIPTION-----------------------------------%
%This method control all processes necessary for pairwise alignment of all
%sequences in data set and calculation of their distance
%-------------------------------------------------------------------------%

%Determine how many cycles will be needed to pairwise alignment
%of input sequences, depending on their count
cycles_to_run = alignment.seq_number;

%Align set of sequences to get distance matrix which is done through pairwise alignment
%between each of the sequences. But we doesn't want to run through those
%for which the distance had alredy been counted. So in each run we
%decrease the number of sequences to be aligned (done through second for cycle)

for i = 1 : cycles_to_run
    
%     if i < cycles_to_run
    alignment.main_seq = i;
    
        for j = i: cycles_to_run
            
                        
            if j < cycles_to_run
                
                %Set global property position on current sequence
                alignment.current_seq = j + 1;
                
                alignment.seq01 = char(alignment.seqs(i));
                alignment.seq02 = char(alignment.seqs(j+1));
                
                %Call of function for pairwise alignment, returns aligned
                %pair
                alignment = initialize_pairwise(alignment);
                alignment = pairwise_alignment(alignment);
                
                %Calculate distance between sequences
                alignment = calculate_distance(alignment);
                
                %Update distance matrix
                alignment = get_align_order(alignment);
                
            end
            
        end
    
%     end
    
end
