-1

Here is my code:

from Bio.Blast import NCBIWWW          
result = NCBIWWW.qblast("blastn","nt",r"C:\Users\video\Documents\sars.fasta")  
save_file = open("blast4.xml", "w")
save_file.write(result.read())
save_file.close()
result.close()
result = open("blast4.xml")
from Bio.Blast import NCBIXML
records = NCBIXML.parse(result)
blast_record = records.__next__()
# Up till here there are no problems 

for alignment in blast_record.alignments:
    for hsp in alignment.hsps:
        if hsp.expect <0.01:
            print('****Alignment****') 
            print('sequence:', alignment.title) 
            print('length:', alignment.length) 
            print('score:', hsp.score) 
            print('gaps:', hsp.gaps) 
            print('e value:', hsp.expect) 
            print(hsp.query[0.90] + '...') 
            print(hsp.match[0.90] + '...') 
            print(hsp.sbjct[0.90] + '...')

The code seems to run, but I get NO output! No tables or anything. The code just runs and nothing. What is the issue?

BioGeek
  • 21,897
  • 23
  • 83
  • 145
Johnn-1231
  • 85
  • 1
  • 1
  • 5

1 Answers1

0

What is the value of len(blast_record.alignments)? I don't know which sars.fasta file you are using, but if I try your code with this sars fasta file then the value of len(blast_record.alignments) is 0.

So I assume that your blast result doesn't contain any alignments and therefore alignment information isn't printed.

BioGeek
  • 21,897
  • 23
  • 83
  • 145