def split(args):
    p = OptionParser(split.__doc__)
    mode_choices = ("batch", "cycle", "optimal")
    p.add_option("--all", default=False, action="store_true",
            help="split all records [default: %default]")
    p.add_option("--mode", default="optimal", choices=mode_choices,
            help="Mode when splitting records [default: %default]")
    p.add_option("--format", choices=("fasta", "fastq", "txt", "clust"),
            help="input file format [default: %default]")

    opts, args = p.parse_args(args)

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

    filename, outdir, N = args
    fs = FileSplitter(filename, outputdir=outdir,
                      format=opts.format, mode=opts.mode)

    if opts.all:
        logging.debug("option -all override N")
        N = fs.num_records
    else:
        N = int(N)
        assert N > 0, "N must be > 0"

    logging.debug("split file into %d chunks" % N)
    fs.split(N)

    return fs
%prog split file outdir N
dataset/ETHPy150Open tanghaibao/jcvi/formats/base.py/split