This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Parsing SwissProt sequences from the net

Hi all,

right now I am getting into the basics of Biopython, working through the Tutorial.

5.3.2 Parsing SwissProt sequences from the net

In this chapter following piece of code doesn't work for me:

from Bio import ExPASy

from Bio import SeqIO

with ExPASy.get_sprot_raw("O23729") as handle:

    seq_record = SeqIO.read(handle, "swiss")

printseq_record.id)

printseq_record.name)

print(seq_record.description)

print(repr(seq_record.seq))

print("Length %i" % len(seq_record))

print(seq_record.annotations["keywords"])

This is what I get at the very beginning and end of the error message:

AssertionError                            Traceback (most recent call last)

<ipython-input-2-87002128e48c> in <module>

      2 from Bio import SeqIO

      3 with ExPASy.get_sprot_raw("O23729") as handle:

----> 4     seq_record = SeqIO.read(handle, "swiss")

      5 printseq_record.id)

      6 printseq_record.name)

...

AssertionError:                 /note="Chalcone synthase 3"

I am a beginner so please bear with me :). I think the file can actually be obtained from ExPASy but

seq_record = SeqIO.read(handle, "swiss")

is where the problem starts Why is it not possible to get seq_record objects from the ExPASy file, do I have to change the SeqIO.read() function? When I use SeqIO.parse() this error returns:

AttributeError: 'generator' object has no attribute 'id'

Hope to get this solved with your help, folks! Keep it up

Best,

Cil

sequence biopython swissprot sec_record

1 answer

Hi,

It seems that problem is not on your side. As of latest Biopython 1.76, Biopython hasn't applied data format changes announced by Uniprot. I have seen some implementation in Biopython repository but not a release includes those changes. You may think to try their development version or skip this part.

Log in to answer this question.