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


C++ StringView::getString方法代码示例

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


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

示例1: digestUnmodifiedString

  void EnzymaticDigestion::digestUnmodifiedString(const StringView sequence, std::vector<StringView>& output, Size min_length, Size max_length) const
  {
    // initialization
    output.clear();

    // naive cleavage sites
    std::vector<Size> pep_positions = tokenize_(sequence.getString());
    Size count = pep_positions.size();

    // disable max length filter by setting to maximum length
    if (max_length == 0)
    {
      max_length = sequence.size();
    }

    // no cleavage sites? return full string
    if (count == 0) 
    {
      if (sequence.size() >= min_length && sequence.size() <= max_length)
      {
        output.push_back(sequence);
      }
      return;
    }

    for (Size i = 1; i != count; ++i)
    {
      // add if cleavage product larger then min length
      Size l = pep_positions[i] - pep_positions[i - 1];
      if (l >= min_length && l <= max_length)
      {
        output.push_back(sequence.substr(pep_positions[i - 1], pep_positions[i] - 1));
      }
    }

    // add last cleavage product (need to add because end is not a cleavage site) if larger then min length
    Size l = sequence.size() - pep_positions[count - 1];
    if (l >= min_length && l <= max_length)
    {
      output.push_back(sequence.substr(pep_positions[count - 1], sequence.size() - 1));
    }

    // generate fragments with missed cleavages
    for (Size i = 1; ((i <= missed_cleavages_) && (i < count)); ++i)
    {
      for (Size j = 1; j < count - i; ++j)
      {
        Size l = pep_positions[j + i] - pep_positions[j - 1];
        if (l >= min_length && l <= max_length)
        {
          output.push_back(sequence.substr(pep_positions[j - 1], pep_positions[j + i] - 1));
        }
      }

      // add last cleavage product (need to add because end is not a cleavage site)
      Size l = sequence.size() - pep_positions[count - i - 1];
      if (l >= min_length && l <= max_length)
      {
        output.push_back(sequence.substr(pep_positions[count - i - 1], sequence.size() - 1 ));
      }
    }
  }
开发者ID:hroest,项目名称:OpenMS,代码行数:62,代码来源:EnzymaticDigestion.cpp


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