# Path: kvarq/log.py
# class ColoredFormatter(logging.Formatter):
#     def format(self, record):
# def color_wrap(handler, emit_bak):
#     def emit(record):
# def set_debug():
# def set_info():
# def set_warning():
# def appendlog(fname):
# def tic(name):
# def toc(name):
# def tictoc(name):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def format_traceback(exc_info):


import math
import gzip
import os.path
import collections
from kvarq.log import lo, tictoc
        else:
            self.fd = None

        if self.fname.endswith('.fastq.gz'):
            self.gz = True
            if not self.fd:
                self.fd = gzip.GzipFile(self.fname, 'rb')
        elif self.fname.endswith('.fastq'):
            self.gz = False
            if not self.fd:
                self.fd = open(self.fname, 'rb')
        else:
            raise FastqFileFormatException(
                        'fastq file must have extension ".fastq" or ".fastq.gz"')

        # save second name of base if exists
        self.fname2 = None
        if paired:
            base = fname[:fname.rindex('.fastq')]
            if base[-2:] == '_1':
                fname2 = base[:-2] + '_2' + fname[fname.rindex('.fastq'):]
                if os.path.exists(fname2):
                    lo.info('including paired file "%s"' % fname2)
                    self.fname2 = fname2

        if sum(self.filesizes()) == 0:
            raise FastqFileFormatException('cannot scan empty file')

        # scan some records
        min_pos, max_pos = self.min_max_score_check_file()

# Path: kvarq/log.py
# class ColoredFormatter(logging.Formatter):
#     def format(self, record):
# def color_wrap(handler, emit_bak):
#     def emit(record):
# def set_debug():
# def set_info():
# def set_warning():
# def appendlog(fname):
# def tic(name):
# def toc(name):
# def tictoc(name):
#     def decorator(f):
#         def wrapper(*args, **kwargs):
# def format_traceback(exc_info):


# Path: kvarq/fastq.py
import math
import gzip
import os.path
import collections
from kvarq.log import lo, tictoc

        else:
            self.fd = None

        if self.fname.endswith('.fastq.gz'):
            self.gz = True
            if not self.fd:
                self.fd = gzip.GzipFile(self.fname, 'rb')
        elif self.fname.endswith('.fastq'):
            self.gz = False
            if not self.fd:
                self.fd = open(self.fname, 'rb')
        else:
            raise FastqFileFormatException(
                        'fastq file must have extension ".fastq" or ".fastq.gz"')

        # save second name of base if exists
        self.fname2 = None
        if paired:
            base = fname[:fname.rindex('.fastq')]
            if base[-2:] == '_1':
                fname2 = base[:-2] + '_2' + fname[fname.rindex('.fastq'):]
                if os.path.exists(fname2):
                    lo.info('including paired file "%s"' % fname2)
                    self.fname2 = fname2

        if sum(self.filesizes()) == 0:
            raise FastqFileFormatException('cannot scan empty file')

        # scan some records
        min_pos, max_pos = self.min_max_score_check_file()

        lo.debug('min_pos=%d max_pos=%d' % (min_pos, max_pos))