| 35 | } |
| 36 | |
| 37 | void CrossLinksDB::readFromOBOFile(const String& filename) |
| 38 | { |
| 39 | ResidueModification mod; |
| 40 | // add multiple mods for multiple specificities |
| 41 | //Map<String, ResidueModification> all_mods; |
| 42 | multimap<String, ResidueModification> all_mods; |
| 43 | |
| 44 | ifstream is(File::find(filename).c_str()); |
| 45 | String line, line_wo_spaces, id; |
| 46 | String origin = ""; |
| 47 | |
| 48 | bool reading_mono_link = false; |
| 49 | |
| 50 | //parse file |
| 51 | while (getline(is, line, '\n')) |
| 52 | { |
| 53 | line.trim(); |
| 54 | line_wo_spaces = line; |
| 55 | line_wo_spaces.removeWhitespaces(); |
| 56 | |
| 57 | if (line.empty() || line[0] == '!') //skip empty lines and comments |
| 58 | { |
| 59 | continue; |
| 60 | } |
| 61 | |
| 62 | if (line_wo_spaces == "[Term]") //new term |
| 63 | { |
| 64 | // if the last [Term] was a moon-link, then it does not belong in CrossLinksDB |
| 65 | if (!id.empty() && !reading_mono_link) //store last term |
| 66 | { |
| 67 | // split into single residues and make unique (for XL-MS, where equal specificities for both sides are possible) |
| 68 | vector<String> origins; |
| 69 | origin.split(",", origins); |
| 70 | |
| 71 | std::sort(origins.begin(), origins.end()); |
| 72 | vector<String>::iterator unique_end = unique(origins.begin(), origins.end()); |
| 73 | origins.resize(distance(origins.begin(), unique_end)); |
| 74 | |
| 75 | for (vector<String>::iterator orig_it = origins.begin(); orig_it != origins.end(); ++orig_it) |
| 76 | { |
| 77 | // we don't allow modifications with ambiguity codes as origin (except "X"): |
| 78 | if ((orig_it->size() == 1) && (*orig_it != "B") && (*orig_it != "J") && (*orig_it != "Z")) |
| 79 | { |
| 80 | mod.setOrigin((*orig_it)[0]); |
| 81 | all_mods.insert(make_pair(id, mod)); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if (origin.hasSubstring("ProteinN-term")) |
| 86 | { |
| 87 | mod.setTermSpecificity(ResidueModification::N_TERM); |
| 88 | mod.setOrigin('X'); |
| 89 | all_mods.insert(make_pair(id, mod)); |
| 90 | } |
| 91 | if (origin.hasSubstring("ProteinC-term")) |
| 92 | { |
| 93 | mod.setTermSpecificity(ResidueModification::C_TERM); |
| 94 | mod.setOrigin('X'); |
nothing calls this directly
no test coverage detected