1 // ==========================================================================
2 //                 SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2015, Knut Reinert, FU Berlin
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions are met:
9 //
10 //     * Redistributions of source code must retain the above copyright
11 //       notice, this list of conditions and the following disclaimer.
12 //     * Redistributions in binary form must reproduce the above copyright
13 //       notice, this list of conditions and the following disclaimer in the
14 //       documentation and/or other materials provided with the distribution.
15 //     * Neither the name of Knut Reinert or the FU Berlin nor the names of
16 //       its contributors may be used to endorse or promote products derived
17 //       from this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
23 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
29 // DAMAGE.
30 //
31 // ==========================================================================
32 // Author: Manuel Holtgrewe <manuel.holtgrewe@fu-berlin.de>
33 // ==========================================================================
34 // Test for globalAlignmentScore() implementations that use Hirschberg and
35 // MyersBitVector, MyersHirschberg.
36 // ==========================================================================
37 
38 #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_GLOBAL_ALIGNMENT_SPECIALIZED_H_
39 #define SEQAN_INCLUDE_SEQAN_ALIGN_GLOBAL_ALIGNMENT_SPECIALIZED_H_
40 
41 namespace seqan {
42 
43 // ============================================================================
44 // Forwards
45 // ============================================================================
46 
47 // ============================================================================
48 // Tags, Classes, Enums
49 // ============================================================================
50 
51 // ============================================================================
52 // Metafunctions
53 // ============================================================================
54 
55 // ============================================================================
56 // Functions
57 // ============================================================================
58 
59 // ----------------------------------------------------------------------------
60 // Function globalAlignment()                                      [Hirschberg]
61 // ----------------------------------------------------------------------------
62 
63 template <typename TSequence, typename TAlignSpec,
64           typename TScoreValue, typename TScoreSpec>
globalAlignment(Align<TSequence,TAlignSpec> & align,Score<TScoreValue,TScoreSpec> const & scoringScheme,Hirschberg const & algorithmTag)65 TScoreValue globalAlignment(Align<TSequence, TAlignSpec> & align,
66                             Score<TScoreValue, TScoreSpec> const & scoringScheme,
67                             Hirschberg const & algorithmTag)
68 {
69     SEQAN_ASSERT_EQ(length(rows(align)), 2u);
70     return _globalAlignment(row(align, 0), row(align, 1), scoringScheme, algorithmTag);
71 }
72 
73 template <typename TSequenceH, typename TGapsSpecH,
74           typename TSequenceV, typename TGapsSpecV,
75           typename TScoreValue, typename TScoreSpec>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,Score<TScoreValue,TScoreSpec> const & scoringScheme,Hirschberg const & algorithmTag)76 TScoreValue globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
77                             Gaps<TSequenceV, TGapsSpecV> & gapsV,
78                             Score<TScoreValue, TScoreSpec> const & scoringScheme,
79                             Hirschberg const & algorithmTag)
80 {
81     return _globalAlignment(gapsH, gapsV, scoringScheme, algorithmTag);
82 }
83 
84 // ----------------------------------------------------------------------------
85 // Function globalAlignment()                                [Myers-Hirschberg]
86 // ----------------------------------------------------------------------------
87 
88 template <typename TSequence, typename TAlignSpec>
globalAlignment(Align<TSequence,TAlignSpec> & align,MyersHirschberg const & algorithmTag)89 int globalAlignment(Align<TSequence, TAlignSpec> & align,
90                     MyersHirschberg const & algorithmTag)
91 {
92     SEQAN_ASSERT_EQ(length(rows(align)), 2u);
93     return _globalAlignment(row(align, 0), row(align, 1), algorithmTag);
94 }
95 
96 template <typename TSequenceH, typename TGapsSpecH,
97           typename TSequenceV, typename TGapsSpecV>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,MyersHirschberg const & algorithmTag)98 int globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
99                     Gaps<TSequenceV, TGapsSpecV> & gapsV,
100                     MyersHirschberg const & algorithmTag)
101 {
102     return _globalAlignment(gapsH, gapsV, algorithmTag);
103 }
104 
105 // ----------------------------------------------------------------------------
106 // Function globalAlignment()                                  [MyersBitVector]
107 // ----------------------------------------------------------------------------
108 
109 template <typename TSequence, typename TAlignSpec>
globalAlignment(Align<TSequence,TAlignSpec> & align,MyersBitVector const & algorithmTag)110 int globalAlignment(Align<TSequence, TAlignSpec> & align,
111                     MyersBitVector const & algorithmTag)
112 {
113     SEQAN_ASSERT_EQ(length(rows(align)), 2u);
114     return _globalAlignment(row(align, 0), row(align, 1), algorithmTag);
115 }
116 
117 template <typename TSequenceH, typename TGapsSpecH,
118           typename TSequenceV, typename TGapsSpecV>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,MyersBitVector const & algorithmTag)119 int globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
120                     Gaps<TSequenceV, TGapsSpecV> & gapsV,
121                     MyersBitVector const & algorithmTag)
122 {
123     return _globalAlignment(gapsH, gapsV, algorithmTag);
124 }
125 
126 // ----------------------------------------------------------------------------
127 // Function globalAlignmentScore()                                 [Hirschberg]
128 // ----------------------------------------------------------------------------
129 
130 template <typename TAlphabetH, typename TSpecH,
131           typename TAlphabetV, typename TSpecV,
132           typename TScoreValue, typename TScoreSpec>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,Score<TScoreValue,TScoreSpec> const & scoringScheme,Hirschberg const & algorithmTag)133 TScoreValue globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
134                                  String<TAlphabetV, TSpecV> const & seqV,
135                                  Score<TScoreValue, TScoreSpec> const & scoringScheme,
136                                  Hirschberg const & algorithmTag)
137 {
138     Gaps<String<TAlphabetH, TSpecH> const, ArrayGaps> gapsH(seqH);
139     Gaps<String<TAlphabetV, TSpecV> const, ArrayGaps> gapsV(seqV);
140     return globalAlignment(gapsH, gapsV, scoringScheme, algorithmTag);
141 }
142 
143 template <typename TString, typename TSpec,
144           typename TScoreValue, typename TScoreSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,Score<TScoreValue,TScoreSpec> const & scoringScheme,Hirschberg const & algorithmTag)145 TScoreValue globalAlignmentScore(StringSet<TString, TSpec> const & strings,
146                                  Score<TScoreValue, TScoreSpec> const & scoringScheme,
147                                  Hirschberg const & algorithmTag)
148 {
149     SEQAN_ASSERT_EQ(length(strings), 2u);
150     return globalAlignmentScore(strings[0], strings[1], scoringScheme, algorithmTag);
151 }
152 
153 // ----------------------------------------------------------------------------
154 // Function globalAlignmentScore()                           [Myers-Hirschberg]
155 // ----------------------------------------------------------------------------
156 
157 template <typename TAlphabetH, typename TSpecH,
158           typename TAlphabetV, typename TSpecV>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,MyersHirschberg const & algorithmTag)159 int globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
160                          String<TAlphabetV, TSpecV> const & seqV,
161                          MyersHirschberg const & algorithmTag)
162 {
163     Gaps<String<TAlphabetH, TSpecH> const, ArrayGaps> gapsH(seqH);
164     Gaps<String<TAlphabetV, TSpecV> const, ArrayGaps> gapsV(seqV);
165     return _globalAlignment(gapsH, gapsV, algorithmTag);
166 }
167 
168 template <typename TString, typename TSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,MyersHirschberg const & algorithmTag)169 int globalAlignmentScore(StringSet<TString, TSpec> const & strings,
170                          MyersHirschberg const & algorithmTag)
171 {
172     SEQAN_ASSERT_EQ(length(strings), 2u);
173     return globalAlignmentScore(strings[0], strings[1], algorithmTag);
174 }
175 
176 // ----------------------------------------------------------------------------
177 // Function globalAlignmentScore()                             [MyersBitVector]
178 // ----------------------------------------------------------------------------
179 
180 template <typename TAlphabetH, typename TSpecH,
181           typename TAlphabetV, typename TSpecV>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,MyersBitVector const & algorithmTag)182 int globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
183                          String<TAlphabetV, TSpecV> const & seqV,
184                          MyersBitVector const & algorithmTag)
185 {
186     return _globalAlignmentScore(seqH, seqV, algorithmTag);
187 }
188 
189 template <typename TString, typename TSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,MyersBitVector const & algorithmTag)190 int globalAlignmentScore(StringSet<TString, TSpec> const & strings,
191                          MyersBitVector const & algorithmTag)
192 {
193     SEQAN_ASSERT_EQ(length(strings), 2u);
194     return _globalAlignmentScore(strings[0], strings[1], algorithmTag);
195 }
196 
197 }  // namespace seqan
198 
199 #endif  // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_GLOBAL_ALIGNMENT_SPECIALIZED_H_
200