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
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
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()
Log in to answer this question.