parameters: (aln_reader, chunk_feeder, contigs_info, err_mode,
                     results_queue, error_queue, bubbles_file_handle,
                     bubbles_file_lock)
docstring: Will run in parallel
docstring_summary: Will run in parallel
docstring_tokens: Will run in parallel
function: def _thread_worker(aln_reader, chunk_feeder, contigs_info, err_mode,
                     results_queue, error_queue, bubbles_file_handle,
                     bubbles_file_lock):
      """
      Will run in parallel
      """
      try:
          while True:
              ctg_region = chunk_feeder.get_chunk()
              if ctg_region is None:
                  break
              ctg_aln = aln_reader.get_alignments(ctg_region.ctg_id, ctg_region.start,
                                                  ctg_region.end)
              ctg_id = ctg_region.ctg_id
              if len(ctg_aln) == 0:
                  continue
              ref_seq = aln_reader.get_region_sequence(ctg_region.ctg_id, ctg_region.start,
                                                       ctg_region.end)
  
              #since we are working with contig chunks, tranform alignment coorinates
              ctg_aln = aln_reader.trim_and_transpose(ctg_aln, ctg_region.start, ctg_region.end)
              ctg_aln, mean_cov = get_uniform_alignments(ctg_aln)
  
              profile, aln_errors = _compute_profile(ctg_aln, ref_seq)
              partition, num_long_bubbles = _get_partition(profile, err_mode)
              ctg_bubbles = _get_bubble_seqs(ctg_aln, profile, partition, ctg_id)
  
              ##
              coverage_cap = 0.9 * cfg.vals["max_read_coverage"]
              if mean_cov > coverage_cap:
                  mean_cov = aln_reader.get_median_depth(ctg_region.ctg_id, ctg_region.start,
                                                         ctg_region.end)
              ##
  
              ctg_bubbles, num_empty = _postprocess_bubbles(ctg_bubbles)
              ctg_bubbles, num_long_branch = _split_long_bubbles(ctg_bubbles)
  
              #transform coordinates back
              for b in ctg_bubbles:
                  b.position += ctg_region.start
  
              with bubbles_file_lock:
                  _output_bubbles(ctg_bubbles, bubbles_file_handle)
              results_queue.put((ctg_id, len(ctg_bubbles), num_long_bubbles,
                                 num_empty, num_long_branch, aln_errors,
                                 mean_cov))
  
              del profile
              del ctg_bubbles
  
      except Exception as e:
          logger.error("Thread exception")
          logger.error(traceback.format_exc())
          error_queue.put(e)
function_tokens: def _thread_worker ( aln_reader , chunk_feeder , contigs_info , err_mode , results_queue , error_queue , bubbles_file_handle , bubbles_file_lock ) : try : while True : ctg_region = chunk_feeder . get_chunk ( ) if ctg_region is None : break ctg_aln = aln_reader . get_alignments ( ctg_region . ctg_id , ctg_region . start , ctg_region . end ) ctg_id = ctg_region . ctg_id if len ( ctg_aln ) == 0 : continue ref_seq = aln_reader . get_region_sequence ( ctg_region . ctg_id , ctg_region . start , ctg_region . end ) #since we are working with contig chunks, tranform alignment coorinates ctg_aln = aln_reader . trim_and_transpose ( ctg_aln , ctg_region . start , ctg_region . end ) ctg_aln , mean_cov = get_uniform_alignments ( ctg_aln ) profile , aln_errors = _compute_profile ( ctg_aln , ref_seq ) partition , num_long_bubbles = _get_partition ( profile , err_mode ) ctg_bubbles = _get_bubble_seqs ( ctg_aln , profile , partition , ctg_id ) ## coverage_cap = 0.9 * cfg . vals [ "max_read_coverage" ] if mean_cov > coverage_cap : mean_cov = aln_reader . get_median_depth ( ctg_region . ctg_id , ctg_region . start , ctg_region . end ) ## ctg_bubbles , num_empty = _postprocess_bubbles ( ctg_bubbles ) ctg_bubbles , num_long_branch = _split_long_bubbles ( ctg_bubbles ) #transform coordinates back for b in ctg_bubbles : b . position += ctg_region . start with bubbles_file_lock : _output_bubbles ( ctg_bubbles , bubbles_file_handle ) results_queue . put ( ( ctg_id , len ( ctg_bubbles ) , num_long_bubbles , num_empty , num_long_branch , aln_errors , mean_cov ) ) del profile del ctg_bubbles except Exception as e : logger . error ( "Thread exception" ) logger . error ( traceback . format_exc ( ) ) error_queue . put ( e )