Beispiel #1
0
def info(args):

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])
    if args.select_all:
        testsuites = load_testsuites(testsuite_paths, testsuite_paths.keys())
    else:
        testsuites = load_testsuites(testsuite_paths, args.select or [])

    print('version=' + VERSION)
    testsuites_descr = []
    tbp = tests = 0
    for name, testsuite in testsuites.items():
        bp = 0
        for test in testsuite.tests:
            if isinstance(test.template, genes.DynamicTemplate):
                bp += len(test.template.seq(spacing=args.spacing))
            else:
                bp += len(test.template.seq())
        testsuites_descr.append('%s-%s[%d:%dbp]' % (
            name, testsuite.version, len(testsuite.tests), bp))
        tbp += bp
        tests += len(testsuite.tests)
    print('testsuites=' + ','.join(testsuites_descr))
    print('sum=%d tests,%dbp' % (tests, tbp))
    print('sys.prefix=' + sys.prefix)
Beispiel #2
0
def illustrate(args):

    data = json.load(file(args.file))

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])
    testsuites = {}
    update_testsuites(testsuites, data['info']['testsuites'], testsuite_paths)

    analyser = analyse.Analyser()
    lo.info('loading json-file args.file')
    analyser.decode(testsuites, data)
    lo.info('updating testsuites')
    analyser.update_testsuites()

    if args.readlengths:
        rls = analyser.stats['readlengths']

        hist = TextHist()
        print(hist.draw(rls, indexed=True))

    if args.coverage:
        for name, testsuite in analyser.testsuites.items():
            print(name + ':')
            for test in testsuite.tests:
                print('  - %s : %s' % (test, analyser[test]))
            print()

    if args.results:
        for testsuite, results in analyser.results.items():
            print('\n'+testsuite)
            print('-'*len(testsuite))
            pprint(results)
Beispiel #3
0
def gui(args):

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])

    # only import Tkinter etc now
    import Tkinter
    from kvarq.gui.main import MainGUI
    MainGUI(testsuite_paths=testsuite_paths)
    Tkinter.mainloop()
Beispiel #4
0
def explorer(args):

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])

    import Tkinter as tk
    from kvarq.gui.explorer import DirectoryExplorer, JsonExplorer
    if os.path.isdir(args.explorable):
        DirectoryExplorer(args.explorable,
                testsuites={}, testsuite_paths=testsuite_paths)
    else:
        JsonExplorer(args.explorable,
                testsuites={}, testsuite_paths=testsuite_paths)
    tk.mainloop()
Beispiel #5
0
def scan(args):

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])
    if args.select_all:
        testsuites = load_testsuites(testsuite_paths, testsuite_paths.keys())
    else:
        testsuites = load_testsuites(testsuite_paths, args.select)

    if not testsuites:
        sys.stderr.write('\n*** you must specify at least one testsuite! ***\n\n')
        sys.stderr.write('(use the -t command line switch)\n\n')
        sys.exit(ERROR_COMMAND_LINE_SWITCH)

    # prepare scanning {{{2

    try:
        fastq = Fastq(args.fastq, paired=not args.no_paired, variant=args.variant)
    except FastqFileFormatException, e:
        lo.error('cannot open file %s : %s'%(args.fastq, str(e)))
        sys.exit(ERROR_FASTQ_FORMAT_ERROR)
Beispiel #6
0
def update(args):

    if args.fastq:
        lo.warning('re-reading of hits not currently implemented')

    data = json.load(file(args.json))

    testsuite_paths = discover_testsuites(args.testsuite_directory or [])
    testsuites = {}
    update_testsuites(testsuites, data['info']['testsuites'], testsuite_paths)

    analyser = analyse.Analyser()
    analyser.decode(testsuites, data)
    analyser.update_testsuites()

    # save results back to .json
    data = analyser.encode(hits = analyser.hits is not None)
    j = codecs.open(args.json, 'w', 'utf-8')
    lo.info('re-wrote results to file ' + args.json)
    json.dump(data, j, indent=2)
Beispiel #7
0
    def do_showlog(self, e=None):
        logwin = ThemedTk(title='contents of logfile (%s)' % logfn, geometry=(-200, -200))

        frame = tk.Frame(logwin)
        text = tk.Text(frame)
        text.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
        scroll = tk.Scrollbar(frame, command=text.yview)
        scroll.pack(side=tk.RIGHT, fill=tk.Y)
        text.config(yscrollcommand=scroll.set)
        text.yscrollbar = scroll
        frame.pack(side=tk.TOP, expand=True, fill=tk.BOTH)

        for line in file(logfn).readlines():
            text.insert(tk.END, line)
        yy = text.yscrollbar.get()
        text.yscrollbar.set(1-yy[1]+yy[0], 1)
        text.yview('moveto', 1-yy[1]+yy[0])

    def scrolldown(self):
        # autoscrolldown
        yy = self.text.yscrollbar.get()
        self.text.yscrollbar.set(1-yy[1]+yy[0], 1)
        self.text.yview('moveto', 1-yy[1]+yy[0])


if __name__=='__main__':

    win = MainGUI(testsuite_paths=discover_testsuites())
    tk.mainloop()

Beispiel #8
0
 def setUpClass(cls):
     lo.setLevel(logging.WARNING)
     cls.testsuite_paths = discover_testsuites([testsuites_alt])
     cls.testsuites = load_testsuites(cls.testsuite_paths, ['MTBC'])