This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to print the best matching hit while making a BLAST search? / BioPython

Hi everyone,

I need your help with something.

I'm trying to making a BLAST search with a nucleotide sequence and print the best matching hit but not sure about which option/command should I use. There are options like ''max_hpsp'' and ''best_hit_overhang''. I don't have an idea about their differences and I want to print just 1 hit. (best matching one) Should i use '' max_hpsp 1'' ?

I wrote this code but it's still not useful. If you could tell me, where i am mistaken and what should to do, I would be very appreciated :) Thank you!

from Bio.Blast import NCBIWWW
seq = Seq("GTTGA......CT")
def best_matching_hit(seq):
try:
    result_handle = NCBIWWW.qblast("blastn", "nt", seq)
except:
    print('BLAST run failed!')
    return None
blast_record = NCBIXML.read(result_handle)
for hit in blast_record.alignments:
    for hsp in hit.hsps:
        if hsp.expect == max_hsps 1:
            print(hit.title)
            print(hsp.sbjct)

 best_matching_hit(seq)
biopython blast best_hit_overhang max_hpsp hit

0 answers

No answers yet.

Log in to answer this question.