1

I have a script that will run for hours at a time, and I have no idea if it's frozen, how long is left, etc. I figured I would try and make a progress bar for it, but I can't seem to wrap my head around creating a progress bar that does not simply increment every X seconds (looking at you tkinter).

The end goal would be to get a very simple progress bar that lets me know my script is still working as it:

1) adds bootstrap support values to a phylogenetic tree using "support_tree = get_support(target_tree,list_of_trees)" from biopython's Phylo. <- this step takes up to 8 hours.

2) starts a new progress bar for when it loops through the nodes on the tree checking for nodes of low support (# of nodes is known, step the for loop is on is known) that increments as it loops through the nodes of the tree.

I'm pretty sure it's just my lack of experience, but I couldn't find a tutorial covering how to hook any type of progress bar into loop functions etc or that wasn't only available for python 2.x Any help is greatly appreciated!

Lostferret
  • 39
  • 1
  • 7
  • I want to use the same function from biopython (i.e, `get_support()` ) for my original tree to get its branch support values using bootstrap replicates. But it results me the tree showing values for a few of the branches and does not display for all of them. Do you have any solution for it? – Sidra Younas Jan 02 '19 at 05:12

1 Answers1

2

A progressbar can be made manually using any GUI package. I like tkinter (or ttk, a typically-included extension package to tk), which has a built-in progressbar class.

here's an example using it How to create downloading progress bar in ttk?

Here's the documentation https://docs.python.org/2/library/ttk.html#progressbar

Here's the New Mexico Tech page on it http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Progressbar.html

A simple usage would be

p = ttk.Progressbar(parent, orient=HORIZONTAL, length=200, mode='determinate')
p['maximum'] = 100
for i in range(100):
    time.sleep(1)
    p['value'] = 1

Though this example might not actually draw unless you force it to. A better example is on the linked SO page; this is just simple usage. The "value" property is how much progress has been made, and the "maximum" property is the limiting progress. If you're not used to using tkinter widgets, there are a lot of resources to get you started (the code can be extremely concise if you want it to)

Community
  • 1
  • 1
en_Knight
  • 5,301
  • 2
  • 26
  • 46
  • Thanks! It did - turns out I still hit the wall time when I run the script on my cluster..stupid bayesian analyses. I just hit the 15 requirement so here's an upvote! – Lostferret Mar 20 '15 at 21:21