def split_by_base_count(infile, outfiles_prefix, max_bases, max_seqs=None):
seq_reader = sequences.file_reader(infile)<EOL>base_count = <NUM_LIT:0><EOL>file_count = <NUM_LIT:1><EOL>seq_count = <NUM_LIT:0><EOL>fout = None<EOL>if max_seqs is None:<EOL><INDENT>max_seqs = float('<STR_LIT>')<EOL><DEDENT>for seq in seq_reader:<EOL><INDENT>if base_count == <NUM_LIT:0>:<EOL><INDENT>fout = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>file_count += <NUM_LIT:1><EOL><DEDENT>if base_count + len(seq) > max_bases or seq_count >= max_seqs:<EOL><INDENT>if base_count == <NUM_LIT:0>:<EOL><INDENT>print(seq, file=fout)<EOL>utils.close(fout)<EOL><DEDENT>else:<EOL><INDENT>utils.close(fout)<EOL>fout = utils.open_file_write(outfiles_prefix + '<STR_LIT:.>' + str(file_count))<EOL>print(seq, file=fout)<EOL>base_count = len(seq)<EOL>file_count += <NUM_LIT:1><EOL>seq_count = <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>base_count += len(seq)<EOL>seq_count += <NUM_LIT:1><EOL>print(seq, file=fout)<EOL><DEDENT><DEDENT>utils.close(fout)<EOL>
Splits a fasta/q file into separate files, file size determined by number of bases.

    Puts <= max_bases in each split file The exception is a single sequence >=max_bases
    is put in its own file.  This does not split sequences.