NVBIO
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.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 #include <nvbio/alignment/sink.h>
32 
33 namespace nvbio {
34 namespace aln {
35 
38 
41 
46 template <typename aligner_type> struct checkpoint_storage_type {
47  typedef null_type type;
48 };
49 template <AlignmentType TYPE, typename algorithm_tag> struct checkpoint_storage_type< EditDistanceAligner<TYPE,algorithm_tag> > { typedef int16 type; };
50 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct checkpoint_storage_type< HammingDistanceAligner<TYPE,scoring_type,algorithm_tag> > { typedef int16 type; };
51 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct checkpoint_storage_type< SmithWatermanAligner<TYPE,scoring_type,algorithm_tag> > { typedef int16 type; };
52 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct checkpoint_storage_type< GotohAligner<TYPE,scoring_type,algorithm_tag> > { typedef short2 type; };
53 
58 template <typename aligner_type> struct column_storage_type {
59  typedef null_type type;
60 };
61 template <AlignmentType TYPE, typename algorithm_tag> struct column_storage_type< EditDistanceAligner<TYPE,algorithm_tag> > { typedef int16 type; };
62 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct column_storage_type< HammingDistanceAligner<TYPE,scoring_type,algorithm_tag> > { typedef int16 type; };
63 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct column_storage_type< SmithWatermanAligner<TYPE,scoring_type,algorithm_tag> > { typedef int16 type; };
64 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct column_storage_type< GotohAligner<TYPE,scoring_type,algorithm_tag> > { typedef short2 type; };
65 
71 template <typename aligner_type> struct direction_vector_traits {
72  static const uint32 BITS = 2;
73 };
74 
80 template <AlignmentType TYPE, typename scoring_type, typename algorithm_tag> struct direction_vector_traits<GotohAligner<TYPE,scoring_type,algorithm_tag> > {
81  static const uint32 BITS = 4;
82 };
83 
85 
88 
93 {
96  const int32 match, const int32 mm, const int32 del, const int32 ins) :
97  m_match(match), m_mismatch(mm), m_deletion(del), m_insertion(ins) {}
98 
99  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE int32 match(const uint8 q = 0) const { return m_match; };
101  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE int32 mismatch(const uint8 a, const uint8 b, const uint8 q = 0) const { return m_mismatch; };
104 
105  int32 m_match;
109 };
110 
115 {
118  const int32 match, const int32 mm, const int32 gap_open, const int32 gap_ext) :
119  m_match(match), m_mismatch(mm), m_gap_open(gap_open), m_gap_ext(gap_ext) {}
120 
121  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE int32 match(const uint8 q = 0) const { return m_match; };
123  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE int32 mismatch(const uint8 a, const uint8 b, const uint8 q = 0) const { return m_mismatch; };
124  NVBIO_FORCEINLINE NVBIO_HOST_DEVICE int32 substitution(const uint32 r_i, const uint32 q_j, const uint8 r, const uint8 q, const uint8 qq = 0) const { return q == r ? m_match : m_mismatch; };
129 
130  int32 m_match;
134 };
135 
140 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
144  int32 min_score,
145  int32 pattern_len);
146 
151 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
155  int32 min_score,
156  int32 pattern_len);
157 
162 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
166  int32 min_score,
167  int32 pattern_len);
168 
173 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
177  int32 min_score,
178  int32 pattern_len);
179 
184 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
188  int32 min_score,
189  int32 pattern_len);
190 
195 template <AlignmentType TYPE, typename scoring_scheme_type, typename algorithm_tag>
199  int32 min_score,
200  int32 pattern_len);
201 
206 template <AlignmentType TYPE, typename algorithm_tag>
210  int32 min_score,
211  int32 pattern_len);
212 
217 template <AlignmentType TYPE, typename algorithm_tag>
221  int32 min_score,
222  int32 pattern_len);
223 
229 {
230  static const uint32 SYMBOL_SIZE = 8u;
231 
233  typedef uint8 value_type;
234  typedef uint8 reference;
235  typedef const uint8* pointer;
241 
245  uint8 operator[] (const index_type i) const { return 0u; }
246 
250  uint8 operator* () const { return 0u; }
251 
256 
260  trivial_quality_string operator++ (int dummy) { return *this; }
261 
266 
270  trivial_quality_string operator-- (int dummy) { return *this; }
271 
275  iterator begin() const { return *this; }
276 };
277 
282 {
284 
286  string_type operator[] (const uint32 i) const { return string_type(); }
287 };
288 
291 
292 } // namespace aln
293 } // namespace nvbio
294