| 144 | } |
| 145 | |
| 146 | BaseFeature::AnnotationState BaseFeature::getAnnotationState() const |
| 147 | { |
| 148 | if (id_matches_.empty()) // consider IDs in old format |
| 149 | { |
| 150 | if (peptides_.empty()) |
| 151 | { |
| 152 | return FEATURE_ID_NONE; |
| 153 | } |
| 154 | if (peptides_.size() == 1 && !peptides_[0].getHits().empty()) |
| 155 | { |
| 156 | return FEATURE_ID_SINGLE; |
| 157 | } |
| 158 | std::set<String> seqs; |
| 159 | for (Size i = 0; i < peptides_.size(); ++i) |
| 160 | { |
| 161 | if (!peptides_[i].getHits().empty()) |
| 162 | { |
| 163 | PeptideIdentification id_tmp = peptides_[i]; |
| 164 | id_tmp.sort(); // look at best hit only - requires sorting |
| 165 | seqs.insert(id_tmp.getHits()[0].getSequence().toString()); |
| 166 | } |
| 167 | } |
| 168 | if (seqs.size() == 1) |
| 169 | { |
| 170 | return FEATURE_ID_MULTIPLE_SAME; // hits have identical seqs |
| 171 | } |
| 172 | if (seqs.size() > 1) |
| 173 | { |
| 174 | return FEATURE_ID_MULTIPLE_DIVERGENT; // multiple different annotations ... probably bad mapping |
| 175 | } |
| 176 | /*else if (seqs.size()==0)*/ |
| 177 | return FEATURE_ID_NONE; // very rare case of empty hits |
| 178 | } |
| 179 | else // consider IDs in new format |
| 180 | { |
| 181 | if (id_matches_.size() == 1) |
| 182 | { |
| 183 | return FEATURE_ID_SINGLE; |
| 184 | } |
| 185 | // if there are multiple IDs, check if all are equal (to the first): |
| 186 | auto it = id_matches_.begin(); |
| 187 | IdentificationData::IdentifiedMolecule molecule = (*it)->identified_molecule_var; |
| 188 | for (++it; it != id_matches_.end(); ++it) |
| 189 | { |
| 190 | if ((*it)->identified_molecule_var != molecule) |
| 191 | { |
| 192 | return FEATURE_ID_MULTIPLE_DIVERGENT; |
| 193 | } |
| 194 | } |
| 195 | return FEATURE_ID_MULTIPLE_SAME; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | |
| 200 | bool BaseFeature::hasPrimaryID() const |