def build_genome_alignment_from_directory(d_name, ref_spec, extensions=None,<EOL>index_exts=None,<EOL>fail_no_index=False):
if index_exts is None and fail_no_index:<EOL><INDENT>raise ValueError("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>blocks = []<EOL>for fn in os.listdir(d_name):<EOL><INDENT>pth = os.path.join(d_name, fn)<EOL>if os.path.isfile(pth):<EOL><INDENT>_, ext = os.path.splitext(pth)<EOL>if extensions is None or ext in extensions:<EOL><INDENT>idx_path = __find_index(pth, index_exts)<EOL>if idx_path is None and fail_no_index:<EOL><INDENT>raise PyokitIOError("<STR_LIT>" + fn)<EOL><DEDENT>for b in genome_alignment_iterator(pth, ref_spec, idx_path):<EOL><INDENT>blocks.append(b)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return GenomeAlignment(blocks)<EOL>
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.