选择blast比对第一条best hit的结果

blast的结果中每条contig都会有很多hit,最好不用max_target_hit这个参数,因为它输出的是数据库中top的序列而不一定是比对最好的序列,即使所有版本都包含相同的最佳匹配结果,但是BLAST却返回不同的结果。而且以不同的方式对数据库进行排序,也会导致在将max_target_seqs参数设置为1时,BLAST返回不同的“top hit”。因此我们需要自己挑出所有hit中第一条打分最高的hit。
参考:https://www.jianshu.com/p/7eb530bc1a9c

nohup time blastn -db ref_prok_rep_genomes -query ../nextpolish/genome.nextpolish.fasta -perc_identity 90 -num_threads 16 -evalue 1e-5 -outfmt "6 std sscinames qcovus" -out nextpolish_blast_all.txt &

python blast_best.py nextpolish_blast_all.txt nextpolish_blast_best.txt
#!/usr/bin/python
# -*- coding: utf-8 -*-
# conda activate python3
"""
    作者:徐诗芬
    内容:读取并输出所有blast结果中最好的第一条hit结果
    日期:2021.1.22
"""
import sys

def usage():
    print('Usage: python blast_best.py [input_file] [outfile]')


def main():

    # global name
    inf = open(sys.argv[1], 'rt')
    ouf = open(sys.argv[2], 'wt')

    flag_list = []
    for line in inf:
        line = line.strip()
        name = line.split("\t")[0]
        #id = eval(line.split("\t")[2])
        if name not in flag_list:
            ouf.write(line + '\n')
        else:
            continue
        flag_list.append(name)

    inf.close()
    ouf.close()

try:
    main()
except IndexError:
    usage()
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 夜莺2517阅读 127,806评论 1 9
  • 版本:ios 1.2.1 亮点: 1.app角标可以实时更新天气温度或选择空气质量,建议处女座就不要选了,不然老想...
    我就是沉沉阅读 11,843评论 1 6
  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 12,728评论 28 53
  • 兔子虽然是枚小硕 但学校的硕士四人寝不够 就被分到了博士楼里 两人一间 在学校的最西边 靠山 兔子的室友身体不好 ...
    待业的兔子阅读 7,512评论 2 9