ionFinder/src/ms2Spectrum.cpp
void ms2::Spectrum::setMZRange(double minMZ, double maxMZ, bool _sort)
{
    //sort ions by mz
    if(_sort)
        sort(_dataPoints.begin(), _dataPoints.end(), DataPoint::MZComparison());

    auto begin = _dataPoints.begin();
    auto end = _dataPoints.end();

    //find min mz
    for(auto it = _dataPoints.begin(); it != _dataPoints.end(); ++it)
    {
        if(it->getMZ() <= minMZ)
        {
            begin = it;
            continue;
        }
        else break;
    }
    //find max mz
    for(auto it = begin; it != _dataPoints.end(); ++it)
    {
        if(it->getMZ() < maxMZ)
        {
            end = it;
            continue;
        }
        else break;
    }

    _dataPoints = ionVecType(begin, end);
    updateRanges();
}
/**
 * Set mz range in spectra. Ions below \p minMZ and above \p maxInt will be removed.
 * \param minMZ
 * \param maxMZ
 * \param _sort Should ions be sorted before filtering? This option should be set to true
 * if ions are not already in order.
 */
Set mz range in spectra. Ions below \p minMZ and above \p maxInt will be removed.
\param minMZ
\param maxMZ
\param _sort Should ions be sorted before filtering. This option should be set to true
if ions are not already in order.
Set mz range in spectra . Ions below \ p minMZ and above \ p maxInt will be removed . \ param minMZ \ param maxMZ \ param _sort Should ions be sorted before filtering . This option should be set to true if ions are not already in order .
void ms2::Spectrum::setMZRange(double minMZ, double maxMZ, bool _sort)
{
    if(_sort)
        sort(_dataPoints.begin(), _dataPoints.end(), DataPoint::MZComparison());
    auto begin = _dataPoints.begin();
    auto end = _dataPoints.end();
    for(auto it = _dataPoints.begin(); it != _dataPoints.end(); ++it)
    {
        if(it->getMZ() <= minMZ)
        {
            begin = it;
            continue;
        }
        else break;
    }
    for(auto it = begin; it != _dataPoints.end(); ++it)
    {
        if(it->getMZ() < maxMZ)
        {
            end = it;
            continue;
        }
        else break;
    }
    _dataPoints = ionVecType(begin, end);
    updateRanges();
}
void ms2 :: Spectrum :: setMZRange ( double minMZ , double maxMZ , bool _sort ) { if ( _sort ) sort ( _dataPoints . begin ( ) , _dataPoints . end ( ) , DataPoint :: MZComparison ( ) ) ; auto begin = _dataPoints . begin ( ) ; auto end = _dataPoints . end ( ) ; for ( auto it = _dataPoints . begin ( ) ; it != _dataPoints . end ( ) ; ++ it ) { if ( it -> getMZ ( ) <= minMZ ) { begin = it ; continue ; } else break ; } for ( auto it = begin ; it != _dataPoints . end ( ) ; ++ it ) { if ( it -> getMZ ( ) < maxMZ ) { end = it ; continue ; } else break ; } _dataPoints = ionVecType ( begin , end ) ; updateRanges ( ) ; }
Set mz range in spectra.
Set mz range in spectra .
//sort ions by mz //find min mz //find max mz