fill map with possible mass-differences along with their explanation
| 133 | |
| 134 | /// fill map with possible mass-differences along with their explanation |
| 135 | void MassExplainer::compute() |
| 136 | { |
| 137 | // differentiate between neutral and charged adducts |
| 138 | AdductsType adduct_neutral, adduct_charged; |
| 139 | for (AdductsType::const_iterator it = adduct_base_.begin(); it != adduct_base_.end(); ++it) |
| 140 | { |
| 141 | if (it->getCharge() == 0) |
| 142 | { |
| 143 | adduct_neutral.push_back(*it); |
| 144 | } |
| 145 | else |
| 146 | { |
| 147 | adduct_charged.push_back(*it); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // calculate some initial boundaries that can be used to shorten the enumeration process |
| 152 | //Int q_comp_min = -max_span_; //minimal expected charge of compomer |
| 153 | //Int q_comp_max = max_span_; //maximal expected charge of compomer |
| 154 | Int max_pq = q_max_; //maximal number of positive adduct-charges for a compomer |
| 155 | //Int max_nq = q_max_; //maximal number of negative adduct-charges for a compomer |
| 156 | |
| 157 | for (AdductsType::const_iterator it = adduct_charged.begin(); it != adduct_charged.end(); ++it) |
| 158 | { |
| 159 | std::vector<Adduct> new_adducts; |
| 160 | //create new compomers |
| 161 | Int i = 1; |
| 162 | //warning: the following code assumes that max_nq == max_pq!! |
| 163 | while (abs(i * it->getCharge()) <= max_pq) |
| 164 | { |
| 165 | Adduct a(*it); |
| 166 | // positive amount |
| 167 | a.setAmount(i); |
| 168 | // this might not be a valid compomer (e.g. due to net_charge excess) |
| 169 | // ... but when combined with other adducts it might become feasible again |
| 170 | new_adducts.push_back(a); |
| 171 | ++i; |
| 172 | } |
| 173 | |
| 174 | // combine all new compomers with existing compomers |
| 175 | std::vector<Adduct>::const_iterator new_it; |
| 176 | std::vector<Adduct>::const_iterator new_begin = new_adducts.begin(); |
| 177 | std::vector<Adduct>::const_iterator new_end = new_adducts.end(); |
| 178 | |
| 179 | std::size_t idx_last = explanations_.size(); |
| 180 | for (size_t ci = 0; ci < idx_last; ++ci) |
| 181 | { |
| 182 | for (new_it = new_begin; new_it != new_end; ++new_it) |
| 183 | { |
| 184 | Compomer cmpl(explanations_[ci]); |
| 185 | cmpl.add(*new_it, Compomer::LEFT); |
| 186 | explanations_.push_back(cmpl); |
| 187 | |
| 188 | Compomer cmpr(explanations_[ci]); |
| 189 | cmpr.add(*new_it, Compomer::RIGHT); |
| 190 | explanations_.push_back(cmpr); |
| 191 | } |
| 192 | } |