Beispiel #1
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 #2
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)
Beispiel #3
0
    def test_update_testsuites(self):

        v = StrictVersion(self.testsuites['MTBC/test'].version)
        # load by full name
        testsuites = {}
        update_testsuites(testsuites,
                {'MTBC/test': str(v)},
                self.testsuite_paths
            )
        assert testsuites.keys() == ['MTBC/test']
        # load by short name
        update_testsuites(testsuites,
                {'test': str(v)},
                self.testsuite_paths
            )
        assert set(testsuites.keys()) == set(['MTBC/test', 'test'])
        assert testsuites['test'] == testsuites['MTBC/test']

        # load compatible
        vv = list(v.version)
        vv[1] -= 1
        v.version = vv
        update_testsuites(testsuites,
                {'test': str(v)},
                self.testsuite_paths
            )
        assert set(testsuites.keys()) == set(['MTBC/test', 'test'])

        # load incompatbile 1/2
        vv[1] += 2
        v.version = vv
        try:
            update_testsuites(testsuites,
                    {'test': str(v)},
                    self.testsuite_paths
                )
            assert False, 'future minor version specified; should fail'
        except TestsuiteVersionConflictException:
            pass

        # load incompatbile 1/2
        vv[1] -= 1
        vv[0] -= 1
        v.version = vv
        try:
            update_testsuites(testsuites,
                    {'test': str(v)},
                    self.testsuite_paths
                )
            assert False, 'different major version specified; should fail'
        except TestsuiteVersionConflictException:
            pass
Beispiel #4
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)