Esempio n. 1
0
  void MSSpectrum::sortByIntensity(bool reverse)
  {
    if (float_data_arrays_.empty() && string_data_arrays_.empty() && integer_data_arrays_.empty())
    {
      if (reverse)
      {
        std::stable_sort(ContainerType::begin(), ContainerType::end(), reverseComparator(PeakType::IntensityLess()));
      }
      else
      {
        std::stable_sort(ContainerType::begin(), ContainerType::end(), PeakType::IntensityLess());
      }
    }
    else
    {
      // sort index list
      std::vector<std::pair<PeakType::IntensityType, Size> > sorted_indices;
      sorted_indices.reserve(ContainerType::size());
      for (Size i = 0; i < ContainerType::size(); ++i)
      {
        sorted_indices.push_back(std::make_pair(ContainerType::operator[](i).getIntensity(), i));
      }

      if (reverse)
      {
        std::stable_sort(sorted_indices.begin(), sorted_indices.end(), reverseComparator(PairComparatorFirstElement<std::pair<PeakType::IntensityType, Size> >()));
      }
      else
      {
        std::stable_sort(sorted_indices.begin(), sorted_indices.end(), PairComparatorFirstElement<std::pair<PeakType::IntensityType, Size> >());
      }

      // extract list of indices
      std::vector<Size> select_indices;
      select_indices.reserve(sorted_indices.size());
      for (Size i = 0; i < sorted_indices.size(); ++i)
      {
        select_indices.push_back(sorted_indices[i].second);
      }
      select(select_indices);
    }
  }
Esempio n. 2
0
 void ConsensusMap::sortByQuality(bool reverse)
 {
   if (reverse)
   {
     std::stable_sort(Base::begin(), Base::end(), reverseComparator(ConsensusFeature::QualityLess()));
   }
   else
   {
     std::stable_sort(Base::begin(), Base::end(), ConsensusFeature::QualityLess());
   }
 }
Esempio n. 3
0
 void FeatureMap::sortByOverallQuality(bool reverse)
 {
   if (reverse)
   {
     std::sort(this->begin(), this->end(), reverseComparator(FeatureType::OverallQualityLess()));
   }
   else
   {
     std::sort(this->begin(), this->end(), FeatureType::OverallQualityLess());
   }
 }
Esempio n. 4
0
 void ConsensusMap::sortBySize()
 {
   std::stable_sort(Base::begin(), Base::end(), reverseComparator(ConsensusFeature::SizeLess()));
 }