AttributeError: 'Hit' object has no attribute 'sacc_ver'
0
0
Entering edit mode
6.6 years ago

Hi, I am trying to write a script to parse and summarize the ncbi web blast output (14 columns). I am using biopython searchIO on the tab delimited output file with the first seven lines commented by default.

I get the following error : AttributeError: 'Hit' object has no attribute 'sacc_ver'

In my previous post, I had described how I had to use the fields from searchIO documentation http://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-pysrc.html to replace the corresponding fields from the blast report, in the script. A: Blast parse script: ValueError: Required query and/or hit ID field not found.

from Bio import SeqIO
from Bio import SearchIO

file = "out.txt"
custom_fields = 'qseqid sseqid qaccver sacc_ver nident length mismatch gapopen qstart qend sstart send evalue score'

blast_generator = SearchIO.parse(file, 'blast-tab', fields=custom_fields, comments=True)
for blast_qresult in blast_generator:
    print "This is blast_qresult ", blast_qresult
    for k,blast_hit in enumerate(blast_qresult):
        print "This is blast_qresult.hit ", blast_hit
        query = blast_hit.id
        print "This is blast_hit.id ", query
        subject = blast_hit.sacc_ver
        print "This is blast_hit subject accession ", subject

As per http://biopython.org/DIST/docs/api/Bio.SearchIO.BlastIO-module.html, the sacc_ver attribute is present in the blast_hit object. So, I am not sure why it gives this error. Can you please help me to identify my error.

blast python searchIO bioPython • 2.1k views
ADD COMMENT
0
Entering edit mode

What version of Biopython do you have? If updating does not fix this you might want to report this at https://github.com/biopython/biopython/issues

ADD REPLY

Login before adding your answer.

Traffic: 2675 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