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


C++ PeakMap::addSpectrum方法代码示例

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


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

示例1: run

  void MassTraceDetection::run(PeakMap::ConstAreaIterator& begin,
                               PeakMap::ConstAreaIterator& end,
                               std::vector<MassTrace>& found_masstraces)
  {
    PeakMap map;
    MSSpectrum<Peak1D> current_spectrum;

    if (begin == end)
    {
      return;
    }

    for (; begin != end; ++begin)
    {
      // AreaIterator points on novel spectrum?
      if (begin.getRT() != current_spectrum.getRT())
      {
        // save new spectrum in map
        if (current_spectrum.getRT() != -1)
        {
          map.addSpectrum(current_spectrum);
        }
        current_spectrum.clear(false);
        current_spectrum.setRT(begin.getRT());
      }
      current_spectrum.push_back(*begin);
    }
    map.addSpectrum(current_spectrum);

    run(map, found_masstraces);
  }
开发者ID:burlab,项目名称:OpenMS,代码行数:31,代码来源:MassTraceDetection.cpp

示例2: getSwathFile

void getSwathFile(PeakMap& exp, int nr_swathes=32, bool ms1=true)
{
  if (ms1)
  {
    MSSpectrum s;
    s.setMSLevel(1);
    Peak1D p; p.setMZ(100); p.setIntensity(200);
    s.push_back(p);
    exp.addSpectrum(s);
  }
  for (int i = 0; i< nr_swathes; i++)
  {
    MSSpectrum s;
    s.setMSLevel(2);
    std::vector<Precursor> prec(1);
    prec[0].setIsolationWindowLowerOffset(12.5);
    prec[0].setIsolationWindowUpperOffset(12.5);
    prec[0].setMZ(400 + i*25 + 12.5);
    s.setPrecursors(prec);
    Peak1D p; p.setMZ(101 + i); p.setIntensity(201 + i);
    s.push_back(p);
    exp.addSpectrum(s);
  }
}
开发者ID:grosenberger,项目名称:OpenMS,代码行数:24,代码来源:SwathFileConsumer_test.cpp

示例3: addSearchFile

  bool IDEvaluationBase::addSearchFile(const String& file_name)
  {
    MSSpectrum<> points;
    if (!loadCurve(file_name, points)) return false;

    data_.addSpectrum(points);

    PeakMap* exp = new PeakMap();
    exp->addSpectrum(points);
    spec_1d_->canvas()->addLayer(SpectrumCanvas::ExperimentSharedPtrType(exp));
    spec_1d_->canvas()->setLayerName(spec_1d_->canvas()->getLayerCount() - 1, points.getMetaValue("search_engine"));
    // set intensity mode (after spectrum has been added!)
    setIntensityMode((int) SpectrumCanvas::IM_SNAP);

    return true;
  }
开发者ID:burlab,项目名称:OpenMS,代码行数:16,代码来源:IDEvaluationBase.cpp

示例4: correctToNearestFeature


//.........这里部分代码省略.........
        {
          if (!compatible_(features[*sit], pc_mz, mz_tolerance_da, max_trace))
          {
            it->second.erase(sit++);
          }
          else
          {
            ++sit;
          }
        }
      }

      // remove entries with no compatible features (empty sets).
      // Note: This is the "delete while iterating" pattern so mind the pre- and postincrement
      for (map<Size, set<Size> >::iterator it = scan_idx_to_feature_idx.begin(); it != scan_idx_to_feature_idx.end(); )
      {
        if (it->second.empty())
        {
          scan_idx_to_feature_idx.erase(it++);
        }
        else
        {
          ++it;
        }
      }

      if (debug_level_ > 0)
      {
        LOG_INFO << "Number of precursors with compatible features: " << scan_idx_to_feature_idx.size() << endl;
      }

      if (!all_matching_features)
      {
        // keep only nearest features in set
        for (map<Size, set<Size> >::iterator it = scan_idx_to_feature_idx.begin(); it != scan_idx_to_feature_idx.end(); ++it)
        {
          const Size scan = it->first;
          const double pc_rt = exp[scan].getRT();

          double min_distance = 1e16;
          set<Size>::iterator best_feature = it->second.begin();

          // determine nearest/best feature
          for (set<Size>::iterator sit = it->second.begin(); sit != it->second.end(); ++sit)
          {
            const double current_distance = fabs(pc_rt - features[*sit].getRT());
            if (current_distance < min_distance)
            {
              min_distance = current_distance;
              best_feature = sit;
            }
          }

          // delete all except the nearest/best feature
          // Note: This is the "delete while iterating" pattern so mind the pre- and postincrement
          for (set<Size>::iterator sit = it->second.begin(); sit != it->second.end(); )
          {
            if (sit != best_feature)
            {
              it->second.erase(sit++);
            }
            else
            {
              ++sit;
            }
          }
        }
      }

      // depending on all_matching_features option, only the nearest or all features are contained in the sets
      // depending on options: move/copy corrected precursor and tandem spectrum
      if (keep_original)
      {
        // duplicate spectra for each feature in set and adapt precursor_mz and precursor_charge to feature_mz and feature_charge
        for (map<Size, set<Size> >::iterator it = scan_idx_to_feature_idx.begin(); it != scan_idx_to_feature_idx.end(); ++it)
        {
          const Size scan = it->first;
          MSSpectrum<> spectrum = exp[scan];
          corrected_precursors.insert(scan);
          for (set<Size>::iterator f_it = it->second.begin(); f_it != it->second.end(); ++f_it)
          {
            spectrum.getPrecursors()[0].setMZ(features[*f_it].getMZ());
            spectrum.getPrecursors()[0].setCharge(features[*f_it].getCharge());
            exp.addSpectrum(spectrum);
          }
        }
      }
      else
      {
        // set precursor_mz and _charge to the feature_mz and _charge
        for (map<Size, set<Size> >::iterator it = scan_idx_to_feature_idx.begin(); it != scan_idx_to_feature_idx.end(); ++it)
        {
          const Size scan = it->first;
          exp[scan].getPrecursors()[0].setMZ(features[*it->second.begin()].getMZ());
          exp[scan].getPrecursors()[0].setCharge(features[*it->second.begin()].getCharge());
          corrected_precursors.insert(scan);
        }
      }
      return corrected_precursors;
    }
开发者ID:chahuistle,项目名称:OpenMS,代码行数:101,代码来源:HighResPrecursorMassCorrector.cpp


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