Ymir  .9
Fast\C++toolforcomputationofassemblingprobabilities,statisticalinferenceofassemblingstatisticalmodelandgenerationofartificialsequencesofT-cellreceptorsdata.
alignment.h
1 /*
2  * Ymir <imminfo.github.io/ymir>
3  *
4  * This file is part of Ymir, a fast C++ tool for computation of assembling
5  * probabilities, statistical inference of assembling statistical model
6  * and generation of artificial sequences of T-cell receptors data.
7  *
8  *
9  * Copyright 2015 Vadim Nazarov <vdn at mailbox dot com>
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 
24 #ifndef _ALIGNMENT_H_
25 #define _ALIGNMENT_H_
26 
27 
28 #include "gapped_alignment_vector.h"
29 #include "vdj_alignment.h"
30 
31 
32 namespace ymir {
33 
34  #define DEFAULT_LOCAL_ALIGNMENT_RESERVE 160
35 
36 
42  typedef double alignment_score_t;
43 
44 
48  struct AlignmentBase {
49 
53  typedef std::vector<bool> events_storage_t;
54 
55 
56  AlignmentBase(seq_len_t p_start, seq_len_t t_start, events_storage_t &events)
57  : _pattern_start(p_start),
58  _text_start(t_start),
59  _len(events.size())
60  {
61  _events.swap(events);
62  }
63 
64 
65  seq_len_t pattern_start() const { return _pattern_start; }
66 
67 
68  seq_len_t text_start() const { return _text_start; }
69 
70 
71  seq_len_t size() const { return _len; }
72 
73 
74  protected:
75 
76  seq_len_t _pattern_start, _text_start, _len;
77  events_storage_t _events;
78 
79 
80  AlignmentBase() {}
81 
82 
83  AlignmentBase(seq_len_t p_start, seq_len_t t_start, seq_len_t len)
84  : _pattern_start(p_start),
85  _text_start(t_start),
86  _len(len)
87  {
88  }
89 
90  };
91 
92 
96  struct NoGapAlignment : public AlignmentBase {
97 
101  NoGapAlignment(seq_len_t p_start, seq_len_t t_start, events_storage_t &events)
102  : AlignmentBase(p_start, t_start, events)
103  {
104  }
105 
106 
107  NoGapAlignment(seq_len_t p_start, seq_len_t t_start, seq_len_t len)
108  : AlignmentBase(p_start, t_start, len)
109  {
110  }
111 
112 
113  bool isMismatch(seq_len_t i) const { return _events[i]; }
114 
115 
116  protected:
117 
118  NoGapAlignment() {}
119 
120  };
121 
122 
126  struct GappedAlignment : public AlignmentBase {
127 
128 
129  GappedAlignment(seq_len_t p_start, seq_len_t t_start, events_storage_t &events)
130  : AlignmentBase(p_start, t_start, events)
131  {
132  }
133 
134 
136  bool isMatch(seq_len_t i) const { return !(_events[i*2] && _events[i*2 + 1]); }
137 
138  bool isMismatch(seq_len_t i) const { return !_events[i*2] && _events[i*2 + 1]; }
139 
140  bool isIns(seq_len_t i) const { return _events[i*2] && !_events[i*2 + 1]; }
141 
142  bool isDel(seq_len_t i) const { return _events[i*2] && _events[i*2 + 1]; }
144 
145 
146  protected:
147 
148  GappedAlignment() {}
149 
150  };
151 
152 }
153 
154 #endif
Definition: aligner.h:37
Definition: alignment.h:126
Definition: alignment.h:48
Definition: alignment.h:96