This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython error message: Protein FASTA provided for nucleotide sequence

Hi, everyone!

Apologies for the simplistic question, but I'm just getting started with Biopython, and I'm having a lot of trouble using qblast() to blast a text file of DNA sequences in FASTA format. The relevant bit of my code is:

"fastaFile = open("all targets.txt", "r")

resultHandle = NCBIWWW.qblast("blastn", "nt", fastaFile, word_size = 7, hitlist_size = 5, megablast = True)"

with the parameters based on requirements from another member of my team. The error message is:

"ValueError: Error message from NCBI: Message ID#24 Error: Failed to read the Blast query: Protein FASTA provided for nucleotide sequence"

The sequence I'm providing is certainly not a protein FASTA. I've tried setting them all to their defaults, and I've tried a few example FASTA files, with the same error being raised. My code works fine when provided with a GI number, or a raw sequence. I'm wondering if the error is something to do with the headers of my FASTA sequences being read as part of the sequence itself, and the non-GCTA letters are causing it to be read as a protein sequence.

Thank you for reading, and I would really appreciate any help anyone could offer!

blast biopython software error fasta

can we have a look at "all targets.txt"?

1 answer

Hi, hope i can be of some help even this late. The mistake is quite simple and i have done it myself 5 minutes ago while learning qblast. Basically u are using blastn that is for nucleotides instead of blastp to process your protein.

I.e. you should do

resultHandle = NCBIWWW.qblast("blastp", "nt", fastaFile, word_size = 7, hitlist_size = 5, megablast = True)

instead of

resultHandle = NCBIWWW.qblast("blastn", "nt", fastaFile, word_size = 7, hitlist_size = 5, megablast = True)

Log in to answer this question.