This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Perform A Protein Analysis With The Protparam Module In Biopython

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

2 answers

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()

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

Thank you so much! You saved my day.

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

Thanks Best regards, Saba

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.

Log in to answer this question.