73 template <
typename ScoringScheme,
typename PipelineType,
typename ReduceContext> __global__
75 const ReduceContext context,
76 PipelineType pipeline,
81 typedef typename read_hits_type::reference hit_type;
83 scoring_queues_type& scoring_queues = pipeline.scoring_queues;
86 if (thread_id >= scoring_queues.active_read_count())
return;
89 read_hits_type read_hits( scoring_queues, thread_id );
91 const uint32 read_id = read_hits.read_info().read_id;
95 pipeline.best_alignments[ read_id ],
96 pipeline.best_alignments[ read_id + pipeline.best_stride ] );
99 const uint2 read_range = pipeline.reads.get_range(read_id);
100 const uint32 read_len = read_range.y - read_range.x;
102 const uint32 count = read_hits.size();
104 for (
uint32 i = 0; i < count; ++i)
106 hit_type hit = read_hits[i];
107 NVBIO_CUDA_DEBUG_ASSERT( hit.read_id == read_id,
"reduce hit[%u][%u]: expected id %u, got: %u (slot: %u)\n", thread_id, i, read_id, hit.read_id, scoring_queues.hits_index( thread_id, i ));
110 const uint32 read_rc = seed_info.
rc;
111 const uint32 top_flag = seed_info.top_flag;
113 const int32 score = hit.score;
114 const uint32 g_pos = hit.loc;
123 context.best_score( read_id, params );
132 context.second_score( read_id, params );
138 else if (context.failure( i, read_id, top_flag, params ))
141 pipeline.hits.erase( read_id );
150 pipeline.best_alignments[ read_id ] = best.
m_a1;
151 pipeline.best_alignments[ read_id + pipeline.best_stride ] = best.
m_a2;
154 template <
typename ReduceContext>
160 ReduceContext& context,
163 context.best_score( read_id, params );
170 NVBIO_CUDA_DEBUG_PRINT_IF( params.
debug.
show_reduce( read_id ),
"update best (anchor[%u]):\n 1. score[%d], rc[%u], pos[%u]\n 2. score[%d], rc[%u], pos[%u,%u]\n", pair.
m_a.
mate(), pair.
m_a.
score(), pair.
m_a.
is_rc(), pair.
m_a.
alignment(), pair.
m_o.
score(), pair.
m_o.
is_rc(), pair.
m_o.
alignment(), pair.
m_o.
alignment() + pair.
m_o.
sink() );
173 template <
typename ReduceContext>
179 ReduceContext& context,
182 context.best_score( read_id, params );
186 NVBIO_CUDA_DEBUG_PRINT_IF( params.
debug.
show_reduce( read_id ),
"update best (anchor[%u]):\n 1. score[%d], rc[%u], pos[%u]\n 2. score[%d], rc[%u], pos[%u,%u]\n", pair.
m_a.
mate(), pair.
m_a.
score(), pair.
m_a.
is_rc(), pair.
m_a.
alignment(), pair.
m_o.
score(), pair.
m_o.
is_rc(), pair.
m_o.
alignment, pair.
m_o.
alignment() + pair.
m_o.
sink() );
189 template <
typename ReduceContext>
195 ReduceContext& context,
198 context.second_score( read_id, params );
202 NVBIO_CUDA_DEBUG_PRINT_IF( params.
debug.
show_reduce( read_id ),
"update second (anchor[%u]):\n 1. score[%d], rc[%u], pos[%u]\n 2. score[%d], rc[%u], pos[%u,%u]\n", pair.
m_a.
mate(), pair.
m_a.
score(), pair.
m_a.
is_rc(), pair.
m_a.
alignment(), pair.
m_o.
score(), pair.
m_o.
is_rc(), pair.
m_o.
alignment, pair.
m_o.
alignment() + pair.
m_o.
sink() );
205 template <
typename ReduceContext>
211 const uint32 min_distance,
212 ReduceContext& context,
224 replace_best( read_id, best_pairs, pair, context, params );
235 update_best( read_id, best_pairs, pair, context, params );
245 update_best( read_id, best_pairs, pair, context, params );
256 template <
typename ReduceContext>
263 ReduceContext& context,
266 context.best_score( read_id, params );
273 template <
typename ReduceContext>
280 ReduceContext& context,
283 context.best_score( read_id, params );
289 template <
typename ReduceContext>
296 ReduceContext& context,
299 context.second_score( read_id, params );
305 template <
typename ReduceContext>
312 const uint32 min_distance,
313 ReduceContext& context,
334 update_best( read_id, a1, a2, a, context, params );
343 update_best( read_id, a1, a2, a, context, params );
368 template <
typename ScoringScheme,
typename PipelineType,
typename ReduceContext> __global__
370 const ReduceContext context,
371 PipelineType pipeline,
376 typedef typename read_hits_type::reference hit_type;
378 scoring_queues_type& scoring_queues = pipeline.scoring_queues;
381 if (thread_id >= scoring_queues.active_read_count())
return;
383 const uint32 anchor = pipeline.anchor;
386 read_hits_type read_hits( scoring_queues, thread_id );
388 const uint32 read_id = read_hits.read_info().read_id;
393 pipeline.best_alignments[ read_id + pipeline.best_stride ] ),
395 pipeline.best_alignments_o[ read_id + pipeline.best_stride ] ) );
398 const uint2 read_range = pipeline.reads.get_range(read_id);
399 const uint32 read_len = read_range.y - read_range.x;
401 const uint32 count = read_hits.size();
404 for (
uint32 i = 0; i < count; ++i)
406 hit_type hit = read_hits[i];
407 NVBIO_CUDA_DEBUG_ASSERT( hit.read_id == read_id,
"reduce hit[%u][%u]: expected id %u, got: %u (slot: %u)\n", thread_id, i, read_id, hit.read_id, read_hits.slot(i) );
410 const uint32 read_rc = seed_info.
rc;
411 const uint32 top_flag = seed_info.top_flag;
413 const uint2 g_pos = make_uint2( hit.loc, hit.sink );
414 const int32 score_a = hit.score;
415 const int32 score_o = hit.opposite_score;
416 const int32 score_o2 = hit.opposite_score2;
431 const uint2 o_g_pos = make_uint2( hit.opposite_loc, hit.opposite_sink );
432 const uint2 o_g_pos2 = make_uint2( hit.opposite_loc, hit.opposite_sink2 );
433 const uint32 o_read_rc = !o_fw;
436 io::Alignment( g_pos.x, g_pos.y - g_pos.x, score_a, read_rc, anchor, score_o > pipeline.score_limit ),
437 io::Alignment( o_g_pos.x, o_g_pos.y - o_g_pos.x, score_o, o_read_rc, !anchor, score_o > pipeline.score_limit ) );
440 io::Alignment( g_pos.x, g_pos.y - g_pos.x, score_a, read_rc, anchor, score_o2 > pipeline.score_limit ),
441 io::Alignment( o_g_pos2.x, o_g_pos2.y - o_g_pos2.x, score_o2, o_read_rc, !anchor, score_o2 > pipeline.score_limit ) );
443 bool updated =
false;
445 const uint32 min_distance = read_len/4;
449 if (
try_update( read_id, best_pairs, pair, min_distance, context, params ))
455 if (
try_update( read_id, best_pairs, pair2, min_distance, context, params ))
475 if (
try_update( read_id, a1, a2, a, min_distance, context, params ))
479 if ((updated ==
false) && context.failure( i, read_id, top_flag, params ))
482 pipeline.hits.erase( read_id );
488 pipeline.best_alignments[ read_id ] = best_pairs.
m_a1;
489 pipeline.best_alignments[ read_id + pipeline.best_stride ] = best_pairs.
m_a2;
490 pipeline.best_alignments_o[ read_id ] = best_pairs.
m_o1;
491 pipeline.best_alignments_o[ read_id + pipeline.best_stride ] = best_pairs.
m_o2;
504 template <
typename ScoringScheme,
typename ReduceContext>
506 const ReduceContext context,
514 detail::score_reduce_kernel<typename pipeline_type::scheme_type> <<<blocks,
BLOCKDIM>>>(
523 template <
typename ScoringScheme,
typename ReduceContext>
525 const ReduceContext context,
533 detail::score_reduce_paired_kernel<typename pipeline_type::scheme_type> <<<blocks,
BLOCKDIM>>>(