'Split a FASTA file sequence by sequence.
Note that even if split_mode="number_of_parts", the actual number of
sub-files produced may not match that requested by split_size.
If split_mode="to_size" then split_size is treated as the number of
FASTA records to put in each sub-file (not size in bytes).'

def split(cls, input_datasets, subdir_generator_function, split_params):

    if (split_params is None):
        return
    if (len(input_datasets) > 1):
        raise Exception('FASTA    file    splitting    does    not    support    multiple    files')
    input_file = input_datasets[0].file_name
    if ('split_mode' not in split_params):
        raise Exception('Tool    does    not    define    a    split    mode')
    elif (split_params['split_mode'] == 'number_of_parts'):
        split_size = int(split_params['split_size'])
        log.debug(('Split    %s    into    %i    parts...' % (input_file, split_size)))
        if ((input_datasets[0].metadata is not None) and input_datasets[0].metadata.sequences):
            batch_size = (1 + (input_datasets[0].metadata.sequences // split_size))
            cls._count_split(input_file, batch_size, subdir_generator_function)
        else:
            chunk_size = (os.path.getsize(input_file) // split_size)
            cls._size_split(input_file, chunk_size, subdir_generator_function)
    elif (split_params['split_mode'] == 'to_size'):
        batch_size = int(split_params['split_size'])
        log.debug(('Split    %s    into    batches    of    %i    records...' % (input_file, batch_size)))
        cls._count_split(input_file, batch_size, subdir_generator_function)
    else:
        raise Exception(('Unsupported    split    mode    %s' % split_params['split_mode']))
