Пример #1
0
def test():
    cmgr = WorkCounterManager(); cmgr.start()
    c = WorkCounter(10)
    c.add_subwork(10, weights=(1.1,2.2,3,4,5,6,7,8,9,10))
    
    for i in xrange(10):
        print c
        c[i].count()
        c.count()
        sleep(1)
    print c
Пример #2
0
    def mem_test(num):
        for _n in xrange(num):
            t0 = time()
            c = WorkCounter()
            searcher = SearchEngine(abort_event)
            results = searcher.find(c, template, primer, 6)
            t1 = (time()-t0)
#            print 'results use: %fMb' % (asizeof(results)/1024.0/1024.0)
            print results
#            print_out(results, '')
            print '[%6.2f%%] elapsed %f seconds\n' % (c.percent(), t1)
 def mem_test(num):
     for _n in xrange(num):
         t0 = time()
         c = WorkCounter()
         searcher = SearchEngine(abort_event)
         results = searcher.find(c, template, primer, 6)
         t1 = (time() - t0)
         #            print 'results use: %fMb' % (asizeof(results)/1024.0/1024.0)
         print results
         #            print_out(results, '')
         print '[%6.2f%%] elapsed %f seconds\n' % (c.percent(), t1)
Пример #4
0
def test():
    cmgr = WorkCounterManager()
    cmgr.start()
    c = WorkCounter(10)
    c.add_subwork(10, weights=(1.1, 2.2, 3, 4, 5, 6, 7, 8, 9, 10))

    for i in xrange(10):
        print c
        c[i].count()
        c.count()
        sleep(1)
    print c
 def find_vs_regexp(primer, template):
     find_times = []
     re_times = []
     for _i in xrange(10):
         #find
         t0 = time()
         searcher = SearchEngine(abort_event)
         p_len, t_len = len(primer), len(template)
         res = searcher._find(WorkCounter(), template, primer, t_len, p_len,
                              10)
         find_times.append(time() - t0)
         #regexp
         t0 = time()
         fwd_seq = str(template.seq)
         rev_seq = str(template.seq.reverse_complement())
         primer_re = primer2re(primer)
         fwd_res = primer_re.findall(fwd_seq)
         rev_res = primer_re.findall(rev_seq)
         re_times.append(time() - t0)
     print 'find results: f %d, r %d' % (len(res[5]), len(res[6]))
     print 're results:   f %d, r %d' % (len(fwd_res), len(rev_res))
     #        print template.seq[res[5][0]:res[5][0]+p_len]
     #        print fwd_res[0]
     return find_times, re_times
    #end def

    ppid = os.getpid()
    import DegenPrimer.TD_Functions as tdf
    from DegenPrimer.SearchEngine import SearchEngine
    from DegenPrimer.WorkCounter import WorkCounter
    tdf.PCR_P.PCR_T = 60

    searcher = SearchEngine(abort_event)

    cProfile.runctx(
        'for x in xrange(10): searcher._find(WorkCounter(), template, primer, len(template), len(primer), 6)',
        globals(), locals(), 'SearchEngine._find.profile')

    matches = searcher._find_mp(WorkCounter(), template[:2000], primer,
                                len(template), len(primer), 6)
    cProfile.runctx(
        'for x in xrange(10): searcher.compile_duplexes(WorkCounter(), *matches)',
        globals(), locals(), 'SearchEngine.compile_duplexes.profile')

    f = 'test_search_results.txt'
    dups = searcher.compile_duplexes(WorkCounter(), *matches)
    if not os.path.isfile(f):
        with open(f, 'w') as out:
            out.write(str(dups))
        sys.exit()
    else:
        with open(f, 'r') as inp:
            if str(dups) != inp.read():
                with open(f + '.wrong', 'w') as out: