Quantcast
Channel: Post Feed
Viewing all articles
Browse latest Browse all 41826

Extracting the from Blast xml output using Biopython and saving in .csv

$
0
0
Hello, I have the blast output in .xml form and I want to retrieve few attributes like <hit_def>. I found the parser on biophython. CODE: from Bio.Blast import NCBIXML blast = NCBIXML.parse(open('output.xml', 'rU')) for record in blast: for align in record.alignments: for hsp in align.hsps: print hsp.score, align.hit_def Q: Above code is just printing the out put on the terminal. Could anyone help me how to store the output file in .csv format. Specifically, I need output.csv with these attribute <Iteration_query-def>, <Hit_def>, <Hsp_score>, <Hsp_evalue> as columns, in a .csv format. Q2: How can I to get the result just for the best hit of each query ? While running blastp setting -max_target_seqs to 1 will do the same? Following is a segment of my input xml <Iteration_iter-num>1</Iteration_iter-num><Iteration_query-ID>Query_1</Iteration_query-ID><Iteration_query-def>comp552019_c3_seq6_V2</Iteration_query-def><Iteration_query-len>227</Iteration_query-len><Iteration_hits><Hit><Hit_num>1</Hit_num><Hit_id>gi|148727288|ref|NP_002327.2|</Hit_id><Hit_def>low-density lipoprotein receptor-related protein 6 precursor [Homo sapiens] &gt;gi|578822872|ref|XP_006719141.1| PREDICTED: low-density lipoprotein receptor-related protein 6 isoform X1 [Homo sapiens]&l ...

Viewing all articles
Browse latest Browse all 41826

Trending Articles