[BioPython] parse Balst results

Yair Benita Y.Benita at pharm.uu.nl
Thu Mar 27 16:43:16 EST 2003


on 27/3/2003 15:13, Yann Moalic at moalic at sb-roscoff.fr wrote:

> Hi,
> I just want to know if it's possible to extract a sequence from a blast
> result and put the sequence in a text file.
> Thanks.
> 


Use that code:

from Bio.Blast import NCBIStandalone
    

BlastFile = "BlastOut.txt"
    
blast_out = open(BlastFile,'r')
b_parser = NCBIStandalone.BlastParser()
b_iterator = NCBIStandalone.Iterator(blast_out, b_parser)


while 1:
    b_record = b_iterator.next()
    
    if b_record is None:
        break

    for Hit in b_record.alignments:
        print Hit.title #this will print the title of each hit
        
        for HSP in Hit.hsps:
            print HSP.query # this is the query sequence
            print HSP.match # these are the match lines
            print HSP.sbjct # this is the subject sequence
    

BlastFile.close()

-- 
Yair Benita
Pharmaceutical Proteomics
Utrecht University



More information about the BioPython mailing list