# Path: crumbs/utils/optional_modules.py
# MSG = 'A python package to run this executable is required,'
# BIO = 'biopython'
# BIO_BGZF = 'biopython with Bgzf support'
#     NCBIXML = create_fake_class(MSG + BIO)
#     NCBIWWW = create_fake_class(MSG + BIO)
# def create_fake_class(msg):
#         def __init__(self, *args, **kwargs):
# def create_fake_funct(msg):
#     def FakeRequiredfunct(*args, **kwargs):
#     class FakePythonRequiredClass(object):


    from collections import UserDict as _dict_base
    from UserDict import DictMixin as _dict_base
from crumbs.utils.optional_modules import (_bytes_to_string, _as_bytes,
                                           SeqFileRandomAccess, Alphabet,
                                           AlphabetEncoder,
                                           _FormatToRandomAccess)

    # Map the file format to a sequence iterator:
    return _IndexedSeqFileDict(filename, format, alphabet, key_function)


class _IndexedSeqFileDict(_dict_base):
    """Read only dictionary interface to a sequential sequence file.

    Keeps the keys and associated file offsets in memory, reads the file to
    access entries as SeqRecord objects using Bio.SeqIO for parsing them.
    This approach is memory limited, but will work even with millions of
    sequences.

    Note - as with the Bio.SeqIO.to_dict() function, duplicate keys
    (record identifiers by default) are not allowed. If this happens,
    a ValueError exception is raised.

    By default the SeqRecord's id string is used as the dictionary
    key. This can be changed by suppling an optional key_function,
    a callback function which will be given the record id and must
    return the desired key. For example, this allows you to parse
    NCBI style FASTA identifiers, and extract the GI number to use
    as the dictionary key.

    Note that this dictionary is essentially read only. You cannot
    add or change values, pop values, nor clear the dictionary.
    """
    def __init__(self, filename, format, alphabet, key_function):
        # Use key_function=None for default value
        try:

# Path: crumbs/utils/optional_modules.py
# MSG = 'A python package to run this executable is required,'
# BIO = 'biopython'
# BIO_BGZF = 'biopython with Bgzf support'
#     NCBIXML = create_fake_class(MSG + BIO)
#     NCBIWWW = create_fake_class(MSG + BIO)
# def create_fake_class(msg):
#         def __init__(self, *args, **kwargs):
# def create_fake_funct(msg):
#     def FakeRequiredfunct(*args, **kwargs):
#     class FakePythonRequiredClass(object):


# Path: crumbs/third_party/index.py
    from collections import UserDict as _dict_base
    from UserDict import DictMixin as _dict_base
from crumbs.utils.optional_modules import (_bytes_to_string, _as_bytes,
                                           SeqFileRandomAccess, Alphabet,
                                           AlphabetEncoder,
                                           _FormatToRandomAccess)


    # Map the file format to a sequence iterator:
    return _IndexedSeqFileDict(filename, format, alphabet, key_function)


class _IndexedSeqFileDict(_dict_base):
    """Read only dictionary interface to a sequential sequence file.

    Keeps the keys and associated file offsets in memory, reads the file to
    access entries as SeqRecord objects using Bio.SeqIO for parsing them.
    This approach is memory limited, but will work even with millions of
    sequences.

    Note - as with the Bio.SeqIO.to_dict() function, duplicate keys
    (record identifiers by default) are not allowed. If this happens,
    a ValueError exception is raised.

    By default the SeqRecord's id string is used as the dictionary
    key. This can be changed by suppling an optional key_function,
    a callback function which will be given the record id and must
    return the desired key. For example, this allows you to parse
    NCBI style FASTA identifiers, and extract the GI number to use
    as the dictionary key.

    Note that this dictionary is essentially read only. You cannot
    add or change values, pop values, nor clear the dictionary.
    """
    def __init__(self, filename, format, alphabet, key_function):
        # Use key_function=None for default value
        try:

            proxy_class = _FormatToRandomAccess[format]