| 552 | } |
| 553 | |
| 554 | void ModificationsDB::readFromOBOFile(const String& filename) |
| 555 | { |
| 556 | ResidueModification mod; |
| 557 | // add multiple mods for multiple specificities |
| 558 | //Map<String, ResidueModification> all_mods; |
| 559 | multimap<String, ResidueModification> all_mods; |
| 560 | |
| 561 | ifstream is(File::find(filename).c_str()); |
| 562 | String line, line_wo_spaces, id; |
| 563 | String origin = ""; |
| 564 | |
| 565 | bool reading_cross_link = false; |
| 566 | |
| 567 | //parse file |
| 568 | while (getline(is, line, '\n')) |
| 569 | { |
| 570 | line.trim(); |
| 571 | line_wo_spaces = line; |
| 572 | line_wo_spaces.removeWhitespaces(); |
| 573 | |
| 574 | if (line.empty() || line[0] == '!') //skip empty lines and comments |
| 575 | { |
| 576 | continue; |
| 577 | } |
| 578 | |
| 579 | if (line_wo_spaces == "[Term]") //new term |
| 580 | { |
| 581 | // if the last [Term] was a moon-link, then it does not belong in CrossLinksDB |
| 582 | if (!id.empty() && !reading_cross_link) //store last term |
| 583 | { |
| 584 | // split into single residues and make unique (for XL-MS, where equal specificities for both sides are possible) |
| 585 | vector<String> origins; |
| 586 | origin.split(",", origins); |
| 587 | |
| 588 | std::sort(origins.begin(), origins.end()); |
| 589 | vector<String>::iterator unique_end = unique(origins.begin(), origins.end()); |
| 590 | origins.resize(distance(origins.begin(), unique_end)); |
| 591 | |
| 592 | for (vector<String>::iterator orig_it = origins.begin(); orig_it != origins.end(); ++orig_it) |
| 593 | { |
| 594 | // we don't allow modifications with ambiguity codes as origin (except "X"): |
| 595 | if ((orig_it->size() == 1) && (*orig_it != "B") && (*orig_it != "J") && (*orig_it != "Z")) |
| 596 | { |
| 597 | mod.setOrigin((*orig_it)[0]); |
| 598 | all_mods.insert(make_pair(id, mod)); |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | // for mono-links from XLMOD.obo: |
| 603 | if (origin.hasSubstring("ProteinN-term")) |
| 604 | { |
| 605 | mod.setTermSpecificity(ResidueModification::PROTEIN_N_TERM); |
| 606 | mod.setOrigin('X'); |
| 607 | all_mods.insert(make_pair(id, mod)); |
| 608 | } |
| 609 | if (origin.hasSubstring("ProteinC-term")) |
| 610 | { |
| 611 | mod.setTermSpecificity(ResidueModification::PROTEIN_C_TERM); |
nothing calls this directly
no test coverage detected