Initialization of global variables (= graph)
| 251 | |
| 252 | // Initialization of global variables (= graph) |
| 253 | void PeptideProteinResolution::buildGraph(ProteinIdentification& protein, |
| 254 | const vector<PeptideIdentification>& peptides, bool skip_sort) |
| 255 | { |
| 256 | vector<ProteinIdentification::ProteinGroup>& groups = protein.getIndistinguishableProteins(); |
| 257 | |
| 258 | if (groups.empty()) |
| 259 | { |
| 260 | throw Exception::MissingInformation( |
| 261 | __FILE__, |
| 262 | __LINE__, |
| 263 | OPENMS_PRETTY_FUNCTION, |
| 264 | "No indistinguishable Groups annotated. Currently this class only resolves across groups."); |
| 265 | } |
| 266 | |
| 267 | OPENMS_LOG_INFO << "Resolving peptides between " << protein.getHits().size() << " proteins in " << groups.size() << " indistinguishable groups." << std::endl; |
| 268 | |
| 269 | |
| 270 | if (!skip_sort) sort(groups.begin(), groups.end()); |
| 271 | |
| 272 | // TODO this is only needed for target_first option |
| 273 | std::unordered_set<std::string> decoy_accs; |
| 274 | for (const ProteinHit& p : protein.getHits()) |
| 275 | { |
| 276 | if (p.metaValueExists("target_decoy") && p.getMetaValue("target_decoy") == "decoy") |
| 277 | { |
| 278 | decoy_accs.insert(p.getAccession()); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | // Construct intermediate mapping of single protein accessions |
| 283 | // to indist. protein groups |
| 284 | for (vector<ProteinIdentification::ProteinGroup>::const_iterator group_it = |
| 285 | groups.begin(); |
| 286 | group_it != groups.end(); ++group_it) |
| 287 | { |
| 288 | for (vector<String>::const_iterator acc_it = group_it->accessions.begin(); |
| 289 | acc_it != group_it->accessions.end(); ++acc_it) |
| 290 | { |
| 291 | Size idx = group_it - groups.begin(); |
| 292 | prot_acc_to_indist_prot_grp_[*acc_it] = idx; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // Go through PeptideIDs and construct a bidirectional mapping |
| 297 | for (vector<PeptideIdentification>::const_iterator pep_it = peptides.begin(); |
| 298 | pep_it != peptides.end(); |
| 299 | ++pep_it) |
| 300 | { |
| 301 | Size pep_index = pep_it - peptides.begin(); |
| 302 | |
| 303 | const vector<PeptideHit>& hits = pep_it->getHits(); |
| 304 | if (!hits.empty()) |
| 305 | { |
| 306 | PeptideHit best_hit = hits[0]; |
| 307 | const vector<PeptideEvidence>& pepev = best_hit.getPeptideEvidences(); |
| 308 | |
| 309 | for (vector<PeptideEvidence>::const_iterator pepev_it = pepev.begin(); |
| 310 | pepev_it != pepev.end(); ++pepev_it) |
no test coverage detected