[Biopython] problem with SeqIO.index() and get_raw

Achim Treumann Achim.Treumann at NEPAF.com
Sat Jul 31 06:05:09 UTC 2010


Dear all, 

I am new to biopython and trying to familiarise myself with its utilities. When I was trying to parse a swissprot.dat file to then copy the full data back using the get_raw attribute, I got stuck (Biopython 1.53, Python 2.6 on WinXP). 

I was using the following code:

<code>
from Bio import SeqIO
from Bio import Swissprot
InputFile = "D:\data\uniprot_sprot.short.dat"

handle = open(InputFile)
uniprot = SeqIO.index(InputFile, "swiss")
acclist=[]
for record in Swissprot.parse(handle):
    accList.append(record.accessions[0])
handle.close()
out_handle = open("D:\data\uniprot_sprot.temp.dat", "w")
for acc in accList:
    out_handle.write(uniprot.get_raw(acc)
out_handle.close()
</code>

The input file is a sprot-formatted file with 39 entries. 

When I try to run this, I get the following error:
Traceback (most recent call last):
  File"<pyshell#52>", line 2, in <module>
    handle.write(uniprot.getraw(acc))
Attribute error: 'SwissDict' object has no attribute 'get_raw'

Where am I going wrong? I have tried to replicate the corresponding example from the tutorial and got stuck at the same point with the same error message. Any help would be greatly appreciated. 

As I am typing, I realise that get_raw might only have been implemented in Biopython 1.54... I will post this anyway, and if upgrading sorts it, I will send a reply. 

Many thanks for comments and advice, 
Achim




More information about the Biopython mailing list