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

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

    lastfile = args[0]
    bedfiles = args[1:]
    blast_table = "blast_table.txt"
    fp = open(lastfile)
    seen = set()
    for row in fp:
        c = BlastLine(row)
        a, b = c.query, c.subject
        a, b = gene_name(a), gene_name(b)
        if a > b:
            a, b = b, a
        seen.add((a, b))

    fw = open(blast_table, "w")
    for a, b in seen:
        print >> fw, "\t".join((a, b))
    fw.close()
    logging.debug("A total of {0} pairs written to `{1}`"\
            .format(len(seen), blast_table))

    fw = open("config.txt", "w")
    for bedfile in bedfiles:
        pf, stanza = write_lst(bedfile)
        print >> fw, "genome={0}".format(pf)
        for seqid, fname in stanza:
            print >> fw,  " ".join((seqid, fname))
        print >> fw

    print >> fw, "blast_table={0}".format(blast_table)
    print >> fw, "cluster_type=colinear"
    print >> fw, "tandem_gap=10"
    print >> fw, "prob_cutoff=0.001"
    print >> fw, "gap_size=20"
    print >> fw, "cluster_gap=20"
    print >> fw, "q_value=0.9"
    print >> fw, "anchor_points=4"
    print >> fw, "alignment_method=gg2"
    print >> fw, "max_gaps_in_alignment=20"
    print >> fw, "output_path=i-adhore_out"
    print >> fw, "number_of_threads=4"
    fw.close()
%prog iadhore athaliana.athaliana.last athaliana.bed
dataset/ETHPy150Open tanghaibao/jcvi/projects/synfind.py/iadhore