def sizes(args):
    """
    %prog sizes bedfile

    Infer the sizes for each seqid. Useful before dot plots.
    """
    p = OptionParser(sizes.__doc__)
    opts, args = p.parse_args(args)

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

    bedfile, = args
    assert op.exists(bedfile)

    sizesfile = bedfile.rsplit(".", 1)[0] + ".sizes"

    fw = must_open(sizesfile, "w", checkexists=True, skipcheck=True)
    if fw:
        b = Bed(bedfile)
        for s, sbeds in b.sub_beds():
            print("{0}\t{1}".format(\
                         s, max(x.end for x in sbeds)), file=fw)
        logging.debug("Sizes file written to `{0}`.".format(sizesfile))

    return sizesfile
def sizes ( args ) : p = OptionParser ( sizes . __doc__ ) opts , args = p . parse_args ( args ) if len ( args ) != 1 : sys . exit ( not p . print_help ( ) ) bedfile , = args assert op . exists ( bedfile ) sizesfile = bedfile . rsplit ( "." , 1 ) [ 0 ] + ".sizes" fw = must_open ( sizesfile , "w" , checkexists = True , skipcheck = True ) if fw : b = Bed ( bedfile ) for s , sbeds in b . sub_beds ( ) : print ( "{0}\t{1}" . format ( s , max ( x . end for x in sbeds ) ) , file = fw ) logging . debug ( "Sizes file written to `{0}`." . format ( sizesfile ) ) return sizesfile
%prog sizes bedfile

    Infer the sizes for each seqid. Useful before dot plots.