def rbbh(args):
    p = OptionParser(rbbh.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    abfile, bafile, = args
    ab = Blast(abfile)
    ba = Blast(bafile)

    ab_hits = ab.best_hits
    ba_hits = ba.best_hits

    for aquery in ab_hits:
        ahit = ab_hits[aquery].subject
        ba_bline = ba_hits.get(ahit)
        if ba_bline:
            bhit = ba_bline.subject
            if bhit == aquery:
                print "\t".join(str(x) for x in (aquery, ahit))
%prog rbbh A_vs_B.blast B_vs_A.blast
dataset/ETHPy150Open tanghaibao/jcvi/formats/blast.py/rbbh