I'm using the Peptides package in R to calculate the mass of peptides with the mw() method. The thing is that I want to calculate them for different pH values, and thus I wrote this little function to take the pH value into account according this image:

Enter image description here

My code is this:

phmw = function(pept_seq , unimod_location, pH ){

  monoisotopic_hydrogen_mass = 1.00794

  if(pH < 7){

    # mol_weight = mol_weight_of_peptide + mol_weight_of_Hydrogen
    mol_weight = mw(pept_seq, monoisotopic = T) + monoisotopic_hydrogen_mass

  }else if(pH > 7){

    # mol_weight = mol_weight_of_peptide - mol_weight_of_Hydrogen
    mol_weight = mw(pept_seq, monoisotopic = T) - monoisotopic_hydrogen_mass

  }else if(pH == 7){

    # mol_weight = mol_weight_of_peptide 
    mol_weight = mw(pept_seq, monoisotopic = T) 



Do you think that this approach is correct or not?

  • 2
    $\begingroup$ The code is correct as far as I can tell but there’s a lot to be said about style. The code can be made a lot shorter and more readable. Furthermore, don’t use T instead of TRUE, and don’t use return` (which is unnecessary here). Generally I suggest reading the Tidyverse style guide, even if you decide not to follow it. $\endgroup$ Jul 20, 2017 at 16:14
  • 2
    $\begingroup$ I'm curious as to the practical application? Is your interest specifically in peptides in solution at different pH values? Just wondering because most peptide MW prediction is with reference to mass spectrometry, where pH is not really relevant. $\endgroup$
    – neilfws
    Jul 21, 2017 at 4:29
  • 3
    $\begingroup$ If you want completely accurate monoisotopic mass you should use the mass of the proton rather than hydrogen. (The difference is the mass of electron). I second the question of practical applicability since each amino acid will have individual pKa, moreover, in the peptide neighboring amino acids will interact. Thus the protonation and deprotonation will happen at the different pH. $\endgroup$ Jul 21, 2017 at 9:52
  • $\begingroup$ Actually I'm trying to mimic the mass spec for some peptides and see if I can characterize them as detectable by their m/z. @neilfws Didn't understand exactly what you said. The algorithm behind the mw() assigns the masses of the a.a's from mass spec knowledge ? But one can run a mass spec experiment with different pH values ( Something that changes the mass of the total peptide). Which of these masses does the mw() algorithm uses ? $\endgroup$
    – J. Doe
    Jul 21, 2017 at 19:35
  • $\begingroup$ I'm just wondering whether protons gained by protonation due to low pH are relevant to the ions generated during MS. For example in electrospray MS "it became evident that there is no correlation between solution charging and electrospray charging" - hindawi.com/journals/ijac/2012/282574. I would think solution protons would be lost during fragmentation and ion generation. $\endgroup$
    – neilfws
    Jul 24, 2017 at 22:22

2 Answers 2


Your approach in general seems to be OK, but I have a few suggestions:

  1. You are basing all your calculations on whether the pH is above or below 7. However the N and C termini have pKa values that determine whether these groups will be ionized (8 and 3, respectively). You should check whether the pH is above/below these values instead of 7.
  2. Different amino acid side chains can also be ionized and should be accounted for when calculating the MW. Amino acid pKas can be found here
  3. Code wise: you pass a variable unimod_location in your function but it's never used. If it's not being used then take it out.

Amino-acid content (eg Lys, Asp) can have drastic effect on observance in a particular MS-mode.

You should consider including Peptides::pI() or Peptides::charge() to determine the likelihood of (de-)protonation in your calculations.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.