LocARNA-1.9.2
|
00001 #ifndef LOCARNA_SEQUENCE_ANNOTATION_HH 00002 #define LOCARNA_SEQUENCE_ANNOTATION_HH 00003 00004 #ifdef HAVE_CONFIG_H 00005 #include <config.h> 00006 #endif 00007 00008 #include <string> 00009 #include <vector> 00010 00011 #include <iosfwd> 00012 00013 #include "aux.hh" 00014 00015 namespace LocARNA { 00016 class AlignmentEdges; 00017 00024 class SequenceAnnotation { 00026 typedef std::string name_t; 00027 00030 typedef std::vector<std::string> annotation_t; 00031 00039 annotation_t annotation_; 00040 00044 static const SequenceAnnotation empty_instance_; 00045 00046 public: 00051 explicit SequenceAnnotation(size_type name_length = 0) 00052 : annotation_(name_length) {} 00053 00059 explicit SequenceAnnotation(const std::string &annotation_string); 00060 00071 explicit SequenceAnnotation( 00072 const std::vector<std::string> &annotation_strings); 00073 00093 SequenceAnnotation(const AlignmentEdges &edges, 00094 const SequenceAnnotation &annotationA, 00095 const SequenceAnnotation &annotationB); 00096 00101 static const SequenceAnnotation & 00102 empty_instance() { 00103 return SequenceAnnotation::empty_instance_; 00104 } 00105 00112 size_t 00113 length() const { 00114 return annotation_.size() > 0 ? annotation_[0].size() : 0; 00115 } 00116 00121 bool 00122 empty() const { 00123 return length() == 0; 00124 } 00125 00130 size_t 00131 name_length() const { 00132 return annotation_.size(); 00133 } 00134 00142 const std::string & 00143 annotation_string(size_t i) const { 00144 assert(i < annotation_.size()); 00145 return annotation_[i]; 00146 } 00147 00155 std::string 00156 single_string(char sep = '#') const; 00157 00163 static bool 00164 is_neutral_char(char c) { 00165 return c == ' ' || c == '.'; 00166 } 00167 00173 static bool 00174 is_neutral(const name_t &name); 00175 00182 bool 00183 is_neutral_pos(size_t i) const; 00184 00190 std::string 00191 name(size_t i) const; 00192 00198 void 00199 push_back_name(const name_t &name); 00200 00201 /* 00202 * @brief test for duplicate names 00203 * @return whether annotation contains duplicate names 00204 */ 00205 bool 00206 duplicate_names() const; 00207 00208 /* 00209 * @brief test for name clashs 00210 * 00211 * @param edges alignment edges between A and B 00212 * @param annotationA annotation A 00213 * @param annotationB annotation B 00214 * 00215 * @return whether names in A and B clash when aligned via edges 00216 */ 00217 static bool 00218 clashing_names(const AlignmentEdges &edges, 00219 const SequenceAnnotation &annotationA, 00220 const SequenceAnnotation &annotationB); 00221 }; 00222 } 00223 00224 #endif // LOCARNA_SEQUENCE_ANNOTATION_HH