LocARNA-1.8.11
trace_controller.hh
1 #ifndef LOCARNA_TRACE_CONTROLLER_HH
2 #define LOCARNA_TRACE_CONTROLLER_HH
3 
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7 
8 #include <vector>
9 #include <assert.h>
10 
11 #include "aux.hh"
12 #include "multiple_alignment.hh"
13 
14 namespace LocARNA {
15 
16  class Sequence;
17 
25  class TraceRange {
26  public:
29 
31  typedef std::pair<SeqEntry, SeqEntry> seqentry_pair_t;
32 
43  static
44  seqentry_pair_t
45  remove_common_gaps(const SeqEntry &aliA,
46  const SeqEntry &aliB);
47 
48  protected:
49  std::vector<size_t> min_col_vector_;
50  std::vector<size_t> max_col_vector_;
51  TraceRange() {
53  }
54 
55  public:
77  TraceRange(const SeqEntry &pseqA,
78  const SeqEntry &pseqB,
79  const SeqEntry &aliA,
80  const SeqEntry &aliB,
81  size_type delta);
82 
83 
98  TraceRange(size_type lenA, size_type lenB, const std::vector<TraceRange> &trs, size_type delta);
99 
107  size_type
109  size_type j,
110  const std::vector<TraceRange> &trs) const;
111 
116  size_t
117  rows() const {return min_col_vector_.size()-1;}
118 
124  size_t
125  min_col(size_t i) const {return min_col_vector_[i];}
126 
132  size_t
133  max_col(size_t i) const {return max_col_vector_[i];}
134 
140  void
141  print_debug(std::ostream & out) const;
142 
143  };
144 
145 
148 
149  public:
156  virtual
157  bool
158  is_valid_match(size_t i, size_t j) const=0;
159 
160  virtual
161  ~MatchController();
162 
163  };
164 
165 
177  class TraceController : public TraceRange, public MatchController {
178 
179  private:
180  // The delimiter character separating the two sequences in the alignment string
181  static const char delimiter = '&';
182 
187  void
188  merge_in_trace_range(const TraceRange &tr);
189 
191  const size_type delta_;
192 
193  // /**
194  // * switch between strict and relaxed merging of pairwise trace
195  // * ranges
196  // */
197  // const bool relaxed_merging_;
198 
199  public:
200 
214  TraceController(const Sequence &seqA,
215  const Sequence &seqB,
216  const MultipleAlignment *ma,
217  int delta,
218  bool relaxed_merging=false);
219 
221  virtual
222  ~TraceController();
223 
230  bool
231  is_valid(size_type i, size_type j) const;
232 
239  virtual
240  bool
241  is_valid_match(size_type i, size_type j) const;
242 
247  size_type get_delta() const {return delta_;}
248 
253  void
254  print_debug(std::ostream & out) const;
255 
256  private:
268  void
269  constrain_wo_ref(size_type lenA, size_type lenB, size_type delta);
270 
271  };
272 
273  inline
274  bool
276  return min_col(i)<=j && j<=max_col(i);
277  }
278 
279  inline
280  bool
282  return is_valid(i,j) && is_valid(i-1,j-1);
283  }
284 
285 } //end namespace
286 
287 
288 #endif /* LOCARNA_TRACE_CONTROLLER_HH */
size_t rows() const
Read number of rows.
Definition: trace_controller.hh:117
Represents a range of traces.
Definition: trace_controller.hh:25
size_t max_col(size_t i) const
Maximal column of trace in a row.
Definition: trace_controller.hh:133
std::vector< size_t > max_col_vector_
Definition: trace_controller.hh:50
A row in a multiple alignment.
Definition: multiple_alignment.hh:144
std::vector< size_t > min_col_vector_
minimal column in row
Definition: trace_controller.hh:49
size_t size_type
general size type
Definition: aux.hh:94
MultipleAlignment::SeqEntry SeqEntry
alias for MultipleAlignment::SeqEntry
Definition: trace_controller.hh:28
Definition: aligner.cc:17
void print_debug(std::ostream &out) const
Definition: trace_controller.cc:309
virtual bool is_valid_match(size_type i, size_type j) const
Definition: trace_controller.hh:281
bool is_valid(size_type i, size_type j) const
Definition: trace_controller.hh:275
size_type get_delta() const
Read deviation.
Definition: trace_controller.hh:247
static seqentry_pair_t remove_common_gaps(const SeqEntry &aliA, const SeqEntry &aliB)
Definition: trace_controller.cc:23
TraceRange()
Construct empty.
Definition: trace_controller.hh:52
Controls the matrix cells valid for traces.
Definition: trace_controller.hh:177
abstract class that declares the method is_valid_match()
Definition: trace_controller.hh:147
size_type consensus_cost(size_type i, size_type j, const std::vector< TraceRange > &trs) const
Computes cost of a cut in the consensus trace of a trace range set.
Definition: trace_controller.cc:212
Represents a multiple alignment.
Definition: multiple_alignment.hh:65
size_t min_col(size_t i) const
Minimal column of trace in a row.
Definition: trace_controller.hh:125
"Sequence View" of multiple alignment as array of column vectors
Definition: sequence.hh:29
std::pair< SeqEntry, SeqEntry > seqentry_pair_t
pair of sequence entries
Definition: trace_controller.hh:31