MSSpectrum::Iterator MSSpectrum::MZEnd(MSSpectrum::Iterator begin, MSSpectrum::CoordinateType mz, MSSpectrum::Iterator end) { PeakType p; p.setPosition(mz); return upper_bound(begin, end, p, PeakType::PositionLess()); }
MSSpectrum::ConstIterator MSSpectrum::MZBegin(MSSpectrum::ConstIterator begin, MSSpectrum::CoordinateType mz, MSSpectrum::ConstIterator end) const { PeakType p; p.setPosition(mz); return lower_bound(begin, end, p, PeakType::PositionLess()); }
PeakType fillPeak(double rt, double mz, double it) { PeakType p; p.setIntensity((OpenMS::Peak2D::IntensityType)it); p.setMZ(mz); p.setRT((rt)); return p; }
void updateWeightedSDEstimate(PeakType p, const double& mean_t1, double& sd_t, double& last_weights_sum) { double denom = last_weights_sum * sd_t * sd_t + p.getIntensity() * (p.getMZ() - mean_t1) * (p.getMZ() - mean_t1); double weights_sum = last_weights_sum + p.getIntensity(); double tmp_sd = std::sqrt(denom / weights_sum); if (tmp_sd > std::numeric_limits<double>::epsilon()) { sd_t = tmp_sd; } last_weights_sum = weights_sum; }
void updateWeightedSDEstimateRobust(PeakType p, const double& mean_t1, double& sd_t, double& last_weights_sum) { double denom1 = std::log(last_weights_sum) + 2 * std::log(sd_t); double denom2 = std::log(p.getIntensity()) + 2 * std::log(std::abs(p.getMZ() - mean_t1)); double denom = std::sqrt(std::exp(denom1) + std::exp(denom2)); double weights_sum = last_weights_sum + p.getIntensity(); double tmp_sd = denom / std::sqrt(weights_sum); if (tmp_sd > std::numeric_limits<double>::epsilon()) { sd_t = tmp_sd; } last_weights_sum = weights_sum; }
MSSpectrum<FeatureFinderAlgorithmIsotopeWavelet::PeakType>* FeatureFinderAlgorithmIsotopeWavelet::createHRData(const UInt i) { MSSpectrum<PeakType> spec((*this->map_)[i]); const MSSpectrum<PeakType>& specr((*this->map_)[i]); for (UInt j = 0; j < spec.size() - 1; ++j) { spec[j].setMZ(-1 * (specr[j + 1].getMZ() - specr[j].getMZ())); spec[j].setIntensity((specr[j].getIntensity() + specr[j + 1].getIntensity())); } spec[spec.size() - 1].setMZ(-1); spec[spec.size() - 1].setIntensity(-1); ConstRefVector<MSSpectrum<PeakType> > c_sorted_spec(spec.begin(), spec.end()); //Sort in ascending order according to the intensities present in the transform c_sorted_spec.sortByPosition(); #ifdef OPENMS_DEBUG_ISOTOPE_WAVELET std::ofstream ofilex("spacings.trans"); for (UInt j = 0; j < spec.size() - 1; ++j) { ofilex << ::std::setprecision(12) << std::fixed << spec[j].getMZ() << "\t" << spec[j].getIntensity() << std::endl; } ofilex.close(); #endif UInt pos = 0; while (c_sorted_spec[pos].getIntensity() <= 0) { if (++pos >= c_sorted_spec.size()) { std::cout << "Detected empty scan or a scan that cannot be interpolated with zeros in HR mode. " << std::endl; std::cout << "Please check scan # " << i << " of your data set." << std::endl; exit(-1); } } double bound = -1 * c_sorted_spec[pos].getMZ(); if (bound > (1. / max_charge_) / 2.) { //that might be case for simulated spectra, //which might show a very artificial spacing bound = (1. / max_charge_) / 2. / 4.; } MSSpectrum<PeakType>* new_spec = new MSSpectrum<PeakType>; new_spec->reserve(200000); new_spec->setRT(((*this->map_)[i]).getRT()); PeakType p; p.setMZ(specr[0].getMZ()); p.setIntensity(specr[0].getIntensity()); new_spec->push_back(p); UInt count; for (UInt j = 0; j < spec.size() - 1; ++j) { count = 0; while (-spec[j].getMZ() - count * bound > bound) { ++count; p.setMZ(specr[j].getMZ() + count * bound); p.setIntensity(0); new_spec->push_back(p); } p.setMZ(specr[j + 1].getMZ()); p.setIntensity(specr[j + 1].getIntensity()); new_spec->push_back(p); } #ifdef OPENMS_DEBUG_ISOTOPE_WAVELET std::ofstream ofiley("new_spec.trans"); for (UInt j = 0; j < new_spec->size(); ++j) { ofiley << ::std::setprecision(12) << std::fixed << (*new_spec)[j].getMZ() << "\t" << (*new_spec)[j].getIntensity() << std::endl; } ofiley.close(); #endif return new_spec; }
void TOFPeakTest<PeakType>::testGetSetTOF() { PeakType peak; peak.setTOF(23.42); CPPUNIT_ASSERT_EQUAL(23.42, peak.getTOF()); }
void fillIntensity(PeakType& peak) const { peak.setIntensity(getIntensity(peak.getPosition())); }
MSSpectrum::ConstIterator MSSpectrum::MZBegin(MSSpectrum::CoordinateType mz) const { PeakType p; p.setPosition(mz); return lower_bound(ContainerType::begin(), ContainerType::end(), p, PeakType::PositionLess()); }
MSSpectrum::Iterator MSSpectrum::MZEnd(MSSpectrum::CoordinateType mz) { PeakType p; p.setPosition(mz); return upper_bound(ContainerType::begin(), ContainerType::end(), p, PeakType::PositionLess()); }