clear all

% Plot octanol-water partitioning data from Wimley, Creamer, White paper, 
% Biochemistry 1996, 35, 5108. Obtained from website, below.
% https://www.blanco.biomol.uci.edu/hydrophobicity_scales.html
% 
% Executes properly on MATLAB version 9.4.0.813654 (R2018a).
% Untested on OCTAVE
% Joshua C. Vaughan 2/13/2024

nms = {'A','R','N','D','C','Q','E','G','H','I','L','K','M', ...
    'F','P','S','T','W','Y','V'};

oct = [0.5 1.81 0.85 3.64 -0.02 0.77 3.63 1.15 2.33 -1.12 -1.25 2.8...
    -0.67 -1.71 0.14 0.46 0.25 -2.09 -0.71 -0.46]*4.184; % kJ/mol

[oct_sorted,inds] = sort(oct);
nms_sorted = nms(inds);

nms_sorted2 = reordercats(categorical(nms_sorted),nms_sorted);

% figure properties
ax_fs = 16;
ax_lw = 2;
la_fs = 20;
pl_lw = 2;
ti_fs = 20;

h = bar(nms_sorted2,oct_sorted,'facecolor','flat');

ch = 1;%

if ch==1
    h.FaceColor = 0.5*[1 1 1 ];
elseif ch==2
    b_inds = [1 2 5]; % aromatic uncharged side chain
    gray_inds = [3 4 6 7 8:15];
    r_inds = [16 17 18 19 20]; % charged side chain
    for k=b_inds
        h.CData(k,:) = [0 0.3 1];
    end
    for k=gray_inds
        h.CData(k,:) = 0.5*[1 1 1];
    end
    for k=r_inds
        h.CData(k,:) = [1 0 0];
    end
end
set(gca,'fontsize',ax_fs)
set(gca,'tickdir','out')
set(gca,'linewidth',ax_lw)
set(gcf,'color',[1 1 1])
set(gca,'xticklabelrotation',0)
set(gca,'linewidth',ax_lw)
set(gca,'ylim',[-10 16])
xlabel('amino acid','fontsize',la_fs)
ylabel('\Delta{\itG}\circ (water to oct., kJ/mol)','fontsize',la_fs)
title('Amino Acid Hydrophobicity','fontsize',ti_fs)

