LocARNA-1.8.11
alignment.hh
1 #ifndef LOCARNA_ALIGNMENT_HH
2 #define LOCARNA_ALIGNMENT_HH
3 
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7 
8 #include <iosfwd>
9 #include <vector>
10 #include "aux.hh"
11 #include "scoring_fwd.hh"
12 
13 namespace LocARNA {
14 
15  class AlignmentImpl;
16  class RnaData;
17  class Sequence;
18  class RnaStructure;
19  class string1;
20  class AnchorConstraints;
21 
22  // unnest definitions of alignment edges
23 
27  class EdgeEnd {
28  int end_; //<! position or Gap
29  public:
30 
32  EdgeEnd(): end_(0) {}
33 
36  EdgeEnd(pos_type end): end_(int(end)) {}
37 
40  EdgeEnd(Gap end): end_(-int(end.idx())-1) {}
41 
44  bool is_gap() const {return end_<0;}
45 
48  bool is_pos() const {return end_>0;}
49 
52  Gap gap() const {assert(end_<0); return Gap(size_t(-(end_+1)));}
53 
56  operator pos_type() const {assert(end_>0); return pos_type(end_);}
57  };
58 
60  typedef std::vector<EdgeEnd> Alignment__edge_ends_t;
61 
63  class AlignmentEdges : public std::pair<Alignment__edge_ends_t,Alignment__edge_ends_t> {
64  typedef Alignment__edge_ends_t edge_ends_t;
65  typedef std::pair<edge_ends_t,edge_ends_t> parent_t;
66  public:
67 
69  AlignmentEdges(const edge_ends_t &x,
70  const edge_ends_t &y)
71  :parent_t(x,y)
72  {
73  assert(x.size()==y.size());
74  };
75 
77  size_t
78  size() const {return first.size();}
79  };
80 
81 
87  class Alignment {
88 
89  AlignmentImpl *pimpl_;
90 
91  public:
92 
95 
97  typedef Alignment__edge_ends_t edge_ends_t;
98 
101 
102 
108  static
109  edge_ends_t
110  alistr_to_edge_ends(const std::string &alistr);
111 
112 
118  Alignment(const Sequence &seqA,const Sequence &seqB);
119 
123  ~Alignment();
124 
132  Alignment(const Sequence &seqA, const Sequence &seqB,
133  const edges_t &edges);
134 
140  Alignment(const Alignment &alignment);
141 
147  Alignment &operator =(const Alignment &alignment);
148 
155  void
156  swap(Alignment &a1,Alignment &a2);
157 
158 
163  void
164  set_consensus_structure(const RnaStructure &structure);
165 
171  void
172  set_structures(const RnaStructure &structureA,const RnaStructure &structureB);
173 
177  void
178  clear();
179 
186  void
187  append(edge_end_t i, edge_end_t j);
188 
192  void
193  add_basepairA(int i, int j);
194 
198  void
199  add_basepairB(int i, int j);
200 
201 
205  void add_deleted_basepairA(int i, int j);
209  void add_deleted_basepairB(int i, int j);
210 
229  const edges_t
230  alignment_edges(bool only_local) const;
231 
232  /* start/end of (locally) aligned subsequences
233  (this is used when finding k-best alignments in Aligner)
234  */
235 
237  size_type
238  local_startA() const;
239 
241  size_type
242  local_endA() const;
243 
245  size_type
246  local_startB() const;
247 
249  size_type
250  local_endB() const;
251 
252 
258  std::string
259  dot_bracket_structureA(bool only_local) const;
260 
266  std::string
267  dot_bracket_structureB(bool only_local) const;
268 
269 
270  /* access */
271 
276  const Sequence &seqA() const;
277 
282  const Sequence &seqB() const;
283 
284  };
285 
286 
287 }
288 #endif
AlignmentEdges edges_t
description of alignment edges
Definition: alignment.hh:100
end of an alignment edge
Definition: alignment.hh:27
AlignmentEdges(const edge_ends_t &x, const edge_ends_t &y)
Construct asserting equal length.
Definition: alignment.hh:69
Gap gap() const
Definition: alignment.hh:52
pair of vector of alignment edges
Definition: alignment.hh:63
EdgeEnd(pos_type end)
construct as position
Definition: alignment.hh:36
size_type pos_type
type of a sequence position
Definition: aux.hh:97
size_t size() const
Size.
Definition: alignment.hh:78
std::vector< EdgeEnd > Alignment__edge_ends_t
vector of alignment edge ends
Definition: alignment.hh:60
size_t size_type
general size type
Definition: aux.hh:94
EdgeEnd(Gap end)
construct as gap
Definition: alignment.hh:40
Definition: aligner.cc:17
EdgeEnd edge_end_t
edge end
Definition: alignment.hh:94
"enum class" of gaps in alignment edges
Definition: aux.hh:104
Implementation of Alignment.
Definition: alignment_impl.hh:22
bool is_pos() const
is position test
Definition: alignment.hh:48
An RNA secondary structure.
Definition: rna_structure.hh:26
EdgeEnd()
construct as invalid end
Definition: alignment.hh:32
Represents a structure-annotated sequence alignment.
Definition: alignment.hh:87
bool is_gap() const
gap test
Definition: alignment.hh:44
"Sequence View" of multiple alignment as array of column vectors
Definition: sequence.hh:29
Alignment__edge_ends_t edge_ends_t
edge ends
Definition: alignment.hh:97