TypeError: 'generator' object is unsubscriptable in biopython
1
0
Entering edit mode
7.5 years ago
bio90029 ▴ 10

Can anyone help me to find the error on this, please? I am trying to count the numbers of hit in an xml file but I get the above errors:

TypeError: object of type 'generator' has no len()

    from Bio import SearchIO
    blast_qresults=SearchIO.parse('my_file.xml', 'blast-xml')
    len(blast_qresults)

    or

    blast_qresults.hit

AttributeError: 'generator' object has no attribute 'hit'
biopython • 2.5k views
ADD COMMENT
1
Entering edit mode
7.5 years ago

Try with len(list(blast_qresults)).
A generator doesn't have an apriori known length, you'll first need to convert it to a list. Although that's not as memory efficient...

ADD COMMENT

Login before adding your answer.

Traffic: 1998 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6