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

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

    master, querybed = args
    fp = open(master)
    header = fp.next()
    assert header[0] == '#'
    qorg = header.strip().split("\t")[1]
    qorg = qorg.split(":")[-1].strip()

    store = {}
    MISSING = ("proxy", "-")
    for row in fp:
        a, b, c = row.strip().split("\t")[1:4]
        store[a] = b in MISSING and c in MISSING

    bed = Bed(querybed)
    tags = []
    for i, b in enumerate(bed):
        accn = b.accn
        if accn not in store:
            logging.warn("missing {0}".format(accn))
            continue
        tags.append((store[accn], accn))

    large = 4  # large segments
    II = []
    II_large = []
    for missing, aa in groupby(tags, key=lambda x: x[0]):
        aa = list(aa)
        if not missing:
            continue
        glist = list(a for missing, a in aa)
        II.append(glist)
        size = len(glist)
        if size >= large:
            II_large.append(glist)

    fw = must_open(opts.outfile, "w")
    for a, t in zip((II, II_large), ("", ">=4 ")):
        nmissing = sum(len(x) for x in a)
        logging.debug("A total of {0} {1}-specific {2}islands found with {3} genes.".\
                        format(len(a), qorg, t, nmissing))

    for x in II:
        print >> fw, len(x), ",".join(x)
Insert a link to an index document.
dataset/ETHPy150Open tanghaibao/jcvi/projects/synfind.py/ecoli--crossover with--dataset/ETHPy150Open nlloyd/SubliminalCollaborator/libs/twisted/lore/tree.py/setIndexLink