def load_just_in_time_genome_alignment(path, ref_spec, extensions=None,<EOL>index_exts=None, fail_no_index=True,<EOL>verbose=False):
if index_exts is None and fail_no_index:<EOL><INDENT>raise ValueError("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>extensions = __trim_extensions_dot(extensions)<EOL>index_exts = __trim_extensions_dot(index_exts)<EOL>partial_chrom_files = {}<EOL>whole_chrom_files = {}<EOL>for fn in os.listdir(path):<EOL><INDENT>pth = os.path.join(path, fn)<EOL>if os.path.isfile(pth):<EOL><INDENT>base, ext = os.path.splitext(pth)<EOL>ext = __trim_extension_dot(ext)<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>chrom, start, end = __split_genomic_interval_filename(fn)<EOL>assert((start is None and end is None) or<EOL>(start is not None and end is not None))<EOL>if start is None:<EOL><INDENT>if chrom in whole_chrom_files:<EOL><INDENT>raise PyokitIOError("<STR_LIT>" + chrom)<EOL><DEDENT>whole_chrom_files[chrom] = (pth, idx_path)<EOL><DEDENT>else:<EOL><INDENT>k = (chrom, start, end)<EOL>if k in partial_chrom_files:<EOL><INDENT>other_pth = partial_chrom_files[k][<NUM_LIT:0>]<EOL>raise PyokitIOError("<STR_LIT>" + str(k) + "<STR_LIT>" +<EOL>pth + "<STR_LIT>" + other_pth)<EOL><DEDENT>partial_chrom_files[k] = (pth, idx_path)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>def factory(k):<EOL><INDENT>pth, idx = k<EOL>return build_genome_alignment_from_file(pth, ref_spec, idx, verbose)<EOL><DEDENT>return JustInTimeGenomeAlignment(whole_chrom_files, partial_chrom_files,<EOL>factory)<EOL>
Load a just-in-time genome alignment from a directory.