# 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/utils/tags.py
# SEQITEM = 'seqitem'
# 
# SEQRECORD = 'seqrecord'
# 
# ILLUMINA_QUALITY = 'fastq-illumina'
# 
# SANGER_QUALITY = 'fastq'
# 
# SANGER_FASTQ_FORMATS = ('fastq-sanger', 'fastq')
# 
# ILLUMINA_FASTQ_FORMATS = ('fastq-illumina',)


from copy import deepcopy
from collections import namedtuple
from crumbs.utils.optional_modules import SeqRecord
from crumbs.utils.tags import (SEQITEM, SEQRECORD, ILLUMINA_QUALITY,
                               SANGER_QUALITY, SANGER_FASTQ_FORMATS,
                               ILLUMINA_FASTQ_FORMATS)
        return _get_seqitem_qualities(seq)
    elif seq_class == SEQRECORD:
        try:
            quals = seq.object.letter_annotations['phred_quality']
        except KeyError:
            msg = 'The given SeqRecord has no phred_quality'
            raise AttributeError(msg)
        return quals


SANGER_STRS = {i - 33: chr(i)  for i in range(33, 127)}
ILLUMINA_STRS = {i - 64: chr(i) for i in range(64, 127)}


def _int_quals_to_str_quals(int_quals, out_format):
    if out_format == SANGER_QUALITY:
        quals_map = SANGER_STRS
    elif out_format == ILLUMINA_QUALITY:
        quals_map = ILLUMINA_STRS
    else:
        msg = 'Unknown or not supported quality format'
        raise ValueError(msg)
    return ''.join([quals_map[int_quality] for int_quality in int_quals])


def get_str_qualities(seq, out_format=None):
    if out_format is None:
        out_format = seq.file_format
    if out_format in SANGER_FASTQ_FORMATS:
        out_format = SANGER_QUALITY

# 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/utils/tags.py
# SEQITEM = 'seqitem'
# 
# SEQRECORD = 'seqrecord'
# 
# ILLUMINA_QUALITY = 'fastq-illumina'
# 
# SANGER_QUALITY = 'fastq'
# 
# SANGER_FASTQ_FORMATS = ('fastq-sanger', 'fastq')
# 
# ILLUMINA_FASTQ_FORMATS = ('fastq-illumina',)


# Path: crumbs/seq/seq.py
from copy import deepcopy
from collections import namedtuple
from crumbs.utils.optional_modules import SeqRecord
from crumbs.utils.tags import (SEQITEM, SEQRECORD, ILLUMINA_QUALITY,
                               SANGER_QUALITY, SANGER_FASTQ_FORMATS,
                               ILLUMINA_FASTQ_FORMATS)

        return _get_seqitem_qualities(seq)
    elif seq_class == SEQRECORD:
        try:
            quals = seq.object.letter_annotations['phred_quality']
        except KeyError:
            msg = 'The given SeqRecord has no phred_quality'
            raise AttributeError(msg)
        return quals


SANGER_STRS = {i - 33: chr(i)  for i in range(33, 127)}
ILLUMINA_STRS = {i - 64: chr(i) for i in range(64, 127)}


def _int_quals_to_str_quals(int_quals, out_format):
    if out_format == SANGER_QUALITY:
        quals_map = SANGER_STRS
    elif out_format == ILLUMINA_QUALITY:
        quals_map = ILLUMINA_STRS
    else:
        msg = 'Unknown or not supported quality format'
        raise ValueError(msg)
    return ''.join([quals_map[int_quality] for int_quality in int_quals])


def get_str_qualities(seq, out_format=None):
    if out_format is None:
        out_format = seq.file_format
    if out_format in SANGER_FASTQ_FORMATS:
        out_format = SANGER_QUALITY

    elif out_format in ILLUMINA_FASTQ_FORMATS: