コード例 #1
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example3():
    widgets = [Bar('>'), ' ', ETA(), ' ', ReverseBar('<')]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10*i+1)
    pbar.finish()
コード例 #2
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example1():
    widgets = ['Test: ', Percentage(), ' ', Bar(marker=RotatingMarker()),
               ' ', ETA(), ' ', FileTransferSpeed()]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10*i+1)
    pbar.finish()
コード例 #3
0
def example15():
    # You may need python 3.x to see this correctly
    try:
        widgets = ['Wheels: ', AnimatedMarker(markers='◐◓◑◒')]
        pbar = ProgressBar(widgets=widgets)
        for i in pbar((i for i in range(24))):
            time.sleep(0.3)
    except UnicodeError:
        sys.stdout.write('Unicode error: skipping example')
コード例 #4
0
def example17():
    widgets = [
        FormatLabel('Animated Bouncer: value %(value)d - '),
        BouncingBar(marker=RotatingMarker())
    ]

    pbar = ProgressBar(widgets=widgets)
    for i in pbar((i for i in range(180))):
        time.sleep(0.05)
コード例 #5
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example4():
    widgets = ['Test: ', Percentage(), ' ',
               Bar(marker='0',left='[',right=']'),
               ' ', ETA(), ' ', FileTransferSpeed()]
    pbar = ProgressBar(widgets=widgets, maxval=500)
    pbar.start()
    for i in range(100,500+1,50):
        time.sleep(0.2)
        pbar.update(i)
    pbar.finish()
コード例 #6
0
def example3():
    widgets = [Bar('>'), ' ', ETA(), ' ', ReverseBar('<')]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10 * i + 1)
    pbar.finish()
コード例 #7
0
def example4():
    widgets = [
        'Test: ',
        Percentage(), ' ',
        Bar(marker='0', left='[', right=']'), ' ',
        ETA(), ' ',
        FileTransferSpeed()
    ]
    pbar = ProgressBar(widgets=widgets, maxval=500)
    pbar.start()
    for i in range(100, 500 + 1, 50):
        time.sleep(0.2)
        pbar.update(i)
    pbar.finish()
コード例 #8
0
 def __init__(self, args, unknown_args):
     self.args = args
     self.unknown_args = unknown_args
     self.option = checkInput(args)
     #
     env.logger = getLogger(max(min(args.verbosity - 1, 2), 0),
                            fn=os.path.splitext(args.output[0])[0],
                            fv=2 if args.verbosity is not 0 else 0)
     env.logger.debug('\n{0}\n{1}\n{0}'.format(
         "=" * min(len(args.cmd), 100), args.cmd))
     self.logger = env.logger.info if args.verbosity != 1 else printinfo
     #
     self.logger('Loading data from [{}] ...'.format(args.data))
     if self.option == 1:
         self.file = SFSFile(args.data)
     else:
         self.file = GFile(args.data)
     self.groups = self.file.getnames()
     self.logger('{:,d} units found'.format(len(self.groups)))
     # load non-missing data
     # to annotate to each variant position wether or not it is missing from assocation analysis
     # name it chip_file because it mimics the behavior of exome chip design
     if args.missing_unlisted:
         self.chip_file = SFSFile(args.missing_unlisted)
     else:
         self.chip_file = None
     # set limit
     if self.args.limit:
         self.limit = min(max(1, args.limit), len(self.groups))
         self.logger('{:,d} units will be analyzed'.format(self.limit))
     else:
         self.limit = len(self.groups)
     self.result = ResultManager(args.output,
                                 action='w' if not args.append else 'a')
     if self.args.verbosity == 1:
         # widgets = [FormatLabel('scanning: unit %(value)d - '), BouncingBar(marker=RotatingMarker())]
         widgets = [
             FormatLabel('scanning: unit %(value)d - '),
             Percentage(), ' ',
             Bar('>'), ' ',
             ETA()
         ]
         self.pbar = ProgressBar(widgets=widgets,
                                 maxval=self.limit,
                                 term_width=get_terminal_size()[0] -
                                 5).start()
     else:
         # use each group's progress bar or not progress bar at all
         self.pbar = ProgressBarNull()
     # this is buffer object to hold all input dict to a list
     self.data_buffer = [] if self.args.replicates < 0 else None
コード例 #9
0
 def run(self):
     '''run multiple replicates'''
     if self.data['verbosity'] <= 1:
         iterations = range(self.data['replicates'])
     else:
         widgets = [
             '{0} : '.format(self.data['name']),
             Percentage(), ' ',
             Bar('='), ' ',
             ETA()
         ]
         pbar = ProgressBar(widgets=widgets,
                            maxval=self.data['replicates'],
                            term_width=get_terminal_size()[0] - 5)
         iterations = pbar((i for i in range(self.data['replicates'])))
     nJobs = max(min(self.data['jobs'], self.data['replicates']), 1)
     workQueue = Queue()
     resQueue = Queue()
     # put all replicates + stop signals in queue
     for replicate in range(self.data['replicates']):
         workQueue.put(replicate)
     for i in range(nJobs):
         workQueue.put(None)
     # spawn workers
     procs = [
         Process(target=self.calculate, args=(workQueue, resQueue))
         for j in range(nJobs)
     ]
     for p in procs:
         p.start()
     # collect the results off the queue
     for i in iterations:
         try:
             self.__save(resQueue.get())
         except KeyboardInterrupt as e:
             raise ValueError("calculator terminated!")
     for p in procs:
         p.join()
     if self.failure_count.value():
         env.logger.info("{} invalid replicate(s)".format(
             self.failure_count.value()))
         self.data['replicates'] = self.data[
             'replicates'] - self.failure_count.value()
     return {} if len(self.result) == 0 else dict(
         list(self.data.items()) + list(self.result.items()))
コード例 #10
0
def example1():
    widgets = [
        'Test: ',
        Percentage(), ' ',
        Bar(marker=RotatingMarker()), ' ',
        ETA(), ' ',
        FileTransferSpeed()
    ]
    pbar = ProgressBar(widgets=widgets, maxval=10000000).start()
    for i in range(1000000):
        # do something
        pbar.update(10 * i + 1)
    pbar.finish()
コード例 #11
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example2():
    class CrazyFileTransferSpeed(FileTransferSpeed):
        "It's bigger between 45 and 80 percent"
        def update(self, pbar):
            if 45 < pbar.percentage() < 80:
                return 'Bigger Now ' + FileTransferSpeed.update(self,pbar)
            else:
                return FileTransferSpeed.update(self,pbar)

    widgets = [CrazyFileTransferSpeed(),' <<<', Bar(), '>>> ',
               Percentage(),' ', ETA()]
    pbar = ProgressBar(widgets=widgets, maxval=10000000)
    # maybe do something
    pbar.start()
    for i in range(2000000):
        # do something
        pbar.update(5*i+1)
    pbar.finish()
コード例 #12
0
def example2():
    class CrazyFileTransferSpeed(FileTransferSpeed):
        "It's bigger between 45 and 80 percent"

        def update(self, pbar):
            if 45 < pbar.percentage() < 80:
                return 'Bigger Now ' + FileTransferSpeed.update(self, pbar)
            else:
                return FileTransferSpeed.update(self, pbar)

    widgets = [
        CrazyFileTransferSpeed(), ' <<<',
        Bar(), '>>> ',
        Percentage(), ' ',
        ETA()
    ]
    pbar = ProgressBar(widgets=widgets, maxval=10000000)
    # maybe do something
    pbar.start()
    for i in range(2000000):
        # do something
        pbar.update(5 * i + 1)
    pbar.finish()
コード例 #13
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example6():
    pbar = ProgressBar().start()
    for i in range(100):
        time.sleep(0.01)
        pbar.update(i + 1)
    pbar.finish()
コード例 #14
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example5():
    pbar = ProgressBar(widgets=[SimpleProgress()], maxval=17).start()
    for i in range(17):
        time.sleep(0.2)
        pbar.update(i + 1)
    pbar.finish()
コード例 #15
0
def example5():
    pbar = ProgressBar(widgets=[SimpleProgress()], maxval=17).start()
    for i in range(17):
        time.sleep(0.2)
        pbar.update(i + 1)
    pbar.finish()
コード例 #16
0
def example6():
    pbar = ProgressBar().start()
    for i in range(100):
        time.sleep(0.01)
        pbar.update(i + 1)
    pbar.finish()
コード例 #17
0
def example7():
    pbar = ProgressBar()  # Progressbar can guess maxval automatically.
    for i in pbar(range(80)):
        time.sleep(0.01)
コード例 #18
0
ファイル: examples.py プロジェクト: rahapazoki/SEQPower
def example0():
    pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=300).start()
    for i in range(300):
        time.sleep(0.01)
        pbar.update(i+1)
    pbar.finish()
コード例 #19
0
def example8():
    pbar = ProgressBar(maxval=80)  # Progressbar can't guess maxval.
    for i in pbar((i for i in range(80))):
        time.sleep(0.01)
コード例 #20
0
def example9():
    pbar = ProgressBar(widgets=['Working: ', AnimatedMarker()])
    for i in pbar((i for i in range(50))):
        time.sleep(.08)
コード例 #21
0
def example0():
    pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=300).start()
    for i in range(300):
        time.sleep(0.01)
        pbar.update(i + 1)
    pbar.finish()
コード例 #22
0
def example10():
    widgets = ['Processed: ', Counter(), ' lines (', Timer(), ')']
    pbar = ProgressBar(widgets=widgets)
    for i in pbar((i for i in range(150))):
        time.sleep(0.1)
コード例 #23
0
def example16():
    widgets = [FormatLabel('Bouncer: value %(value)d - '), BouncingBar()]
    pbar = ProgressBar(widgets=widgets)
    for i in pbar((i for i in range(180))):
        time.sleep(0.05)
コード例 #24
0
def example11():
    widgets = [FormatLabel('Processed: %(value)d lines (in: %(elapsed)s)')]
    pbar = ProgressBar(widgets=widgets)
    for i in pbar((i for i in range(150))):
        time.sleep(0.1)
コード例 #25
0
def example12():
    widgets = ['Balloon: ', AnimatedMarker(markers='.oO@* ')]
    pbar = ProgressBar(widgets=widgets)
    for i in pbar((i for i in range(24))):
        time.sleep(0.3)