49 template <
typename MapqCalculator,
typename ReadData>
54 MapqCalculator _mapq_eval,
58 const ReadData _read_data1,
59 const ReadData _read_data2) :
74 (
mate == 0) ? best : best_o,
75 (
mate == 0) ? best_o : best );
78 const uint32 read_len1 =
read_data1.sequence_index()[ read_id + 1 ] - read_offset1;
81 const uint32 read_len2 =
read_data2.sequence_index()[ read_id + 1 ] - read_offset2;
85 best_paired.
anchor_mate<0>() ? read_len2 : read_len1,
86 best_paired.
anchor_mate<0>() ? read_len1 : read_len2 ) );
114 typedef typename scoring_scheme_type::threshold_score_type threshold_score_type;
118 threshold_score_type threshold_score = scoring_scheme.threshold_score();
131 const uint32 genome_len = genome_access.
bps();
144 for (
uint32 anchor = 0; anchor < 2; ++anchor)
146 log_debug(stderr,
"[%u] anchor mate: %u\n",
ID, anchor);
152 thrust::make_counting_iterator(0u),
153 thrust::make_counting_iterator(0u) + count,
166 const bool fw_strand =
171 const bool fw = fw_strand ? params.
fw : params.
rc;
172 const bool rc = fw_strand ? params.
rc : params.
fw;
174 for (
uint32 seeding_pass = 0; seeding_pass < params.
max_reseed+1; ++seeding_pass)
194 log_debug(stderr,
"[%u] mapping (%u active reads)\n",
ID, n_active_reads);
196 device_timer.
start();
204 anchor ? reads2 : reads1, fmi, rfmi,
232 seeding_pass == (
uint32) params.persist_seeding)
237 if (seeding_pass == 0 && anchor == 0 && params.
keep_stats)
240 best_approx_score<scoring_tag>(
248 anchor ? read_data2 : read_data1,
249 anchor ? read_data1 : read_data2,
274 thrust::device_vector<io::Alignment>::iterator best_anchor_iterator =
best_data_dvec.begin();
275 thrust::device_vector<io::Alignment>::iterator best_opposite_iterator =
best_data_dvec_o.begin();
277 io::Alignment* best_anchor_ptr = thrust::raw_pointer_cast( best_anchor_iterator.base() );
278 io::Alignment* best_opposite_ptr = thrust::raw_pointer_cast( best_opposite_iterator.base() );
295 mapq_evaluator_type mapq_eval( input_scoring_scheme.
sw );
299 nvbio::transform<device_tag>(
301 thrust::make_counting_iterator<uint32>(0),
323 device_timer.
start();
338 if (
cigar.has_overflown())
346 device_timer.
start();
357 input_scoring_scheme.
sw,
392 mapq_evaluator_type mapq_eval( input_scoring_scheme.
sw );
396 nvbio::transform<device_tag>(
398 thrust::make_counting_iterator<uint32>(0),
417 device_timer.
start();
424 thrust::make_counting_iterator(0u),
425 thrust::make_counting_iterator(0u) + count,
426 best_opposite_iterator,
432 log_debug(stderr,
"[%u] paired opposite: %u\n",
ID, n_paired);
433 const uint32* paired_idx = thrust::raw_pointer_cast( paired_idx_begin.base() );
435 log_debug(stderr,
"[%u] paired opposite backtracking\n",
ID);
447 if (
cigar.has_overflown())
456 thrust::make_counting_iterator(0u),
457 thrust::make_counting_iterator(0u) + count,
458 best_opposite_iterator,
464 log_debug(stderr,
"[%u] unpaired opposite: %u\n",
ID, n_unpaired);
465 const uint32* unpaired_idx = thrust::raw_pointer_cast( unpaired_idx_begin.base() );
467 log_debug(stderr,
"[%u] unpaired opposite backtracking\n",
ID);
480 if (
cigar.has_overflown())
489 device_timer.
start();
495 thrust::make_counting_iterator(0u),
496 thrust::make_counting_iterator(0u) + count,
497 best_opposite_iterator,
503 log_debug(stderr,
"[%u] opposite alignment: %u\n",
ID, n_aligned);
504 const uint32* aligned_idx = thrust::raw_pointer_cast( aligned_idx_begin.base() );
514 input_scoring_scheme.
sw,
564 thrust::make_counting_iterator(0u),
565 thrust::make_counting_iterator(0u) + count,
566 best_anchor_iterator,
580 device_timer.
start();
583 const uint32* second_idx = thrust::raw_pointer_cast( second_idx_begin.base() );
598 if (
cigar.has_overflown())
606 device_timer.
start();
617 input_scoring_scheme.
sw,
656 device_timer.
start();
666 thrust::make_counting_iterator(0u),
667 thrust::make_counting_iterator(0u) + count,
668 best_opposite_iterator,
672 const uint32* second_idx = thrust::raw_pointer_cast( second_idx_begin.base() );
690 if (
cigar.has_overflown())
696 thrust::make_counting_iterator(0u),
697 thrust::make_counting_iterator(0u) + count,
698 best_opposite_iterator,
702 if (n_second_unpaired)
719 if (
cigar.has_overflown())
728 device_timer.
start();
732 thrust::make_counting_iterator(0u),
733 thrust::make_counting_iterator(0u) + count,
734 best_opposite_iterator,
750 input_scoring_scheme.
sw,
794 thrust::host_vector<io::Alignment> h_best_data(
BATCH_SIZE*2 );
795 thrust::host_vector<io::Alignment> h_best_data_o(
BATCH_SIZE*2 );
796 thrust::host_vector<uint8> h_mapq(
BATCH_SIZE );
804 for (
uint32 i = 0; i < count; ++i)
808 const uint8 mapq = h_mapq[i];
819 typename scoring_tag,
820 typename scoring_scheme_type>
825 const scoring_scheme_type& scoring_scheme,
831 const uint32 seeding_pass,
832 const uint32 seed_queue_size,
838 typedef typename scoring_scheme_type::threshold_score_type threshold_score_type;
841 const int32 score_limit = scoring_scheme_type::worst_score;
848 global_timer.
start();
859 const uint32 genome_len = genome_access.
bps();
865 thrust::device_vector<uint32>::iterator opposite_queue_iterator =
opposite_queue_dvec.begin();
880 active_read_queues.
resize( seed_queue_size );
883 thrust::device_ptr<const uint32>( seed_queue ),
884 thrust::device_ptr<const uint32>( seed_queue ) + seed_queue_size,
885 active_read_queues.
in_queue.begin(),
893 pipeline_type pipeline(
916 for (
uint32 extension_pass = 0; active_read_queues.
in_size && n_ext < params.
max_ext; ++extension_pass)
918 log_debug(stderr,
"[%u] pass:\n[%u] batch:[%u] %u\n[%u] seeding pass: %u\n[%u] extension pass: %u\n",
ID,
ID,
batch_number,
ID, seeding_pass,
ID, extension_pass);
927 device_timer.
start();
939 device_timer.
start();
942 pipeline.n_hits_per_read = 1;
959 pipeline.n_hits_per_read =
std::min(
988 cudaDeviceSynchronize();
995 active_read_queues.
swap();
1001 if (active_read_queues.
in_size == 0)
1006 if (pipeline.hits_queue_size == 0)
1018 pipeline.n_hits_per_read,
1019 pipeline.hits_queue_size,
1023 log_debug(stderr,
"[%u] selected %u hits\n",
ID, pipeline.hits_queue_size);
1026 device_timer.
start();
1030 pipeline.idx_queue =
sort_hi_bits( pipeline.hits_queue_size, pipeline.scoring_queues.hits.loc );
1032 device_timer.
stop();
1037 device_timer.
start();
1054 device_timer.
stop();
1065 device_timer.
start();
1071 pipeline.idx_queue =
sort_hi_bits( pipeline.hits_queue_size, pipeline.scoring_queues.hits.loc );
1073 device_timer.
stop();
1080 float score_time = 0.0f;
1081 float dev_score_time = 0.0f;
1083 device_timer.
start();
1093 device_timer.
stop();
1095 score_time += timer.
seconds();
1096 dev_score_time += device_timer.
seconds();
1106 device_timer.
start();
1113 const int32 worst_score = scoring_scheme_type::worst_score;
1116 thrust::make_counting_iterator(0u),
1117 thrust::make_counting_iterator(0u) + pipeline.hits_queue_size,
1118 thrust::make_permutation_iterator( score_queue_iterator, thrust::device_ptr<uint32>( pipeline.idx_queue ) ),
1119 opposite_queue_iterator,
1124 opposite_score_queue_iterator,
1125 opposite_score_queue_iterator + pipeline.hits_queue_size,
1128 if (pipeline.opposite_queue_size)
1131 log_debug(stderr,
"[%u] score opposite (%u)\n",
ID, pipeline.opposite_queue_size );
1145 pipeline.n_hits_per_read,
1146 pipeline.hits_queue_size,
1153 device_timer.
stop();
1162 device_timer.
start();
1178 n_ext += pipeline.n_hits_per_read;
1180 device_timer.
stop();
1182 stats.
score.
add( pipeline.hits_queue_size, score_time + timer.
seconds(), dev_score_time + device_timer.
seconds() );
1186 global_timer.
stop();