当前位置: 首页>>代码示例>>C++>>正文


C++ SpectrumPtr::setMZIntensityPairs方法代码示例

本文整理汇总了C++中SpectrumPtr::setMZIntensityPairs方法的典型用法代码示例。如果您正苦于以下问题:C++ SpectrumPtr::setMZIntensityPairs方法的具体用法?C++ SpectrumPtr::setMZIntensityPairs怎么用?C++ SpectrumPtr::setMZIntensityPairs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpectrumPtr的用法示例。


在下文中一共展示了SpectrumPtr::setMZIntensityPairs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: operator


//.........这里部分代码省略.........
            // no need to check bounds on thresholdItr because it gets checked above
            thresholdItr = mzIntensityPairs.begin() + ((size_t) threshold)-1;

            // iterate forward until a non-tie is found
            while (true)
            {
                const double& i = thresholdItr->intensity;
                if (++thresholdItr == mzIntensityPairs.end() ||
                    i != thresholdItr->intensity)
                    break;
            }
            break;

        case ThresholdingBy_AbsoluteIntensity:
            if (orientation == Orientation_MostIntense)
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                                           mzIntensityPairs.end(),
                                           MZIntensityPair(0, threshold),
                                           orientationMore_Predicate);
            else
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                                           mzIntensityPairs.end(),
                                           MZIntensityPair(0, threshold),
                                           orientationLess_Predicate);
            break;

        case ThresholdingBy_FractionOfBasePeakIntensity:
            if (orientation == Orientation_MostIntense)
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                                           mzIntensityPairs.end(),
                                           MZIntensityPair(0, threshold*bpi),
                                           MZIntensityPairIntensityFractionGreaterThan(bpi));
            else
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                                           mzIntensityPairs.end(),
                                           MZIntensityPair(0, threshold*bpi),
                                           MZIntensityPairIntensityFractionLessThan(bpi));
            break;

        case ThresholdingBy_FractionOfTotalIntensity:
            if (orientation == Orientation_MostIntense)
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                mzIntensityPairs.end(),
                MZIntensityPair(0, threshold*tic),
                MZIntensityPairIntensityFractionGreaterThan(tic));
            else
                thresholdItr = lower_bound(mzIntensityPairs.begin(),
                mzIntensityPairs.end(),
                MZIntensityPair(0, threshold*tic),
                MZIntensityPairIntensityFractionLessThan(tic));
            break;

        case ThresholdingBy_FractionOfTotalIntensityCutoff:
        {
            // example (ties are included)
            // intensities:     12  2   2   1   1   1   1   0   0  (TIC 20)
            // cumulative:      12  14  16  17  18  19  20  20  20
            // fraction:        .60 .70 .80 .85 .90 .95 1.0 1.0 1.0
            // at threshold 1.0 ---------------------------^ cut here
            // at threshold .99 ---------------------------^ cut here
            // at threshold .90 ---------------------------^ cut here
            // at threshold .80 -----------^ cut here
            // at threshold .65 -----------^ cut here
            // at threshold .60 ---^ cut here
            // at threshold .15 ---^ cut here

            // starting at the (most/least intense point)/TIC fraction, calculate the running sum
            vector<double> cumulativeIntensityFraction;
            cumulativeIntensityFraction.reserve(mzIntensityPairs.size());
            cumulativeIntensityFraction.push_back(mzIntensityPairs[0].intensity / tic);
            size_t i=1;
            while (cumulativeIntensityFraction.back() < threshold - 1e-6 &&
                   i < mzIntensityPairs.size())
            {
                cumulativeIntensityFraction.push_back(cumulativeIntensityFraction[i-1] +
                                                      mzIntensityPairs[i].intensity / tic);
                ++i;
            }

            thresholdItr = mzIntensityPairs.begin() + (i-1);

            // iterate forward until a non-tie is found
            while (thresholdItr != mzIntensityPairs.end())
            {
                const double& i = thresholdItr->intensity;
                if (++thresholdItr == mzIntensityPairs.end() ||
                    i != thresholdItr->intensity)
                    break;
            }
        }
        break;

        default:
            throw runtime_error("[threshold()] invalid thresholding type");
    }

    sort(mzIntensityPairs.begin(), thresholdItr, MZIntensityPairSortByMZ());
    s->setMZIntensityPairs(&mzIntensityPairs[0], thresholdItr - mzIntensityPairs.begin(),
        s->getIntensityArray()->cvParam(MS_intensity_array).units);
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:101,代码来源:ThresholdFilter.cpp


注:本文中的SpectrumPtr::setMZIntensityPairs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。