| 96 | } |
| 97 | |
| 98 | void IDMergerAlgorithm::returnResultsAndClear( |
| 99 | ProteinIdentification& prots, |
| 100 | vector<PeptideIdentification>& peps) |
| 101 | { |
| 102 | // convert the map from file origin to idx into |
| 103 | // a vector |
| 104 | StringList newOrigins(file_origin_to_idx_.size()); |
| 105 | for (auto& entry : file_origin_to_idx_) |
| 106 | { |
| 107 | newOrigins[entry.second] = entry.first; |
| 108 | } |
| 109 | // currently setPrimaryMSRunPath does not support move (const ref) |
| 110 | prot_result_.setPrimaryMSRunPath(newOrigins); |
| 111 | std::swap(prots, prot_result_); |
| 112 | std::swap(peps, pep_result_); |
| 113 | //reset so the new this class is reuseable |
| 114 | prot_result_ = ProteinIdentification{}; |
| 115 | prot_result_.setIdentifier(getNewIdentifier_()); |
| 116 | //clear, if user gave non-empty vector |
| 117 | pep_result_.clear(); |
| 118 | //reset internals |
| 119 | file_origin_to_idx_.clear(); |
| 120 | |
| 121 | for (auto& p : collected_protein_hits_) |
| 122 | prots.getHits().push_back(std::move(const_cast<ProteinHit&>(p))); |
| 123 | // above invalidates set but we clear right after |
| 124 | |
| 125 | collected_protein_hits_.clear(); |
| 126 | } |
| 127 | |
| 128 | String IDMergerAlgorithm::getNewIdentifier_() const |
| 129 | { |