def generate_all_options(fasta_dict, window_length, keep_every_nd=1, num_entries=0):
  """Generates all possible sequence options for every entry in a fasta_dict.
  Calculates according to a moving window of size window_length, like:
  'BAAAC' -> '[BAAA]C' + 'B[AAAC] -> ['BAAA', 'AAAC']
  
  Args:
    fasta_dict: A sequence dict from parse_fasta
    window_length: int, size of the moving window
    keep_every_nd: int; Keep every nd sequence like sequences[0::nd]
    num_entries: Maximal number of entries, 0 if all
  Returns:
    A fasta_dict but with all possible options
  """
  all_sequence_dict = {}
  for header in fasta_dict:
    all_sequence_dict[header] = []
    for sequence in fasta_dict[header]:
      seq_length = len(sequence)
      if seq_length < window_length:  # can't get window
        continue
      num_windows = seq_length - window_length + 1
      for win_start in range(num_windows):
        win_end = win_start + window_length
        window = sequence[win_start:win_end]
        all_sequence_dict[header].append(window)
    # check if we added any windows, otherwise delete entry
    if len(all_sequence_dict[header]) == 0:
      del all_sequence_dict[header]
    elif keep_every_nd is not 1:
      all_sequence_dict[header] = all_sequence_dict[header][0::keep_every_nd]
  if num_entries > 0:
    # Select the "first" n keys
    kept_headers = list(all_sequence_dict.keys())[0:num_entries]
    # Create a new dict with those keys
    all_sequence_dict = {header: all_sequence_dict[header] for header in kept_headers}
  return all_sequence_dict