使用Python/BioPython解析BLAST结果

Wisdom_love posted @ 2008年5月21日 20:34 in Bioinformatics , 14133 阅读

在生物信息学中,对BLAST结果文件的解析是最为普遍的一个工作之一,在Perl中有BioPerl可以解析,而在Python中也有 BioPython,并且解析起来非常方便。由于BLAST的版本升级比较快,它的结果输出文件的格式有时也会相应变化,因此为了能正确的解析BLAST 结果,在做BLAST的时候使用’-m 7′参数,使输出结果保存为xml的格式,这是由于xml的格式很少随着BLAST的版本而发生变化,所以推荐使用xml文件来做自动化分析,这能保证我 们的程序能准确的解析BLAST结果。下面的代码是一个简单的框架,可以在此基础上添加内容以满足自己的需要:

#!/usr/bin/python
“”"
DESCRIPTION
Frame for parsing BLAST report

AUTHOR
Wubin Qu: quwubin@gmail.com
“”"
from Bio.Blast import NCBIXML
def parseBlast (result_file):

result_handle = open(result_file)
blast_parser = NCBIXML.BlastParser()
blast_records = blast_parser.parse(result_handle)record_list = list(blast_records)

expects = []
for record in record_list:

for alignment in record.alignments:

for hsp in alignment.hsps:

# Do whatever you want, such as
expects.append(hsp.expect)

return expects

def main ():

expects = parseBlast(Blast_report_file)
print expects

if __main__ == ‘__main__’:

main()

Avatar_small
cleaning services 说:
2022年1月25日 16:54

Aided by the continuous get higher in Covid-19 infectivity, there has become a compulsory importance of companies not to mention businesses together to invent new methods disinfecting his or her's offices not to mention business habitat, and thank goodness, a strong and tidy environment might possibly diffuse there are various spread of that infection. Disinfecting your working environment is some must-do to not have the get spread around of bacterial infection and sicknesses. Different families do acquired the clinic daily not to mention unfortunately, it is somewhat hard towards diagnose whether they have a contamination or in no way by merely contemplating their deals with; however, a possibility you could prevent the spread of that infection might be by practicing proper clinic hygiene.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter