1 // ==========================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ==========================================================================
4 // Copyright (c) 2006-2018, 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 TSequenceH, typename TGapsSpecH,
64 typename TSequenceV, typename TGapsSpecV,
65 typename TScoreValue>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,Score<TScoreValue,Simple> const & scoringScheme,Hirschberg const &)66 TScoreValue globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
67 Gaps<TSequenceV, TGapsSpecV> & gapsV,
68 Score<TScoreValue, Simple> const & scoringScheme,
69 Hirschberg const & /*algorithmTag*/)
70 {
71 SEQAN_ASSERT_EQ(scoreGapOpen(scoringScheme), scoreGapExtend(scoringScheme));
72 return _globalAlignment(gapsH, gapsV, scoringScheme, Hirschberg());
73 }
74
75 template <typename TSequence, typename TAlignSpec,
76 typename TScoreValue>
globalAlignment(Align<TSequence,TAlignSpec> & align,Score<TScoreValue,Simple> const & scoringScheme,Hirschberg const &)77 TScoreValue globalAlignment(Align<TSequence, TAlignSpec> & align,
78 Score<TScoreValue, Simple> const & scoringScheme,
79 Hirschberg const & /*algorithmTag*/)
80 {
81 SEQAN_ASSERT_EQ(length(rows(align)), 2u);
82
83 return globalAlignment(row(align, 0), row(align, 1), scoringScheme, Hirschberg());
84 }
85
86 // ----------------------------------------------------------------------------
87 // Function globalAlignment() [Myers-Hirschberg]
88 // ----------------------------------------------------------------------------
89
90 template <typename TSequence, typename TAlignSpec>
globalAlignment(Align<TSequence,TAlignSpec> & align,MyersHirschberg const & algorithmTag)91 int globalAlignment(Align<TSequence, TAlignSpec> & align,
92 MyersHirschberg const & algorithmTag)
93 {
94 SEQAN_ASSERT_EQ(length(rows(align)), 2u);
95 return _globalAlignment(row(align, 0), row(align, 1), algorithmTag);
96 }
97
98 template <typename TSequenceH, typename TGapsSpecH,
99 typename TSequenceV, typename TGapsSpecV>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,MyersHirschberg const & algorithmTag)100 int globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
101 Gaps<TSequenceV, TGapsSpecV> & gapsV,
102 MyersHirschberg const & algorithmTag)
103 {
104 return _globalAlignment(gapsH, gapsV, algorithmTag);
105 }
106
107 // ----------------------------------------------------------------------------
108 // Function globalAlignment() [MyersBitVector]
109 // ----------------------------------------------------------------------------
110
111 template <typename TSequence, typename TAlignSpec>
globalAlignment(Align<TSequence,TAlignSpec> & align,MyersBitVector const & algorithmTag)112 int globalAlignment(Align<TSequence, TAlignSpec> & align,
113 MyersBitVector const & algorithmTag)
114 {
115 SEQAN_ASSERT_EQ(length(rows(align)), 2u);
116 return _globalAlignment(row(align, 0), row(align, 1), algorithmTag);
117 }
118
119 template <typename TSequenceH, typename TGapsSpecH,
120 typename TSequenceV, typename TGapsSpecV>
globalAlignment(Gaps<TSequenceH,TGapsSpecH> & gapsH,Gaps<TSequenceV,TGapsSpecV> & gapsV,MyersBitVector const & algorithmTag)121 int globalAlignment(Gaps<TSequenceH, TGapsSpecH> & gapsH,
122 Gaps<TSequenceV, TGapsSpecV> & gapsV,
123 MyersBitVector const & algorithmTag)
124 {
125 return _globalAlignment(gapsH, gapsV, algorithmTag);
126 }
127
128 // ----------------------------------------------------------------------------
129 // Function globalAlignmentScore() [Hirschberg]
130 // ----------------------------------------------------------------------------
131
132 template <typename TAlphabetH, typename TSpecH,
133 typename TAlphabetV, typename TSpecV,
134 typename TScoreValue>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,Score<TScoreValue,Simple> const & scoringScheme,Hirschberg const & algorithmTag)135 TScoreValue globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
136 String<TAlphabetV, TSpecV> const & seqV,
137 Score<TScoreValue, Simple> const & scoringScheme,
138 Hirschberg const & algorithmTag)
139 {
140 Gaps<String<TAlphabetH, TSpecH> const, ArrayGaps> gapsH(seqH);
141 Gaps<String<TAlphabetV, TSpecV> const, ArrayGaps> gapsV(seqV);
142 return globalAlignment(gapsH, gapsV, scoringScheme, algorithmTag);
143 }
144
145 template <typename TString, typename TSpec,
146 typename TScoreValue, typename TScoreSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,Score<TScoreValue,TScoreSpec> const & scoringScheme,Hirschberg const & algorithmTag)147 TScoreValue globalAlignmentScore(StringSet<TString, TSpec> const & strings,
148 Score<TScoreValue, TScoreSpec> const & scoringScheme,
149 Hirschberg const & algorithmTag)
150 {
151 SEQAN_ASSERT_EQ(length(strings), 2u);
152 return globalAlignmentScore(strings[0], strings[1], scoringScheme, algorithmTag);
153 }
154
155 // ----------------------------------------------------------------------------
156 // Function globalAlignmentScore() [Myers-Hirschberg]
157 // ----------------------------------------------------------------------------
158
159 template <typename TAlphabetH, typename TSpecH,
160 typename TAlphabetV, typename TSpecV>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,MyersHirschberg const & algorithmTag)161 int globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
162 String<TAlphabetV, TSpecV> const & seqV,
163 MyersHirschberg const & algorithmTag)
164 {
165 Gaps<String<TAlphabetH, TSpecH> const, ArrayGaps> gapsH(seqH);
166 Gaps<String<TAlphabetV, TSpecV> const, ArrayGaps> gapsV(seqV);
167 return _globalAlignment(gapsH, gapsV, algorithmTag);
168 }
169
170 template <typename TString, typename TSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,MyersHirschberg const & algorithmTag)171 int globalAlignmentScore(StringSet<TString, TSpec> const & strings,
172 MyersHirschberg const & algorithmTag)
173 {
174 SEQAN_ASSERT_EQ(length(strings), 2u);
175 return globalAlignmentScore(strings[0], strings[1], algorithmTag);
176 }
177
178 // ----------------------------------------------------------------------------
179 // Function globalAlignmentScore() [MyersBitVector]
180 // ----------------------------------------------------------------------------
181
182 template <typename TAlphabetH, typename TSpecH,
183 typename TAlphabetV, typename TSpecV>
globalAlignmentScore(String<TAlphabetH,TSpecH> const & seqH,String<TAlphabetV,TSpecV> const & seqV,MyersBitVector const & algorithmTag)184 int globalAlignmentScore(String<TAlphabetH, TSpecH> const & seqH,
185 String<TAlphabetV, TSpecV> const & seqV,
186 MyersBitVector const & algorithmTag)
187 {
188 return _globalAlignmentScore(seqH, seqV, algorithmTag);
189 }
190
191 template <typename TString, typename TSpec>
globalAlignmentScore(StringSet<TString,TSpec> const & strings,MyersBitVector const & algorithmTag)192 int globalAlignmentScore(StringSet<TString, TSpec> const & strings,
193 MyersBitVector const & algorithmTag)
194 {
195 SEQAN_ASSERT_EQ(length(strings), 2u);
196 return _globalAlignmentScore(strings[0], strings[1], algorithmTag);
197 }
198
199 } // namespace seqan
200
201 #endif // #ifndef SEQAN_INCLUDE_SEQAN_ALIGN_GLOBAL_ALIGNMENT_SPECIALIZED_H_
202