# Path: kvarq/gui/util.py
# class ThemedTk(tk.Tk):
# 
#     def __init__(self, title=None, esc_closes=False, geometry=None):
#         ''' :param esc_closes: whether hitting the ``<Escape>`` key should close
#                 the window (via overridable :py:meth:`close` callback)
# 
#             :param geometry: tuple ``(width, height)`` where both parameters can
#                 be either pixels or fractions (value between 0-1) or difference
#                 from total screen dimension (value below 0) '''
# 
#         tk.Tk.__init__(self)
#         if title:
#             title = ' -- ' + title
#         else:
#             title = ''
#         self.wm_title('KvarQ ' + str(VERSION) + title)
# 
#         if sys.platform == 'win32':
#             self.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))
# 
#         self.monospace = tkFont.Font(self, family='Courier New', weight=tkFont.BOLD)
#         self.boldfont = tkFont.Font(self, weight='bold')
# 
#         if esc_closes:
#             self.bind('<Escape>', lambda x: self.close())
# 
#         if geometry:
#             sw = self.winfo_screenwidth()
#             sh = self.winfo_screenheight()
# 
#             w, h = geometry
#             if w<0: w = sw + w
#             elif w<1: w = int(sw * w)
#             if h<0: h = sh + h
#             elif h<1: h = int(sh * h)
# 
#             w = max(200, min(w, sw - 100))
#             h = max(200, min(h, sh - 200))
#             self.geometry('%dx%d+%d+%d'%(w,h,50,(sh-h)/2))
# 
#         self.focus_force()
# 
#     def close(self, x=None):
#         self.destroy()


from collections import Counter
from math import log
from kvarq.gui.util import ThemedTk
    from kvarq.genes import ancestor
    from kvarq.analyse import Coverage
import Tkinter as tk
import tkFont
import tkMessageBox
    import json

        text = '%d templates with %d' % (self.data[i], a)
        if a != b:
            text += '-' + str(b)
        text += ' hits'

        self.label.config(text=text)

    def update(self, e=None):

        self.canvas.delete('all')
        w, h = self.width(), self.height()

        x = self.data
        for i, rl in enumerate(x):
            rx = w * i / len(x)
            rh = int(float(h) * x[i] / max(x))
            rw = w * (i + 1) / len(x) - w * i / len(x)
            self.create_rectangle(rx, 0, rw, rh,
                    fill='gray', outline='')

        self.create_rectangle(0, 0, self.width(), self.height(), fill='', outline='black')


class HitHistogramWindow:

    def __init__(self, data, indexed=False):

        if data and max(data):
            title = 'Histogram of hits/template'

# Path: kvarq/gui/util.py
# class ThemedTk(tk.Tk):
# 
#     def __init__(self, title=None, esc_closes=False, geometry=None):
#         ''' :param esc_closes: whether hitting the ``<Escape>`` key should close
#                 the window (via overridable :py:meth:`close` callback)
# 
#             :param geometry: tuple ``(width, height)`` where both parameters can
#                 be either pixels or fractions (value between 0-1) or difference
#                 from total screen dimension (value below 0) '''
# 
#         tk.Tk.__init__(self)
#         if title:
#             title = ' -- ' + title
#         else:
#             title = ''
#         self.wm_title('KvarQ ' + str(VERSION) + title)
# 
#         if sys.platform == 'win32':
#             self.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))
# 
#         self.monospace = tkFont.Font(self, family='Courier New', weight=tkFont.BOLD)
#         self.boldfont = tkFont.Font(self, weight='bold')
# 
#         if esc_closes:
#             self.bind('<Escape>', lambda x: self.close())
# 
#         if geometry:
#             sw = self.winfo_screenwidth()
#             sh = self.winfo_screenheight()
# 
#             w, h = geometry
#             if w<0: w = sw + w
#             elif w<1: w = int(sw * w)
#             if h<0: h = sh + h
#             elif h<1: h = int(sh * h)
# 
#             w = max(200, min(w, sw - 100))
#             h = max(200, min(h, sh - 200))
#             self.geometry('%dx%d+%d+%d'%(w,h,50,(sh-h)/2))
# 
#         self.focus_force()
# 
#     def close(self, x=None):
#         self.destroy()


# Path: kvarq/gui/tkplot.py
from collections import Counter
from math import log
from kvarq.gui.util import ThemedTk
    from kvarq.genes import ancestor
    from kvarq.analyse import Coverage
import Tkinter as tk
import tkFont
import tkMessageBox
    import json


        text = '%d templates with %d' % (self.data[i], a)
        if a != b:
            text += '-' + str(b)
        text += ' hits'

        self.label.config(text=text)

    def update(self, e=None):

        self.canvas.delete('all')
        w, h = self.width(), self.height()

        x = self.data
        for i, rl in enumerate(x):
            rx = w * i / len(x)
            rh = int(float(h) * x[i] / max(x))
            rw = w * (i + 1) / len(x) - w * i / len(x)
            self.create_rectangle(rx, 0, rw, rh,
                    fill='gray', outline='')

        self.create_rectangle(0, 0, self.width(), self.height(), fill='', outline='black')


class HitHistogramWindow:

    def __init__(self, data, indexed=False):

        if data and max(data):
            title = 'Histogram of hits/template'

            self.win = ThemedTk(title=title, esc_closes=True, geometry=(600, 400))