build a genome aligment by loading all files in a directory.

  Fiel without indexes are loaded immediately; those with indexes are
  loaded on-demand. Not recursive (i.e. subdirectories are not parsed).

  :param d_name:        directory to load from.
  :param ref_spec:      which species in the alignemnt files is the reference?
  :param extensions:    list or set of acceptable extensions; treat any files
                        with these extensions as part of the alignment. If
                        None, treat any file which has an extension that is
                        NOT in index_extensions as part of the alignment.
  :param index_exts:    treat any files with these extensions as index files.
  :param fail_no_index: fail if index extensions are provided and an alignment
                        file has no index file.

def build_genome_alignment_from_directory(d_name, ref_spec, extensions=None,
                                          index_exts=None,
                                          fail_no_index=False):
  """
  build a genome aligment by loading all files in a directory.

  Fiel without indexes are loaded immediately; those with indexes are
  loaded on-demand. Not recursive (i.e. subdirectories are not parsed).

  :param d_name:        directory to load from.
  :param ref_spec:      which species in the alignemnt files is the reference?
  :param extensions:    list or set of acceptable extensions; treat any files
                        with these extensions as part of the alignment. If
                        None, treat any file which has an extension that is
                        NOT in index_extensions as part of the alignment.
  :param index_exts:    treat any files with these extensions as index files.
  :param fail_no_index: fail if index extensions are provided and an alignment
                        file has no index file.
  """
  if index_exts is None and fail_no_index:
    raise ValueError("Failure on no index specified for loading genome " +
                     "alignment, but no index extensions specified")

  blocks = []
  for fn in os.listdir(d_name):
    pth = os.path.join(d_name, fn)
    if os.path.isfile(pth):
      _, ext = os.path.splitext(pth)
      if extensions is None or ext in extensions:
        idx_path = __find_index(pth, index_exts)
        if idx_path is None and fail_no_index:
          raise PyokitIOError("No index file for " + fn)
        for b in genome_alignment_iterator(pth, ref_spec, idx_path):
          blocks.append(b)
  return GenomeAlignment(blocks)