[Biopython] SeqIO.index AttributeError: 'SeqRecord' object has no attribute 'taxonomy'
Peter Cock
p.j.a.cock at googlemail.com
Mon Nov 7 19:38:52 UTC 2011
On Mon, Nov 7, 2011 at 7:10 PM, Sheila the angel <from.d.putto at gmail.com> wrote:
> Hi All,
> Consider the following code (from Biopython Cookbook)
>
> from Bio import SeqIO
> uniprot = SeqIO.index("uniprot_sprot.dat", "swiss")
> handle = open("selected.dat", "w")
> for acc in ["P33487", "P19801", "P13689", "Q8JZQ5", "Q9TRC7"]:
> handle.write(uniprot.get_raw(acc))
> handle.close()
>
> I want to print only selected part of (ID, description and Taxonomy ) not
> the full record. I modified the code as
>
> for acc in ["P33487", "P19801", "P13689", "Q8JZQ5", "Q9TRC7"]:
> print uniprot[acc].id, uniprot[acc].description, uniprot[acc].taxonomy
>
> but this gives error "AttributeError: 'SeqRecord' object has no attribute
> 'taxonomy' "
> Any suggestion !!!!
What makes you think there would be a taxonomy attribute? Is there
a mistake in the documentation somewhere? From memory you should
try uniprot[acc].annoations["taxonomy"]
Also your code will parse the record three times for each accession,
use this instead:
for acc in ["P33487", "P19801", "P13689", "Q8JZQ5", "Q9TRC7"]:
record = uniprot[acc]
print.id, record.description, ...
Peter
Peter
More information about the Biopython
mailing list