Why biopython built-in calculated proteins molecular weight is different from the one calculated by my code?

Viewed 40
mw = 0 
n=0 # number of amino acid in each protein
Total=0 # total molecular weight after elimination of one molecule of water
for y,z in proteins[i].items():
    n+=z
    mw += ((weights[y]*z))
    Total=(mw-(18.015*(n-1)))
for sequence in SeqIO.parse("H:\\yeast.fasta","fasta"):
    analysed_seq = ProteinAnalysis(str(sequence.seq))
    print(sequence.id, sequence.seq, 'Mw : ', analysed_seq.molecular_weight())

First code gave me result 6760.

Second code gave me 7560.

What may be the difference for?

3 Answers

not sure but could be related to :

see here https://biopython.org/docs/1.76/api/Bio.SeqUtils.ProtParam.html

class Bio.SeqUtils.ProtParam.ProteinAnalysis(prot_sequence, monoisotopic=False) 

Bases: object Class containing methods for protein analysis.

The constructor takes two arguments. The first is the protein sequence as a string, which is then converted to a sequence object using the Bio.Seq module. This is done just to make sure the sequence is a protein sequence and not anything else.

The second argument is optional. If set to True, the weight of the amino acids will be calculated using their monoisotopic mass (the weight of the most abundant isotopes for each element), instead of the average molecular mass (the averaged weight of all stable isotopes for each element). If set to false (the default value) or left out, the IUPAC average molecular mass will be used for the calculation.

try using both:

analysed_seq = ProteinAnalysis(str(sequence.seq, monoisotopic=False))

and :

analysed_seq = ProteinAnalysis(str(sequence.seq, monoisotopic=True))

but can't tell for sure unless you tell us how your weights function does calculate Mw

More on Biopython have a look at aa Mws in IUPACData.py

from (https://github.com/biopython/biopython/blob/c560c95b6575686b4e84637111d4a4bf070053ae/Bio/Data/IUPACData.py

starting at line 219 https://github.com/biopython/biopython/blob/c560c95b6575686b4e84637111d4a4bf070053ae/Bio/Data/IUPACData.py#L219

or if you are using second answers from here: I need help to create a program that calculate molecular weight of each protein sequence in FASTA file of many sequences

that were borrowed from here : The Sum of molecular weight of proteins in python

you need to amend code :

weight = sum(weights[p] for p in seq)

in

weight = sum(weight_table[x] for x in seq) - (len(seq) - 1) * water

with water = 18.0153 ( monoisotopic water = 18.010565)

see https://github.com/biopython/biopython/blob/c560c95b6575686b4e84637111d4a4bf070053ae/Bio/SeqUtils/init.py#L485

if the peptide is circular --> weight -= water

Take home lesson: never trust an SO unaccepted answer, test every bit of code, dont forget your biochemistry studies:

Amino acids bind to each other to make polypeptide chains via a condensation reaction, which involves the elimination of a water molecule for each bond formed.

mw = 0 
n=0 # number of amino acid in each protein
Total=0 # total molecular weight after elemination of one molecule of   warter
for y,z in proteins[i].items():
    n+=z
    mw += ((weights[y]*z))
    Total=(mw-(18.015*(n-1)))

replace indentation last line :

mw = 0 
n=0 # number of amino acid in each protein
Total=0 # total molecular weight after elemination of one molecule of   warter
for y,z in proteins[i].items():
    n+=z
    mw += ((weights[y]*z))

Total=(mw-(18.015*(n-1)))
Related