%% Charge on amino acid side chains

AA={'Asp (D)','Glu (E)','Arg (R)','Lys (K)','His (H)','Cys (C)','Tyr (Y)'};
pKa=[3.9,4.3,12.0,10.5,6.08,8.28,10.1];
c_p=[0,0,1,1,1,0,0];
c_d=c_p-1;

%pH=[5 7 9];
pH=(5:.1:9)
clear charge
for pp=1:length(pH)
    for kk=1:length(pKa)
        RdivRH=10^(pH(pp)-pKa(kk));
        charge(pp,kk)=c_p(kk)*(1+RdivRH)^-1+c_d(kk)*(1+1/RdivRH)^-1;
    end
end

clr={'r','g','b','c','m','y','k'};
figure
for kk=1:length(pKa)
    plot(pH,charge(:,kk),'o-','Color',clr{kk},'linewidth',2)
    hold on
end
legend(AA)

xlabel('pH','fontsize',14)
ylabel('Average Amino Acid Side Chain Charge (e)','fontsize',14)

