function count_alignment
[genes, number_of_genes] = load_struct;
empty_genes = {};
missing_gene_in_sequence = {};

for gene_number = 1:number_of_genes
    
    [sequence, header, number_of_seq,empty_genes] = load_sequences_and_check_empty(genes,gene_number,empty_genes);
    alignment = multiple_alignment_of_sequence(sequence, gene_number,genes);
end

function [genes, number_of_genes] = load_struct
genes = dir('*.fasta');
number_of_genes = length(genes);


function [sequence, header, number_of_seq,empty_genes] = load_sequences_and_check_empty(genes,gene_number,empty_genes)

if (genes(gene_number).bytes) ~= 0                                        %% obsahuje sekvence?    
    [header,sequence] = fastaread(genes(gene_number).name);
    number_of_seq = length(sequence);
else
    sequence = '';
    header = '';
    number_of_seq = [];
    empty_genes{end+1} = genes(gene_number).name;
end

function alignment = multiple_alignment_of_sequence(sequence, gene_number,genes)
position = strfind(genes(gene_number).name,'.');
name_of_file = genes(gene_number).name(1:position-1);
name = [name_of_file '_alignment'];
alignment = multialign(sequence,'ScoringMatrix','NUC44');
save(name,'alignment')