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: Rene Rahn <rene.rahn@fu-berlin.de>
33 // ==========================================================================
34 // Implements the score function for dynamic gap costs published in
35 // "Dynamic Gaps Selector: A Smith Waterman Sequence Alignment Algorithm with
36 // Affine Gap Model Optimization" by Gianvito Urgese et al.
37 // ==========================================================================
38 
39 #ifndef INCLUDE_SEQAN_ALIGN_DP_FORMULA_DYNAMIC_H_
40 #define INCLUDE_SEQAN_ALIGN_DP_FORMULA_DYNAMIC_H_
41 
42 namespace seqan {
43 
44 // ============================================================================
45 // Forwards
46 // ============================================================================
47 
48 // ============================================================================
49 // Tags, Classes, Enums
50 // ============================================================================
51 
52 // ============================================================================
53 // Metafunctions
54 // ============================================================================
55 
56 // ============================================================================
57 // Functions
58 // ============================================================================
59 
60 // ----------------------------------------------------------------------------
61 // Function _internalComputeScore      [RecursionDirectionDiagonal, DynamicGaps]
62 // ----------------------------------------------------------------------------
63 
64 template <typename TScoreValue, typename TTraceValueL, typename TTraceValueGap>
65 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & diagCompare,TTraceValueL,TTraceValueGap,TracebackOff const &,RecursionDirectionDiagonal const &)66 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
67                       TScoreValue const & diagCompare,
68                       TTraceValueL,
69                       TTraceValueGap,
70                       TracebackOff const &,
71                       RecursionDirectionDiagonal const &)
72 {
73     if(_scoreOfCell(activeCell) < diagCompare)
74     {
75         activeCell._score = diagCompare;
76         setGapExtension(activeCell, False(), False());
77         return TraceBitMap_::NONE;
78     }
79     return TraceBitMap_::NONE;
80 }
81 
82 template <typename TScoreValue, typename TTraceValueL, typename TTraceValueGap, typename TGapsPlacement>
83 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & diagCompare,TTraceValueL leftTrace,TTraceValueGap gapTrace,TracebackOn<TracebackConfig_<SingleTrace,TGapsPlacement>> const &,RecursionDirectionDiagonal const &)84 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
85                       TScoreValue const & diagCompare,
86                       TTraceValueL leftTrace,
87                       TTraceValueGap gapTrace,
88                       TracebackOn<TracebackConfig_<SingleTrace, TGapsPlacement> > const &,
89                       RecursionDirectionDiagonal const &)
90 {
91     if(_scoreOfCell(activeCell) <= diagCompare)
92     {
93         activeCell._score = diagCompare;
94         setGapExtension(activeCell, False(), False());
95         return TraceBitMap_::DIAGONAL | leftTrace;
96     }
97     return leftTrace | gapTrace;
98 }
99 
100 template <typename TScoreValue, typename TTraceValueL, typename TTraceValueGap, typename TGapsPlacement>
101 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & diagCompare,TTraceValueL leftTrace,TTraceValueGap gapTrace,TracebackOn<TracebackConfig_<CompleteTrace,TGapsPlacement>> const &,RecursionDirectionDiagonal const &)102 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
103                       TScoreValue const & diagCompare,
104                       TTraceValueL leftTrace,
105                       TTraceValueGap gapTrace,
106                       TracebackOn<TracebackConfig_<CompleteTrace, TGapsPlacement> >  const &,
107                       RecursionDirectionDiagonal const &)
108 {
109     if(_scoreOfCell(activeCell) < diagCompare)
110     {
111         activeCell._score = diagCompare;  // Maximal score comes from diagonal.
112         setGapExtension(activeCell, False(), False());
113         return TraceBitMap_::DIAGONAL | leftTrace;  // Return trace for Diagonal.
114     }
115     if (_scoreOfCell(activeCell) == diagCompare)  // Maximal score comes from previous computed directions and diagonal.
116         return leftTrace | TraceBitMap_::DIAGONAL | gapTrace;  // Return all directions inclusively the flag indicating max from gap.
117 
118     return leftTrace | gapTrace;  // Maximum comes from gap. Return gap value inclusively the flag indicating max from gap.
119 }
120 
121 // ----------------------------------------------------------------------------
122 // Function _internalComputeScore    [RecursionDirectionHorizontal, DynamicGaps]
123 // ----------------------------------------------------------------------------
124 
125 template <typename TScoreValue, typename TValueH, typename TValueV, typename TScore>
126 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & prevCell,TValueH const & valH,TValueV const & valV,TScore const & score,TracebackOff const &,RecursionDirectionHorizontal const &)127 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
128                       DPCell_<TScoreValue, DynamicGaps> const & prevCell,
129                       TValueH const & valH,
130                       TValueV const & valV,
131                       TScore const & score,
132                       TracebackOff const &,
133                       RecursionDirectionHorizontal const &)
134 {
135     if(!isGapExtension(prevCell, DynamicGapExtensionHorizontal()))
136         activeCell._score = _scoreOfCell(prevCell) + scoreGapOpenHorizontal(score, valH, valV);
137     return TraceBitMap_::NONE;
138 }
139 
140 template <typename TScoreValue, typename TValueH, typename TValueV, typename TScore, typename TTraceConfig>
141 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & prevCell,TValueH const & valH,TValueV const & valV,TScore const & score,TracebackOn<TTraceConfig> const &,RecursionDirectionHorizontal const &)142 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
143                       DPCell_<TScoreValue, DynamicGaps> const & prevCell,
144                       TValueH const & valH,
145                       TValueV const & valV,
146                       TScore const & score,
147                       TracebackOn<TTraceConfig> const &,
148                       RecursionDirectionHorizontal const &)
149 {
150     if (!isGapExtension(prevCell, DynamicGapExtensionHorizontal()))
151     {
152         activeCell._score = _scoreOfCell(prevCell) + scoreGapOpenHorizontal(score, valH, valV);
153         return TraceBitMap_::HORIZONTAL_OPEN;
154     }
155     return TraceBitMap_::HORIZONTAL;
156 }
157 
158 // ----------------------------------------------------------------------------
159 // Function _internalComputeScore      [RecursionDirectionVertical, DynamicGaps]
160 // ----------------------------------------------------------------------------
161 
162 template <typename TScoreValue, typename TValueH, typename TValueV, typename TScore>
163 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & prevCell,TValueH const & valH,TValueV const & valV,TScore const & score,TracebackOff const &,RecursionDirectionVertical const &)164 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
165                       DPCell_<TScoreValue, DynamicGaps> const & prevCell,
166                       TValueH const & valH,
167                       TValueV const & valV,
168                       TScore const & score,
169                       TracebackOff const &,
170                       RecursionDirectionVertical const &)
171 {
172     if(!isGapExtension(prevCell, DynamicGapExtensionVertical()))
173         activeCell._score = _scoreOfCell(prevCell) + scoreGapOpenVertical(score, valH, valV);
174     return TraceBitMap_::NONE;
175 }
176 
177 template <typename TScoreValue, typename TValueH, typename TValueV, typename TScore, typename TTraceConfig>
178 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & prevCell,TValueH const & valH,TValueV const & valV,TScore const & score,TracebackOn<TTraceConfig> const &,RecursionDirectionVertical const &)179 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
180                       DPCell_<TScoreValue, DynamicGaps> const & prevCell,
181                       TValueH const & valH,
182                       TValueV const & valV,
183                       TScore const & score,
184                       TracebackOn<TTraceConfig> const &,
185                       RecursionDirectionVertical const &)
186 {
187     if (!isGapExtension(prevCell, DynamicGapExtensionVertical()))
188     {
189         activeCell._score = _scoreOfCell(prevCell) + scoreGapOpenVertical(score, valH, valV);
190         return TraceBitMap_::VERTICAL_OPEN;
191     }
192     return TraceBitMap_::VERTICAL;
193 }
194 
195 // ----------------------------------------------------------------------------
196 // Function _internalComputeScore          [Vertical vs Horizontal, DynamicGaps]
197 // ----------------------------------------------------------------------------
198 
199 template <typename TScoreValue>
200 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & horizontalComp,TracebackOff const &)201 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
202                       TScoreValue const & horizontalComp,
203                       TracebackOff const &)
204 {
205     if(_scoreOfCell(activeCell) < horizontalComp)
206     {
207         activeCell._score = horizontalComp;
208         setGapExtension(activeCell, False(), True());
209         return TraceBitMap_::NONE;
210     }
211     setGapExtension(activeCell, True(), False());
212     return TraceBitMap_::NONE;
213 }
214 
215 template <typename TScoreValue, typename TGapsPlacement>
216 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & horizontalComp,TracebackOn<TracebackConfig_<SingleTrace,TGapsPlacement>> const &)217 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
218                       TScoreValue const & horizontalComp,
219                       TracebackOn<TracebackConfig_<SingleTrace, TGapsPlacement> >  const &)
220 {
221     if(_scoreOfCell(activeCell) < horizontalComp)
222     {
223         activeCell._score = horizontalComp;
224         setGapExtension(activeCell, False(), True());
225         return TraceBitMap_::MAX_FROM_HORIZONTAL_MATRIX;
226     }
227     setGapExtension(activeCell, True(), False());
228     return TraceBitMap_::MAX_FROM_VERTICAL_MATRIX;
229 }
230 
231 template <typename TScoreValue, typename TGapsPlacement>
232 inline typename TraceBitMap_::TTraceValue
_internalComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,TScoreValue const & horizontalComp,TracebackOn<TracebackConfig_<CompleteTrace,TGapsPlacement>> const &)233 _internalComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
234                       TScoreValue const & horizontalComp,
235                       TracebackOn<TracebackConfig_<CompleteTrace, TGapsPlacement> >  const &)
236 {
237     if(_scoreOfCell(activeCell) < horizontalComp)
238     {
239         setGapExtension(activeCell, False(), True());
240         activeCell._score = horizontalComp;
241         return TraceBitMap_::MAX_FROM_HORIZONTAL_MATRIX;
242     }
243     if (_scoreOfCell(activeCell) == horizontalComp)
244     {
245         setGapExtension(activeCell, True(), True());
246         return TraceBitMap_::MAX_FROM_VERTICAL_MATRIX | TraceBitMap_::MAX_FROM_HORIZONTAL_MATRIX;
247     }
248     setGapExtension(activeCell, True(), False());
249     return TraceBitMap_::MAX_FROM_VERTICAL_MATRIX;
250 }
251 
252 // ----------------------------------------------------------------------------
253 // Function _doComputeScore                 [RecursionAllDirection, DynamicGaps]
254 // ----------------------------------------------------------------------------
255 
256 template <typename TScoreValue, typename TSequenceHValue, typename TSequenceVValue, typename TScoringScheme,
257           typename TAlgorithm, typename TTracebackConfig>
258 inline typename TraceBitMap_::TTraceValue
_doComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & previousDiagonal,DPCell_<TScoreValue,DynamicGaps> const & previousHorizontal,DPCell_<TScoreValue,DynamicGaps> const & previousVertical,TSequenceHValue const & seqHVal,TSequenceVValue const & seqVVal,TScoringScheme const & scoringScheme,RecursionDirectionAll const &,DPProfile_<TAlgorithm,DynamicGaps,TTracebackConfig> const &)259 _doComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
260                 DPCell_<TScoreValue, DynamicGaps> const & previousDiagonal,
261                 DPCell_<TScoreValue, DynamicGaps> const & previousHorizontal,
262                 DPCell_<TScoreValue, DynamicGaps> const & previousVertical,
263                 TSequenceHValue const & seqHVal,
264                 TSequenceVValue const & seqVVal,
265                 TScoringScheme const & scoringScheme,
266                 RecursionDirectionAll const &,
267                 DPProfile_<TAlgorithm, DynamicGaps, TTracebackConfig> const &)
268 {
269     typedef typename TraceBitMap_::TTraceValue TTraceValue;
270 
271     // Compute best alignment from either horizontal open or extension.
272     DPCell_<TScoreValue, DynamicGaps> tmpScore = _scoreOfCell(previousHorizontal) + scoreGapExtendHorizontal(scoringScheme, seqHVal, seqVVal);
273     TTraceValue tvGap = _internalComputeScore(tmpScore, previousHorizontal, seqHVal, seqVVal, scoringScheme,
274                                               TTracebackConfig(), RecursionDirectionHorizontal());
275 
276     // Compute best alignment between vertical and vertical open gap.
277     activeCell._score = _scoreOfCell(previousVertical) + scoreGapExtendVertical(scoringScheme, seqHVal, seqVVal);
278     tvGap |= _internalComputeScore(activeCell, previousVertical, seqHVal, seqVVal, scoringScheme,
279                                    TTracebackConfig(), RecursionDirectionVertical());
280 
281     // Finds the maximum between the vertical and the horizontal matrix. Stores the flag for coming from a potential direction.
282     TTraceValue tvMax = _internalComputeScore(activeCell, tmpScore._score, TTracebackConfig());  // Stores from where the maximal score comes.
283     tmpScore._score = _scoreOfCell(previousDiagonal) + score(scoringScheme, seqHVal, seqVVal);
284     return _internalComputeScore(activeCell, tmpScore._score, tvGap, tvMax, TTracebackConfig(), RecursionDirectionDiagonal());
285 }
286 
287 // ----------------------------------------------------------------------------
288 // Function _doComputeScore       [RecursionUpperDiagonalDirection, DynamicGaps]
289 // ----------------------------------------------------------------------------
290 
291 template <typename TScoreValue, typename TSequenceHValue, typename TSequenceVValue, typename TScoringScheme,
292           typename TAlgorithm, typename TTracebackConfig>
293 inline typename TraceBitMap_::TTraceValue
_doComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & previousDiagonal,DPCell_<TScoreValue,DynamicGaps> const & previousHorizontal,DPCell_<TScoreValue,DynamicGaps> const &,TSequenceHValue const & seqHVal,TSequenceVValue const & seqVVal,TScoringScheme const & scoringScheme,RecursionDirectionUpperDiagonal const &,DPProfile_<TAlgorithm,DynamicGaps,TTracebackConfig> const &)294 _doComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
295                 DPCell_<TScoreValue, DynamicGaps> const & previousDiagonal,
296                 DPCell_<TScoreValue, DynamicGaps> const & previousHorizontal,
297                 DPCell_<TScoreValue, DynamicGaps> const & /*previousVertical*/,
298                 TSequenceHValue const & seqHVal,
299                 TSequenceVValue const & seqVVal,
300                 TScoringScheme const & scoringScheme,
301                 RecursionDirectionUpperDiagonal const &,
302                 DPProfile_<TAlgorithm, DynamicGaps, TTracebackConfig> const &)
303 {
304     typedef typename TraceBitMap_::TTraceValue TTraceValue;
305 
306     // This computes the difference between the horizontal extend and horizontal open.
307     activeCell._score = _scoreOfCell(previousHorizontal) + scoreGapExtendHorizontal(scoringScheme, seqHVal, seqVVal);
308     TTraceValue tv = _internalComputeScore(activeCell, previousHorizontal, seqHVal, seqVVal, scoringScheme,
309                                            TTracebackConfig(), RecursionDirectionHorizontal());
310 
311     setGapExtension(activeCell, False(), True());
312     TScoreValue tmpScore = _scoreOfCell(previousDiagonal) + score(scoringScheme, seqHVal, seqVVal);
313     return _internalComputeScore(activeCell, tmpScore, tv, TraceBitMap_::MAX_FROM_HORIZONTAL_MATRIX,
314                                  TTracebackConfig(), RecursionDirectionDiagonal());
315 }
316 
317 // ----------------------------------------------------------------------------
318 // Function _doComputeScore      [RecursionDirectionLowerDiagonal, DynamicGaps]
319 // ----------------------------------------------------------------------------
320 
321 template <typename TScoreValue, typename TSequenceHValue, typename TSequenceVValue, typename TScoringScheme,
322           typename TAlgorithm, typename TTracebackConfig>
323 inline typename TraceBitMap_::TTraceValue
_doComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const & previousDiagonal,DPCell_<TScoreValue,DynamicGaps> const &,DPCell_<TScoreValue,DynamicGaps> const & previousVertical,TSequenceHValue const & seqHVal,TSequenceVValue const & seqVVal,TScoringScheme const & scoringScheme,RecursionDirectionLowerDiagonal const &,DPProfile_<TAlgorithm,DynamicGaps,TTracebackConfig> const &)324 _doComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
325                 DPCell_<TScoreValue, DynamicGaps> const & previousDiagonal,
326                 DPCell_<TScoreValue, DynamicGaps> const & /*previousHorizontal*/,
327                 DPCell_<TScoreValue, DynamicGaps> const & previousVertical,
328                 TSequenceHValue const & seqHVal,
329                 TSequenceVValue const & seqVVal,
330                 TScoringScheme const & scoringScheme,
331                 RecursionDirectionLowerDiagonal const &,
332                 DPProfile_<TAlgorithm, DynamicGaps, TTracebackConfig> const &)
333 {
334     typedef typename TraceBitMap_::TTraceValue TTraceValue;
335 
336     // This computes the difference between the vertical extend and vertical open.
337     activeCell._score = _scoreOfCell(previousVertical) + scoreGapExtendVertical(scoringScheme, seqHVal, seqVVal);
338     TTraceValue tv = _internalComputeScore(activeCell, previousVertical, seqHVal, seqVVal, scoringScheme,
339                                            TTracebackConfig(), RecursionDirectionVertical());
340     setGapExtension(activeCell, True(), False());
341     TScoreValue tmpScore = _scoreOfCell(previousDiagonal) + score(scoringScheme, seqHVal, seqVVal);
342     return _internalComputeScore(activeCell, tmpScore, tv, TraceBitMap_::MAX_FROM_VERTICAL_MATRIX,
343                                  TTracebackConfig(), RecursionDirectionDiagonal());
344 }
345 
346 // ----------------------------------------------------------------------------
347 // Function _doComputeScore                      [RecursionHorizontalDirection]
348 // ----------------------------------------------------------------------------
349 
350 template <typename TScoreValue, typename TSequenceHValue, typename TSequenceVValue, typename TScoringScheme,
351           typename TAlgorithm, typename TTracebackConfig>
352 inline typename TraceBitMap_::TTraceValue
_doComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const &,DPCell_<TScoreValue,DynamicGaps> const & previousHorizontal,DPCell_<TScoreValue,DynamicGaps> const &,TSequenceHValue const & seqHVal,TSequenceVValue const & seqVVal,TScoringScheme const & scoringScheme,RecursionDirectionHorizontal const & tag,DPProfile_<TAlgorithm,DynamicGaps,TTracebackConfig> const &)353 _doComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
354                 DPCell_<TScoreValue, DynamicGaps> const & /*previousDiagonal*/,
355                 DPCell_<TScoreValue, DynamicGaps> const & previousHorizontal,
356                 DPCell_<TScoreValue, DynamicGaps> const & /*previousVertical*/,
357                 TSequenceHValue const & seqHVal,
358                 TSequenceVValue const & seqVVal,
359                 TScoringScheme const & scoringScheme,
360                 RecursionDirectionHorizontal const & tag,
361                 DPProfile_<TAlgorithm, DynamicGaps, TTracebackConfig> const &)
362 {
363     activeCell._score = _scoreOfCell(previousHorizontal) + scoreGapExtendHorizontal(scoringScheme, seqHVal, seqVVal);
364     setGapExtension(activeCell, False(), True());
365     return _internalComputeScore(activeCell, previousHorizontal, seqHVal, seqVVal, scoringScheme,
366                                  TTracebackConfig(), tag) | TraceBitMap_::MAX_FROM_HORIZONTAL_MATRIX;
367 }
368 
369 // ----------------------------------------------------------------------------
370 // Function _doComputeScore                        [RecursionVerticalDirection]
371 // ----------------------------------------------------------------------------
372 
373 template <typename TScoreValue, typename TSequenceHValue, typename TSequenceVValue, typename TScoringScheme,
374           typename TAlgorithm, typename TTracebackConfig>
375 inline typename TraceBitMap_::TTraceValue
_doComputeScore(DPCell_<TScoreValue,DynamicGaps> & activeCell,DPCell_<TScoreValue,DynamicGaps> const &,DPCell_<TScoreValue,DynamicGaps> const &,DPCell_<TScoreValue,DynamicGaps> const & previousVertical,TSequenceHValue const & seqHVal,TSequenceVValue const & seqVVal,TScoringScheme const & scoringScheme,RecursionDirectionVertical const & tag,DPProfile_<TAlgorithm,DynamicGaps,TTracebackConfig> const &)376 _doComputeScore(DPCell_<TScoreValue, DynamicGaps> & activeCell,
377                 DPCell_<TScoreValue, DynamicGaps> const & /*previousDiagonal*/,
378                 DPCell_<TScoreValue, DynamicGaps> const & /*previousHorizontal*/,
379                 DPCell_<TScoreValue, DynamicGaps> const & previousVertical,
380                 TSequenceHValue const & seqHVal,
381                 TSequenceVValue const & seqVVal,
382                 TScoringScheme const & scoringScheme,
383                 RecursionDirectionVertical const & tag,
384                 DPProfile_<TAlgorithm, DynamicGaps, TTracebackConfig> const &)
385 {
386     activeCell._score = _scoreOfCell(previousVertical) + scoreGapExtendVertical(scoringScheme, seqHVal, seqVVal);
387     setGapExtension(activeCell, True(), False());
388     return _internalComputeScore(activeCell, previousVertical, seqHVal, seqVVal, scoringScheme,
389                                  TTracebackConfig(), tag) | TraceBitMap_::MAX_FROM_VERTICAL_MATRIX;
390 }
391 
392 }  // namespace seqan
393 
394 #endif  // INCLUDE_SEQAN_ALIGN_DP_FORMULA_DYNAMIC_H_
395