% Download the SAR-CoV 2 sequence from GenBank

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

dim_cnts = dimercount(cov_seq);

dimers = fieldnames(dim_cnts);
freq = struct2array(dim_cnts);

% Sort the freq in descending order and obtain sort indices 
[vals, indx] = sort (freq, 'descend');

% Rearrage dimers using the same sort indices
dimers = dimers(indx);

% Convert cell array to categorical values enforcing  
% ordering of categorical values (by using identical valueset)

dimers = categorical (dimers,  dimers);

% Plot a Bar Graphs 

bar(dimers, vals, 0.5);
xtickangle(45)
xlabel('Dimers')
ylabel('Frequency')
legend('Dimer Frequency for SARS-CoV 2')