| 161 | } |
| 162 | |
| 163 | static bool checkPeptideIdentification_(BaseFeature& feature, |
| 164 | const bool remove_annotated_features, |
| 165 | const bool remove_unannotated_features, |
| 166 | const StringList& sequences, |
| 167 | const String& sequence_comparison_method, |
| 168 | const StringList& accessions, |
| 169 | const bool keep_best_score_id, |
| 170 | const bool remove_clashes) |
| 171 | { |
| 172 | //flag: remove_annotated_features and non-empty peptideIdentifications |
| 173 | if (remove_annotated_features && !feature.getPeptideIdentifications().empty()) |
| 174 | { |
| 175 | return false; |
| 176 | } |
| 177 | //flag: remove_unannotated_features and no peptideIdentifications |
| 178 | if (remove_unannotated_features && feature.getPeptideIdentifications().empty()) |
| 179 | { |
| 180 | return false; |
| 181 | } |
| 182 | //flag: remove_clashes |
| 183 | if (remove_clashes && !feature.getPeptideIdentifications().empty()) |
| 184 | { |
| 185 | String temp = feature.getPeptideIdentifications().begin()->getHits().begin()->getSequence().toString(); |
| 186 | //loop over all peptideIdentifications |
| 187 | for (const PeptideIdentification& pep : feature.getPeptideIdentifications()) |
| 188 | { |
| 189 | //loop over all peptideHits |
| 190 | for (const PeptideHit& pep_hit : pep.getHits()) |
| 191 | { |
| 192 | if (pep_hit.getSequence().toString() != temp) |
| 193 | { |
| 194 | return false; |
| 195 | } |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | //flag: keep_best_score_id |
| 200 | if (keep_best_score_id && !feature.getPeptideIdentifications().empty()) |
| 201 | { |
| 202 | PeptideIdentification temp = feature.getPeptideIdentifications().front(); |
| 203 | //loop over all peptideIdentifications |
| 204 | for (const PeptideIdentification& pep : feature.getPeptideIdentifications()) |
| 205 | { |
| 206 | //loop over all peptideHits |
| 207 | for (const PeptideHit& pep_hit : pep.getHits()) |
| 208 | { |
| 209 | if ((pep.isHigherScoreBetter() && pep_hit.getScore() > temp.getHits().front().getScore()) || |
| 210 | (!pep.isHigherScoreBetter() && pep_hit.getScore() < temp.getHits().front().getScore())) |
| 211 | { |
| 212 | temp = pep; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | feature.setPeptideIdentifications(vector<PeptideIdentification>(1, temp)); |
| 217 | // not filtering sequences or accessions |
| 218 | if (sequences.empty() && accessions.empty()) |
| 219 | { |
| 220 | return true; |
nothing calls this directly
no test coverage detected