BLAST using Biopython
1
0
Entering edit mode
5.5 years ago
a.lathifbt ▴ 30

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 • 1.3k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
2
Entering edit mode
5.5 years ago

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.

ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY

Login before adding your answer.

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