Ncbixml.Parse doesn't process all the results
1
0
Entering edit mode
2.8 years ago
Sasha ▴ 10

Greetings, I am trying to parse by Blast results using "NCBIXML.parse", however when i run it it only analysis few results and not the whole file. If anybody knows the solution to it I would really appreciate it.

from Bio.Blast import NCBIXML
E_VALUE_THRESH = 1
with open("Coilia_nasus_results.xml","r") as result:
    records= NCBIXML.parse(result)
    item=next(records)
    for alignment in item.alignments:
        for hsp in alignment.hsps:
            if hsp.expect < E_VALUE_THRESH:
                print('****Alignment****')
                print('sequence:', item.query)
                print('length:', alignment.length)
                print("e value:", hsp.expect)
                print('score:', hsp.score)
                print('gaps:', hsp.gaps)
                print(hsp.sbjct)
Blast Biopython Python • 573 views
ADD COMMENT
1
Entering edit mode
2.8 years ago
Sasha ▴ 10

Was able to resolve this issue on my own!

from Bio.Blast import NCBIXML
E_VALUE_THRESH = 1
with open("Coilia_nasus_results.xml","r") as result:
    blast_records = NCBIXML.parse(result)
    for blast_record in blast_records:
        for alignment in blast_record.alignments:
            for hsp in alignment.hsps:
                if hsp.expect < E_VALUE_THRESH:
                    print('****Alignment****')
                    print('sequence:', blast_record.query)
                    print('length:', alignment.length)
                    print("e value:", hsp.expect)
                    print('score:', hsp.score)
                    print('gaps:', hsp.gaps)
                    print(hsp.sbjct)
ADD COMMENT

Login before adding your answer.

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