Skip to content
Snippets Groups Projects
Commit e987c136 authored by Amandine  PERRIN's avatar Amandine PERRIN
Browse files

Change clustering progressbar stategy

Before, we used a pool of size 1 to run mmseqs_clust inside, and showed a progress bar in the main thread.
Now, run_mmseqs_clust runs in the main thread, and a progressbar is running in a separate thread, that is stoped when mmseqs_clust has finished.
parent 8f5e0e9d
No related branches found
No related tags found
No related merge requests found
...@@ -41,8 +41,9 @@ April 2017 ...@@ -41,8 +41,9 @@ April 2017
""" """
import logging import logging
import os import os
import sys
import time import time
import multiprocessing import threading
import progressbar import progressbar
import copy import copy
...@@ -202,21 +203,27 @@ def do_pangenome(outdir, prt_bank, mmseqdb, min_id, clust_mode, threads, start, ...@@ -202,21 +203,27 @@ def do_pangenome(outdir, prt_bank, mmseqdb, min_id, clust_mode, threads, start,
"it to a pangenome file.").format(mmseqclust)) "it to a pangenome file.").format(mmseqclust))
else: else:
logger.info("Clustering proteins...") logger.info("Clustering proteins...")
if not quiet: try:
widgets = [progressbar.BouncingBar(marker=progressbar.RotatingMarker(markers="◐◓◑◒")), stop_bar = False
" - ", progressbar.Timer()] if quiet:
bar = progressbar.ProgressBar(widgets=widgets, max_value=20, term_width=50) widgets = []
pool = multiprocessing.Pool(1) # If not quiet, start a progress bar while clustering proteins. We cannot guess
args = [mmseqdb, mmseqclust, tmpdir, logmmseq, min_id, threads, clust_mode] # how many time it will take, so we start an "infinite" bar, and send it a signal
final = pool.map_async(run_mmseqs_clust, [args], chunksize=1) # when it has to stop. If quiet, we start a thread that will immediatly stop
pool.close() else:
if not quiet: widgets = [progressbar.BouncingBar(marker=progressbar.RotatingMarker(markers="◐◓◑◒")),
while True: " - ", progressbar.Timer()]
if final.ready(): x = threading.Thread(target=utils.thread_progressbar, args=(widgets, lambda : stop_bar,))
break x.start()
bar.update() args = (mmseqdb, mmseqclust, tmpdir, logmmseq, min_id, threads, clust_mode)
bar.finish() run_mmseqs_clust(args)
pool.join() except KeyboardInterrupt: # pragma: no cover
stop_bar = True
x.join()
sys.exit(1)
# Clustering done, stop bar and join (if quiet, it was already finished, so we just join it)
stop_bar = True
x.join()
# Convert output to tsv file (one line per comparison done) # Convert output to tsv file (one line per comparison done)
# # Convert output to tsv file (one line per comparison done) # # Convert output to tsv file (one line per comparison done)
# -> returns (families, outfile) # -> returns (families, outfile)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment