LocARNA-1.8.11
sequence_annotation.hh
1 #ifndef LOCARNA_SEQUENCE_ANNOTATION_HH
2 #define LOCARNA_SEQUENCE_ANNOTATION_HH
3 
4 #ifdef HAVE_CONFIG_H
5 # include <config.h>
6 #endif
7 
8 #include <string>
9 #include <vector>
10 
11 #include <iosfwd>
12 
13 #include "aux.hh"
14 
15 namespace LocARNA {
16  class AlignmentEdges;
17 
25 
27  typedef std::string name_t;
28 
31  typedef std::vector<std::string> annotation_t;
32 
40  annotation_t annotation_;
41 
45  static
46  const
47  SequenceAnnotation empty_instance_;
48 
49  public:
50 
55  explicit
57 
63  explicit
64  SequenceAnnotation(const std::string &annotation_string);
65 
75  explicit
76  SequenceAnnotation(const std::vector<std::string> &annotation_strings);
77 
94  SequenceAnnotation(const AlignmentEdges &edges,
95  const SequenceAnnotation &annotationA,
96  const SequenceAnnotation &annotationB);
97 
98 
103  static
104  const SequenceAnnotation&
106  return SequenceAnnotation::empty_instance_;
107  }
108 
115  size_t
116  length() const {
117  return annotation_.size()>0?annotation_[0].size():0;
118  }
119 
124  bool
125  empty() const {
126  return length()==0;
127  }
128 
133  size_t
134  name_length() const {
135  return annotation_.size();
136  }
137 
145  const std::string &
146  annotation_string(size_t i) const {
147  assert(i<annotation_.size());
148  return annotation_[i];
149  }
150 
158  std::string
159  single_string(char sep='#') const;
160 
166  static
167  bool
168  is_neutral_char(char c) {
169  return c==' ' || c=='.';
170  }
171 
176  static
177  bool
178  is_neutral(const name_t &name);
179 
185  bool
186  is_neutral_pos(size_t i) const;
187 
193  std::string
194  name(size_t i) const;
195 
201  void
202  push_back_name(const name_t &name);
203 
204  /*
205  * @brief test for duplicate names
206  * @return whether annotation contains duplicate names
207  */
208  bool
209  duplicate_names() const;
210 
211  /*
212  * @brief test for name clashs
213  *
214  * @param edges alignment edges between A and B
215  * @param annotationA annotation A
216  * @param annotationB annotation B
217  *
218  * @return whether names in A and B clash when aligned via edges
219  */
220  static
221  bool
222  clashing_names(const AlignmentEdges &edges,
223  const SequenceAnnotation &annotationA,
224  const SequenceAnnotation &annotationB);
225 
226  };
227 }
228 
229 #endif // LOCARNA_SEQUENCE_ANNOTATION_HH
std::string single_string(char sep='#') const
Definition: sequence_annotation.cc:66
static bool is_neutral_char(char c)
Test for neutral character.
Definition: sequence_annotation.hh:168
pair of vector of alignment edges
Definition: alignment.hh:63
const std::string & annotation_string(size_t i) const
Definition: sequence_annotation.hh:146
static const SequenceAnnotation & empty_instance()
initialize the static member empty_instance
Definition: sequence_annotation.hh:105
bool is_neutral_pos(size_t i) const
Test neutral name at a position.
Definition: sequence_annotation.cc:80
size_t size_type
general size type
Definition: aux.hh:94
Definition: aligner.cc:17
SequenceAnnotation(size_type name_length=0)
Construct empty.
Definition: sequence_annotation.hh:56
size_t name_length() const
Name length.
Definition: sequence_annotation.hh:134
std::string name(size_t i) const
Access name at position.
Definition: sequence_annotation.cc:89
static bool is_neutral(const name_t &name)
Test neutral name.
Definition: sequence_annotation.cc:71
bool empty() const
Check empty.
Definition: sequence_annotation.hh:125
void push_back_name(const name_t &name)
Push back name to the annotation strings in annotation_.
Definition: sequence_annotation.cc:102
Annotation of a sequence.
Definition: sequence_annotation.hh:24
size_t length() const
Size of the represented range.
Definition: sequence_annotation.hh:116