% Download the SAR-CoV 2 sequence from GenBank

seq_obj = getgenbank ('NC_045512');
cov_seq = seq_obj.Sequence;

words = generate_trimers();
freqs = freq_profile(cov_seq, words);

% Sort the freq in descending order and obtain 
% indices of the sorted values

[vals, indx] = sort (freqs, 'descend');
words = words(indx);

% Get indices where the frequency is greater than 500

sel = vals > 500;
vals = vals(sel);
words = words(sel);

% Rearrage trimers using the sorted indices

words = categorical (words, words);

bar(words, vals);
xtickangle(60)
ax = gca;
ax.XAxis.FontSize = 14;

xlabel('Trimers')
ylabel('Frequency')
legend('Trimer Frequency for SARS-CoV 2')