# 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/settings.py
# def get_setting(key):
#     'It returns the value for one setting'
#     return _settings[key]
# 
# Path: crumbs/utils/file_utils.py
# def fhand_is_seekable(fhand):
#     'It returns True if the fhand is seekable'
#     try:
#         try:
#             # The stdin stream in some instances has seek, has no seekable
#             fhand.tell()
#         except IOError:
#             return False
#         try:
#             if fhand.seekable():
#                 return True
#             else:
#                 return False
#         except AttributeError:
#             return True
#     except AttributeError:
#         return False
# 
# def peek_chunk_from_file(fhand, chunk_size):
#     'It returns the beginning of a file without moving the pointer'
#     if fhand_is_seekable(fhand):
#         fhand.seek(0)
#         chunk = fhand.read(chunk_size)
#         fhand.seek(0)
#     else:
#         chunk = fhand.peek(chunk_size)
#     return chunk
# 
# Path: crumbs/exceptions.py
# class UnknownFormatError(Exception):
#     'Raised when the format of a sequence file cannot be guessed'
#     pass
# 
# class UndecidedFastqVersionError(Exception):
#     'The file is Fastq, but the version is difficult to guess'
#     pass
# 
# class FileIsEmptyError(Exception):
#     pass


import cStringIO
import hashlib
from array import array
from crumbs.utils.optional_modules import FastqGeneralIterator
from crumbs.settings import get_setting
from crumbs.utils.file_utils import fhand_is_seekable, peek_chunk_from_file
from crumbs.exceptions import (UnknownFormatError, UndecidedFastqVersionError,
                               FileIsEmptyError)
# Copyright 2013 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# seq_crumbs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR  PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.



FILETYPE = 'file'
STRINGIOTYPE = 'stringio'
OTHERTYPE = 'othertype'


def _get_some_qual_and_lengths(fhand, force_file_as_non_seek):
    'It returns the quality characters and the lengths'

# 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/settings.py
# def get_setting(key):
#     'It returns the value for one setting'
#     return _settings[key]
# 
# Path: crumbs/utils/file_utils.py
# def fhand_is_seekable(fhand):
#     'It returns True if the fhand is seekable'
#     try:
#         try:
#             # The stdin stream in some instances has seek, has no seekable
#             fhand.tell()
#         except IOError:
#             return False
#         try:
#             if fhand.seekable():
#                 return True
#             else:
#                 return False
#         except AttributeError:
#             return True
#     except AttributeError:
#         return False
# 
# def peek_chunk_from_file(fhand, chunk_size):
#     'It returns the beginning of a file without moving the pointer'
#     if fhand_is_seekable(fhand):
#         fhand.seek(0)
#         chunk = fhand.read(chunk_size)
#         fhand.seek(0)
#     else:
#         chunk = fhand.peek(chunk_size)
#     return chunk
# 
# Path: crumbs/exceptions.py
# class UnknownFormatError(Exception):
#     'Raised when the format of a sequence file cannot be guessed'
#     pass
# 
# class UndecidedFastqVersionError(Exception):
#     'The file is Fastq, but the version is difficult to guess'
#     pass
# 
# class FileIsEmptyError(Exception):
#     pass


# Path: crumbs/seq/utils/file_formats.py
import cStringIO
import hashlib
from array import array
from crumbs.utils.optional_modules import FastqGeneralIterator
from crumbs.settings import get_setting
from crumbs.utils.file_utils import fhand_is_seekable, peek_chunk_from_file
from crumbs.exceptions import (UnknownFormatError, UndecidedFastqVersionError,
                               FileIsEmptyError)

# Copyright 2013 Jose Blanca, Peio Ziarsolo, COMAV-Univ. Politecnica Valencia
# This file is part of seq_crumbs.
# seq_crumbs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# seq_crumbs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR  PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with seq_crumbs. If not, see <http://www.gnu.org/licenses/>.



FILETYPE = 'file'
STRINGIOTYPE = 'stringio'
OTHERTYPE = 'othertype'


def _get_some_qual_and_lengths(fhand, force_file_as_non_seek):
    'It returns the quality characters and the lengths'

    seqs_to_peek = get_setting('SEQS_TO_GUESS_FASTQ_VERSION')