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: Hannes Hauswedell <hauswedell@mi.fu-berlin.de>
33 // ==========================================================================
34 // This file contains routines to extend an existing Align object
35 // ==========================================================================
36 
37 
38 #ifndef INCLUDE_ALIGN_ALIGN_EXTEND_BASE_H
39 #define INCLUDE_ALIGN_ALIGN_EXTEND_BASE_H
40 
41 namespace seqan {
42 
43 
44 // ============================================================================
45 // Tags, Classes, Enums
46 // ============================================================================
47 
48 template <typename TSpec = void>
49 struct AlignExtend_
50 {
51 };
52 
53 // ============================================================================
54 // Metafunctions
55 // ============================================================================
56 
57 
58 // overrides for AligExtend general case
59 template <typename TSpec, typename TAlignConfig, typename TGapCosts,
60           typename TTraceSwitch>
61 struct SetupAlignmentProfile_<AlignExtend_<TSpec>, TAlignConfig, TGapCosts,
62                               TTraceSwitch>
63 {
64     typedef DPProfile_<AlignExtend_<TSpec>, TGapCosts, TracebackOn<> > Type;
65 };
66 
67 template <typename TSpec>
68 struct TraceTail_<AlignExtend_<TSpec> > : False
69 {};
70 
71 template <typename TSpec>
72 struct TraceHead_<AlignExtend_<TSpec> > : True
73 {};
74 
75 template <typename TSpec>
76 struct IsFreeEndGap_<AlignExtend_<TSpec>, DPLastRow> : True
77 {};
78 
79 template <typename TSpec>
80 struct IsFreeEndGap_<AlignExtend_<TSpec>, DPLastColumn> : True
81 {};
82 
83 
84 
85 // ----------------------------------------------------------------------------
86 // Class DPMetaColumn_                                             [FullColumn]
87 // ----------------------------------------------------------------------------
88 
89 template <typename TSpec, typename TGapCosts, typename TTraceback, typename TExecPolicy,
90           typename TColumnType>
91 struct DPMetaColumn_<DPProfile_<AlignExtend_<TSpec>, TGapCosts,
92                                 TTraceback, TExecPolicy>,
93                      MetaColumnDescriptor<TColumnType, FullColumn> >
94 {
95 
96     typedef typename If<IsSameType<TColumnType,
97                                    DPInitialColumn>, RecursionDirectionZero,
98                         RecursionDirectionHorizontal
99                        >::Type TRecursionTypeFirstCell_;
100     typedef typename If<IsSameType<TColumnType,
101                                    DPInitialColumn>, RecursionDirectionVertical,
102                         RecursionDirectionAll
103                        >::Type TRecursionTypeInnerCell_;
104     typedef typename If<IsSameType<TColumnType,
105                                    DPInitialColumn>, RecursionDirectionVertical,
106                         RecursionDirectionAll
107                        >::Type TRecursionTypeLastCell_;
108 
109     typedef DPMetaCell_<TRecursionTypeFirstCell_, True> TFirstCell_;
110     typedef DPMetaCell_<TRecursionTypeInnerCell_, True> TInnerCell_;
111     typedef DPMetaCell_<TRecursionTypeLastCell_, True> TLastCell_;
112 };
113 
114 
115 // ----------------------------------------------------------------------------
116 // Class DPMetaColumn_                                       [PartialColumnTop]
117 // ----------------------------------------------------------------------------
118 
119 template <typename TSpec, typename TGapCosts, typename TTraceback, typename TExecPolicy,
120           typename TColumnType>
121 struct DPMetaColumn_<DPProfile_<AlignExtend_<TSpec>, TGapCosts,
122                                 TTraceback, TExecPolicy>,
123                      MetaColumnDescriptor<TColumnType, PartialColumnTop> >
124 {
125 
126     typedef typename If<IsSameType<TColumnType,
127                                    DPInitialColumn>, RecursionDirectionZero,
128                         RecursionDirectionHorizontal
129                        >::Type TRecursionTypeFirstCell_;
130     typedef typename If<IsSameType<TColumnType,
131                                    DPInitialColumn>, RecursionDirectionVertical,
132                         RecursionDirectionAll
133                        >::Type TRecursionTypeInnerCell_;
134     typedef typename If<IsSameType<TColumnType,
135                                    DPInitialColumn>, RecursionDirectionVertical,
136                         RecursionDirectionLowerDiagonal
137                        >::Type TRecursionTypeLastCell_;
138 
139     typedef DPMetaCell_<TRecursionTypeFirstCell_, True> TFirstCell_;
140     typedef DPMetaCell_<TRecursionTypeInnerCell_, True> TInnerCell_;
141     typedef DPMetaCell_<TRecursionTypeLastCell_, True> TLastCell_;
142 };
143 
144 // ----------------------------------------------------------------------------
145 // Class DPMetaColumn_                                    [PartialColumnMiddle]
146 // ----------------------------------------------------------------------------
147 
148 template <typename TSpec, typename TGapCosts, typename TTraceback, typename TExecPolicy,
149           typename TColumnType>
150 struct DPMetaColumn_<DPProfile_<AlignExtend_<TSpec>, TGapCosts,
151                                 TTraceback, TExecPolicy>,
152                      MetaColumnDescriptor<TColumnType, PartialColumnMiddle> >
153 {
154     typedef typename If<IsSameType<TColumnType,
155                                    DPInitialColumn>, RecursionDirectionZero,
156                         RecursionDirectionUpperDiagonal
157                        >::Type TRecursionTypeFirstCell_;
158     typedef typename If<IsSameType<TColumnType,
159                                    DPInitialColumn>, RecursionDirectionVertical,
160                         RecursionDirectionAll
161                        >::Type TRecursionTypeInnerCell_;
162     typedef typename If<IsSameType<TColumnType,
163                                    DPInitialColumn>, RecursionDirectionVertical,
164                         RecursionDirectionLowerDiagonal
165                        >::Type TRecursionTypeLastCell_;
166 
167     typedef DPMetaCell_<TRecursionTypeFirstCell_, True> TFirstCell_;
168     typedef DPMetaCell_<TRecursionTypeInnerCell_, True> TInnerCell_;
169     typedef DPMetaCell_<TRecursionTypeLastCell_, True> TLastCell_;
170 };
171 
172 // ----------------------------------------------------------------------------
173 // Class DPMetaColumn_                                    [PartialColumnBottom]
174 // ----------------------------------------------------------------------------
175 
176 template <typename TSpec, typename TGapCosts, typename TTraceback, typename TExecPolicy,
177           typename TColumnType>
178 struct DPMetaColumn_<DPProfile_<AlignExtend_<TSpec>, TGapCosts,
179                                 TTraceback, TExecPolicy>,
180                      MetaColumnDescriptor<TColumnType, PartialColumnBottom> >
181 {
182     typedef typename If<IsSameType<TColumnType,
183                                    DPInitialColumn>, RecursionDirectionZero,
184                         RecursionDirectionUpperDiagonal
185                        >::Type TRecursionTypeFirstCell_;
186     typedef typename If<IsSameType<TColumnType,
187                                    DPInitialColumn>, RecursionDirectionVertical,
188                         RecursionDirectionAll
189                        >::Type TRecursionTypeInnerCell_;
190     typedef typename If<IsSameType<TColumnType,
191                                    DPInitialColumn>, RecursionDirectionVertical,
192                         RecursionDirectionAll
193                        >::Type TRecursionTypeLastCell_;
194 
195     typedef DPMetaCell_<TRecursionTypeFirstCell_, True> TFirstCell_;
196     typedef DPMetaCell_<TRecursionTypeInnerCell_, True> TInnerCell_;
197     typedef DPMetaCell_<TRecursionTypeLastCell_, True> TLastCell_;
198 };
199 
200 }
201 #endif
202