LocARNA-2.0.0
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  public:
27  typedef std::string name_t;
28 
34  : annotation_(name_length) {}
35 
41  explicit SequenceAnnotation(const std::string &annotation_string);
42 
53  explicit SequenceAnnotation(
54  const std::vector<std::string> &annotation_strings);
55 
76  const SequenceAnnotation &annotationA,
77  const SequenceAnnotation &annotationB);
78 
83  static const SequenceAnnotation &
85  return SequenceAnnotation::empty_instance_;
86  }
87 
94  size_t
95  length() const {
96  return annotation_.size() > 0 ? annotation_[0].size() : 0;
97  }
98 
103  bool
104  empty() const {
105  return length() == 0;
106  }
107 
112  size_t
113  name_length() const {
114  return annotation_.size();
115  }
116 
124  const std::string &
125  annotation_string(size_t i) const {
126  assert(i < annotation_.size());
127  return annotation_[i];
128  }
129 
137  std::string
138  single_string(char sep = '#') const;
139 
145  static bool
146  is_neutral_char(char c) {
147  return c == ' ' || c == '.';
148  }
149 
155  static bool
156  is_neutral(const name_t &name);
157 
164  bool
165  is_neutral_pos(size_t i) const;
166 
172  std::string
173  name(size_t i) const;
174 
180  void
181  push_back_name(const name_t &name);
182 
183  /*
184  * @brief test for duplicate names
185  * @return whether annotation contains duplicate names
186  */
187  bool
188  duplicate_names() const;
189 
190  // /*
191  // * @brief test for name clashs
192  // *
193  // * @param edges alignment edges between A and B
194  // * @param annotationA annotation A
195  // * @param annotationB annotation B
196  // *
197  // * @return whether names in A and B clash when aligned via edges
198  // */
199  // static bool
200  // clashing_names(const AlignmentEdges &edges,
201  // const SequenceAnnotation &annotationA,
202  // const SequenceAnnotation &annotationB);
203 
204  private:
207  typedef std::vector<std::string> annotation_t;
208 
216  annotation_t annotation_;
217 
221  static const SequenceAnnotation empty_instance_;
222  };
223 }
224 
225 #endif // LOCARNA_SEQUENCE_ANNOTATION_HH
Definition: alignment.hh:73
Annotation of a sequence.
Definition: sequence_annotation.hh:24
std::string name_t
an anchcor name
Definition: sequence_annotation.hh:27
bool is_neutral_pos(size_t i) const
Test neutral name at a position.
Definition: sequence_annotation.cc:72
std::string name(size_t i) const
Access name at position.
Definition: sequence_annotation.cc:83
static bool is_neutral(const name_t &name)
Test neutral name.
Definition: sequence_annotation.cc:66
void push_back_name(const name_t &name)
Push back name to the annotation strings in annotation_.
Definition: sequence_annotation.cc:96
static const SequenceAnnotation & empty_instance()
initialize the static member empty_instance
Definition: sequence_annotation.hh:84
std::string single_string(char sep='#') const
Definition: sequence_annotation.cc:61
static bool is_neutral_char(char c)
Test for neutral character.
Definition: sequence_annotation.hh:146
SequenceAnnotation(size_type name_length=0)
Construct empty.
Definition: sequence_annotation.hh:33
const std::string & annotation_string(size_t i) const
Definition: sequence_annotation.hh:125
size_t name_length() const
Name length.
Definition: sequence_annotation.hh:113
bool empty() const
Check empty.
Definition: sequence_annotation.hh:104
size_t length() const
Size of the represented range.
Definition: sequence_annotation.hh:95
Definition: aligner.cc:15
size_t size_type
general size type
Definition: aux.hh:120