NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pipeline_states.h
Go to the documentation of this file.
1 /*
2  * nvbio
3  * Copyright (c) 2011-2014, NVIDIA CORPORATION. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the NVIDIA CORPORATION nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 
31 
32 namespace nvbio {
33 namespace bowtie2 {
34 namespace cuda {
35 
38 
51 
54 
58 template <typename ScoringScheme>
59 struct BaseScoringPipelineState
60 {
65  typedef ScoringScheme scheme_type;
66 
68  const uint32 _anchor,
69  const read_batch_type _reads,
70  const read_batch_type _reads_o,
71  const uint32 _genome_len,
72  const genome_iterator _genome,
73  const fmi_type _fmi,
74  const rfmi_type _rfmi,
75  const ScoringScheme _scoring_scheme,
76  const int32 _score_limit,
77  Aligner& _aligner) :
78  anchor ( _anchor ),
79  reads ( _reads ),
80  reads_o ( _reads_o ),
81  genome_length ( _genome_len ),
82  genome ( _genome ),
83  fmi ( _fmi ),
84  rfmi ( _rfmi ),
85  hits ( _aligner.hit_deques.device_view() ),
87  opposite_queue ( _aligner.opposite_queue_dptr ),
88  dp_buffer ( _aligner.dp_buffer_dptr ),
89  dp_buffer_size ( _aligner.dp_buffer_dvec.size() ),
90  scoring_scheme ( _scoring_scheme ),
91  score_limit ( _score_limit )
92  {}
93 
97  const read_batch_type& get_reads(const uint32 mate) const { return mate ? reads_o : reads; }
98 
99  const uint32 anchor;
102 
105 
106  const fmi_type fmi;
108 
110 
112 
118 
121 
122  const ScoringScheme scoring_scheme;
124 };
125 
129 template <typename ScoringScheme>
130 struct BestApproxScoringPipelineState : public BaseScoringPipelineState<ScoringScheme>
131 {
137  typedef ScoringScheme scheme_type;
138 
140  const uint32 _anchor,
141  const read_batch_type _reads,
142  const read_batch_type _reads_o,
143  const uint32 _genome_len,
144  const genome_iterator _genome,
145  const fmi_type _fmi,
146  const rfmi_type _rfmi,
147  const ScoringScheme _scoring_scheme,
148  const int32 _score_limit,
149  Aligner& _aligner) :
150  base_type(
151  _anchor,
152  _reads,
153  _reads_o,
154  _genome_len,
155  _genome,
156  _fmi,
157  _rfmi,
158  _scoring_scheme,
159  _score_limit,
160  _aligner ),
161  trys ( _aligner.trys_dptr ),
162  rseeds ( _aligner.rseeds_dptr ),
163  best_alignments ( _aligner.best_data_dptr ),
164  best_alignments_o ( _aligner.best_data_dptr_o ),
165  best_stride ( _aligner.BATCH_SIZE )
166  {}
167 
170 
174 };
175 
179 template <typename ScoringScheme>
180 struct AllMappingPipelineState : public BaseScoringPipelineState<ScoringScheme>
181 {
187  typedef ScoringScheme scheme_type;
188 
190  const uint32 _anchor,
191  const read_batch_type _reads,
192  const read_batch_type _reads_o,
193  const uint32 _genome_len,
194  const genome_iterator _genome,
195  const fmi_type _fmi,
196  const rfmi_type _rfmi,
197  const ScoringScheme _scoring_scheme,
198  const int32 _score_limit,
199  Aligner& _aligner) :
200  base_type(
201  _anchor,
202  _reads,
203  _reads_o,
204  _genome_len,
205  _genome,
206  _fmi,
207  _rfmi,
208  _scoring_scheme,
209  _score_limit,
210  _aligner ),
211  output_read_info ( _aligner.output_read_info_dptr ),
212  buffer_read_info ( _aligner.buffer_read_info_dptr ),
213  buffer_alignments ( _aligner.buffer_alignments_dptr ),
214  cigar ( nvbio::device_view( _aligner.cigar ) ),
215  cigar_coords ( nvbio::device_view( _aligner.cigar_coords_dvec ) ),
216  mds ( nvbio::device_view( _aligner.mds ) ),
217  dp_buffer ( nvbio::device_view( _aligner.dp_buffer_dvec ) ),
218  dp_buffer_size ( _aligner.dp_buffer_dvec.size() )
219  {}
220 
224 
226  uint2* cigar_coords;
228 
231 };
232 
242 template <typename ScoringScheme>
244 {
247  typedef ScoringScheme scheme_type;
248 
257  const read_batch_type _reads1,
258  const read_batch_type _reads2,
259  const uint32 _genome_len,
260  const genome_iterator _genome,
261  const ScoringScheme _scoring_scheme,
262  Aligner& _aligner) :
263  reads ( _reads1 ),
264  reads_o ( _reads2 ),
265  genome_length ( _genome_len ),
266  genome ( _genome ),
267  scoring_scheme ( _scoring_scheme ),
268  cigar ( nvbio::device_view( _aligner.cigar ) ),
269  cigar_coords ( nvbio::device_view( _aligner.cigar_coords_dvec ) ),
270  mds ( nvbio::device_view( _aligner.mds ) ),
271  dp_buffer ( nvbio::device_view( _aligner.dp_buffer_dvec ) ),
272  dp_buffer_size ( _aligner.dp_buffer_dvec.size() )
273  {}
274 
278  const read_batch_type& get_reads(const uint32 mate) const { return mate ? reads_o : reads; }
279 
282 
285 
286  const ScoringScheme scoring_scheme;
287 
289  uint2* cigar_coords;
291 
294 };
295 
298 
299 } // namespace cuda
300 } // namespace bowtie2
301 } // namespace nvbio