def _process_reads_worker(fast5_q, snp_calls_q, caller_conn, model_info, device, do_false_ref): model_info.prep_model_worker(device) map_thr_buf = mappy.ThreadBuffer() while True: try: fast5_fn, read_id = fast5_q.get(block=False) except queue.Empty: sleep(0.001) continue if fast5_fn is None: if caller_conn is not None: caller_conn.send(True) break try: raw_sig = fast5_io.get_signal(fast5_fn, read_id) read_snp_calls = process_read(raw_sig, read_id, model_info, caller_conn, map_thr_buf, do_false_ref) snp_calls_q.put((True, read_snp_calls)) except Exception as e: snp_calls_q.put((False, str(e))) pass return
def _map_read_worker(aligner, map_conn, allow_supps): LOGGER.debug('MappingWorkerStarting') # get mappy aligner thread buffer map_thr_buf = mappy.ThreadBuffer() LOGGER.debug('MappingWorkerInitComplete') while True: try: q_seq, read_id = map_conn.recv() except EOFError: LOGGER.debug('MappingWorkerClosing') break map_conn.send( align_read(q_seq, aligner, map_thr_buf, read_id, allow_supps))
def mpile(seqs): if seqs is None: return([]) thrbuf = mp.ThreadBuffer() hits = [] chrom=None for hit in a.map(seqs[1], buf=thrbuf): if (hit.NM<=min_mis_match) and ('S' not in hit.cigar_str) and ('H' not in hit.cigar_str): if chrom is None: chrom=mapping[hit.ctg] hits.append((hit.ctg, hit.r_st-1, hit.r_en)) elif mapping[hit.ctg] == chrom: hits.append((hit.ctg, hit.r_st-1, hit.r_en)) else: break return(hits)
def _map_read_worker(aligner, map_conn, mo_q): # get mappy aligner thread buffer map_thr_buf = mappy.ThreadBuffer() while True: try: q_seq, read_id = map_conn.recv() except Exception: # exit gracefully return if q_seq is None: break map_res, full_res = align_read(q_seq, aligner, map_thr_buf, read_id) map_conn.send(map_res) if mo_q is not None and full_res is not None: mo_q.put((map_res[0], full_res))
def _map_read_worker(aligner, map_conn): LOGGER.debug('MappingWorkerStarting') # get mappy aligner thread buffer map_thr_buf = mappy.ThreadBuffer() LOGGER.debug('MappingWorkerInitComplete') while True: try: q_seq, read_id = map_conn.recv() except EOFError: LOGGER.debug('MappingWorkerClosing') break map_res = align_read(q_seq, aligner, map_thr_buf, read_id) if map_res is not None: # only convert to tuple if result is valid map_res = tuple(map_res) map_conn.send(map_res)
def _process_reads_worker(bc_q, var_calls_q, caller_conn, do_false_ref): LOGGER.debug("InitWorker") map_thr_buf = mappy.ThreadBuffer() while True: try: bc_res = bc_q.get(block=True, timeout=0.1) except queue.Empty: continue if bc_res is None: LOGGER.debug("Closing") if caller_conn is not None: caller_conn.close() break try: read_var_calls = process_read(bc_res, caller_conn, map_thr_buf, do_false_ref) var_calls_q.put((True, read_var_calls)) except Exception as e: var_calls_q.put((False, str(e)))