This is a test version of Biostars. For the public version, visit https://www.biostars.org.
BLAST using Biopython

Hello.I am new to biopython and I am trying to do BLAST search for a single query sequence. This is the script I wrote:

""" BLAST OVER INTERNET """
from Bio.Blast import NCBIWWW
file_name=input("enter the file name:")
filename = open(file_name).read()
result=NCBIWWW.qblast("blastn", "nt", "filename")
from Bio.Blast import NCBIXML
blast_record = NCBIXML.read(result)
print(len(blast_record.alignments))
evalue = 0.01
for alignment in blast_record.alignments:
   for hsp in alignment.hsps:
     if hsp.expect < evalue:
       print("****Alignment****")
       print("sequence:", alignment.title)
       print("length:", alignment.length)
       print("e value:", hsp.expect)
       print(hsp.query[0:75] + "...")
       print(hsp.match[0:75] + "...")
       print(hsp.sbjct[0:75] + "...")

So the issue I am getting is, no result is being generated. The length of the "blast_record_allignments" returns 0 value. Can anyone please help me with it? Thanks in advance

gene alignment

Please use 101010 button to format the code. Could you provide a samples fasta sequence you're using for this script?

1 answer

few problems: You pass the STRING "filename" to the NCBIWWW.qblast call instead of variable.

If the file from input should be FASTA file, then you need to pass file_name variable (without quotes) and the open(..).read() is not necessary.

Thank you so much! rectified the issue and it's working now.

Great. I’ve moved the comment to an answer, so if you’re happy with the resolution to the thread, please go ahead and toggle the Tick to accept the answer as a solution.

Log in to answer this question.