How To Perform A Protein Analysis With The Protparam Module In Biopython
2
2
Entering edit mode
11.8 years ago
saba.bsbi154 ▴ 20

I am using this code for getting protein parameters from Protparam:

http://www.biopython.org/DIST/docs/api/Bio.SeqUtils.ProtParam-pysrc.html

But the problem is that I have many protein sequencs for which I want to calculate the features. so I am using following code for reading sequences in fasta format and storing the parsed sequence in variable a and passing it to function but its not working....:

handle = open("example.fasta", "rU") for record in SeqIO.parse(handle, "fasta") : a = t record.seq

X = ProtParam.ProteinAnalysis(a)

I would really appreciate if anybody could help me.. Many thanks Best regards,

Saba

biopython protein • 9.6k views
ADD COMMENT
8
Entering edit mode
11.8 years ago

Since the ProtParam module takes the protein sequence as a string you have to call str() on a Seq object to return the full sequence as a string.

This is a bit tricky, because you often don't actually have to do this conversion explicitly, because Python does this automatically with a print statement. If you are using Biopython 1.44 or older, using str(record.seq) will give just a truncated representation. Instead use record.seq.tostring() which is still available in the current Biopython releases for backwards compatibility.

For example:

from Bio import SeqIO
from Bio.SeqUtils import ProtParam

handle = open("example.fasta") 
for record in SeqIO.parse(handle, "fasta"): 
    seq = str(record.seq)
    X = ProtParam.ProteinAnalysis(seq)
    print X.count_amino_acids() 
    print X.get_amino_acids_percent() 
    print X.molecular_weight() 
    print X.aromaticity() 
    print X.instability_index() 
    print X.flexibility() 
    print X.isoelectric_point() 
    print X.secondary_structure_fraction()
ADD COMMENT
0
Entering edit mode

Biopython 1.44 was released in 2007, do you think we can stop worrying about this now? We're considering removing the tostring() method... https://github.com/biopython/biopython/pull/137

ADD REPLY
0
Entering edit mode

Some of the functions are no longer available, such as molecular_wight()

ADD REPLY
0
Entering edit mode

Thank you so much! You saved my day.

ADD REPLY
0
Entering edit mode
11.8 years ago
saba.bsbi154 ▴ 20

Thank you so very much for your help. It worked...:)

Thanks Best regards, Saba

ADD COMMENT
0
Entering edit mode

Saba, please accept a.zielezinski's answer rather than commenting with your own answer. That way he'll get a nice tick mark and your question will be marked as solved.

ADD REPLY

Login before adding your answer.

Traffic: 2492 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6