Exemple #1
0
    def __init__(self, jpath_or_analyser, testsuites, testsuite_paths):
        self.win = ThemedTk(title='json explorer', esc_closes=True,
                geometry=(-200, -200))

        if sys.platform == 'win32':
            self.win.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))

        self.win.columnconfigure(0, weight=1)
        self.win.columnconfigure(1, weight=0)
        self.win.rowconfigure(0, weight=0)
        self.win.rowconfigure(1, weight=0)
        self.win.rowconfigure(2, weight=4)

        if isinstance(jpath_or_analyser, Analyser):
            self.analyser = jpath_or_analyser
            name = os.path.basename(self.analyser.fastq.fname)
        else:
            try:

                data = json.load(file(jpath_or_analyser))
                update_testsuites(testsuites, data['info']['testsuites'], testsuite_paths)

                self.analyser = Analyser()
                self.analyser.decode(testsuites, data)
                self.analyser.update_testsuites()
            except Exception, e:
                exc_info = sys.exc_info()
                self.win.destroy()
                raise exc_info[1], None, exc_info[2]
            name = os.path.basename(jpath_or_analyser)
from kvarq.genes import load_testsuite
from kvarq.analyse import Analyser

# rows : genomes
# columns : SNPs
#
# table1 : mean coverage
# table2 : sd/mean
# table3 : [AX][M]
#   - D if derived has majority
#   - X if non-ancestral-non-derived has majority
#   - M if most prevalent < 90%

import json, csv, sys, os.path

analyser = Analyser()

coll_path = os.path.join(os.path.dirname(__file__), 'coll14.py')
name, testsuite = load_testsuite(coll_path)
tests = testsuite.tests
testsuites = {name: testsuite}

columns = ['filename']
columns += [str(test) for test in tests]

means = {}
sds = {}
types = {}

for fname in sys.argv[1:]:
Exemple #3
0
class JsonExplorer:

    # whishlist
    #   - file info
    #     - version, size, scantime
    #     - readlengths_hist=f(Amin), fastq_type
    #   - lineage
    #     - scores
    #   - resistances
    #     - analyse : (non) synonymous

    def __init__(self, jpath_or_analyser, testsuites, testsuite_paths):
        self.win = ThemedTk(title='json explorer', esc_closes=True,
                geometry=(-200, -200))

        if sys.platform == 'win32':
            self.win.wm_iconbitmap(bitmap = get_root_path('res', 'TPH_DNA.ico'))

        self.win.columnconfigure(0, weight=1)
        self.win.columnconfigure(1, weight=0)
        self.win.rowconfigure(0, weight=0)
        self.win.rowconfigure(1, weight=0)
        self.win.rowconfigure(2, weight=4)

        if isinstance(jpath_or_analyser, Analyser):
            self.analyser = jpath_or_analyser
            name = os.path.basename(self.analyser.fastq.fname)
        else:
            try:

                data = json.load(file(jpath_or_analyser))
                update_testsuites(testsuites, data['info']['testsuites'], testsuite_paths)

                self.analyser = Analyser()
                self.analyser.decode(testsuites, data)
                self.analyser.update_testsuites()
            except Exception, e:
                exc_info = sys.exc_info()
                self.win.destroy()
                raise exc_info[1], None, exc_info[2]
            name = os.path.basename(jpath_or_analyser)

        self.dlabel = tk.Label(self.win, text=name)
        self.dlabel.grid(row=0, column=0, columnspan=2, sticky='ew')

        self.menu = tk.Menu(self.win)
        filemenu = tk.Menu(self.menu)
        self.menu.add_cascade(label='KvarQ', menu=filemenu)
        filemenu.add_command(label='Help', command=open_help)
        self.win.config(menu=self.menu)

        # list of analyses
        self.yscroll1 = tk.Scrollbar(self.win, orient=tk.VERTICAL)
        self.yscroll1.grid(row=1, column=1, sticky='ns')
        self.alist = tk.Listbox(self.win, height=len(self.analyser.testsuites)+1, yscrollcommand=self.yscroll1.set)
        self.alist.grid(row=1, column=0, sticky='nsew')
        self.yscroll1["command"]  =  self.alist.yview
        self.alist.bind("<Double-Button-1>", self.show_analyses)
        self.alist.bind("<Return>", self.show_analyses)

        # fill in list of analyses, prepare dict of coverages
        self.anames = ['info']
        self.alist.insert(tk.END, 'info')
        for aname, testsuite in self.analyser.testsuites.items():
            self.anames.append(aname)
            result = self.analyser.results[aname]
            if type(result)==list:
                result = '; '.join(result)
            self.alist.insert(tk.END, aname + ': ' + result)

        # list of coverages
        self.yscroll2 = tk.Scrollbar(self.win, orient=tk.VERTICAL)
        self.yscroll2.grid(row=2, column=1, sticky='ns')
        self.clist = tk.Listbox(self.win, yscrollcommand=self.yscroll2.set)
        self.clist.grid(row=2, column=0, sticky='nsew')
        self.yscroll2["command"]  =  self.clist.yview
        self.clist.bind("<Double-Button-1>", self.show_coverage)
        self.clist.bind("<Return>", self.show_coverage)

        self.current = None
        self.alist.activate(0)
        self.alist.selection_set(0)
        self.alist.focus_set()

        self.after_id = None
        def close_win(a=None):
            if self.after_id:
                self.win.after_cancel(self.after_id)
            self.win.destroy()
        self.win.close = close_win
        self.win.protocol('WM_DELETE_WINDOW', close_win)
        self.poll()
from kvarq.genes import load_testsuite
from kvarq.analyse import Analyser

# rows : genomes
# columns : SNPs
#
# table1 : mean coverage
# table2 : sd/mean
# table3 : [AX][M]
#   - D if derived has majority
#   - X if non-ancestral-non-derived has majority
#   - M if most prevalent < 90%

import json, csv, sys, os.path

analyser = Analyser()

coll_path = os.path.join(os.path.dirname(__file__), 'coll14.py')
name, testsuite = load_testsuite(coll_path)
tests = testsuite.tests
testsuites = {name: testsuite}

columns = ['filename']
columns += [str(test) for test in tests]

means = {}
sds = {}
types = {}

for fname in sys.argv[1:]: