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


C++ Sequence::at方法代码示例

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


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

示例1: static_distance

unsigned int LevenshteinDistance::static_distance(const Sequence &sequence1, const Sequence &sequence2, const unsigned int cost_sub, const unsigned int cost_indel) {
  size_t n = sequence1.length();
  size_t m = sequence2.length();

  unsigned int distances[n+1][m+1];

  // Distance from empty string to the position
  for (size_t i = 0; i <= n; i++) {
    distances[i][0] = i * cost_indel;
  }
  for (size_t j = 0; j <= m; j++) {
    distances[0][j] = j * cost_indel;
  }

  for (size_t i = 1; i <= n; i++) {
    for (size_t j = 1; j <= m; j++) {
      unsigned int cost = 0;

      if (sequence1.at(i-1) != sequence2.at(j-1)) {
        cost = cost_sub;
      }

      distances[i][j] = std::min(std::min(distances[i-1][j-1] + cost, distances[i][j-1] + cost_indel), distances[i-1][j] + cost_indel);
    }
  }

  unsigned int min_distance = distances[n][m];

  return (min_distance);

}
开发者ID:Bioconductor-mirror,项目名称:DNABarcodes,代码行数:31,代码来源:levenshteindistance.cpp

示例2: getPercentile

double DeterminatorInterpolated::getPercentile(const Sequence &sequence, int percentile) const {
    size_t size = sequence.size();
    double coeff = 100.0 / size;

    double calcIdx = percentile / coeff - .5;

    if (calcIdx <= 0) return sequence.front();
    if (calcIdx >= size - 1) return sequence.back();

    size_t idx0 = (size_t) floor(calcIdx);
    int v0 = sequence.at(idx0);
    int v1 = sequence.at(idx0 + 1);

    double p0 = 100.0 / size * (idx0);

    double slope = size / 100.0 * (percentile - p0);

    return v0 + (v1 - v0) * slope;
}
开发者ID:antifriz,项目名称:ooup,代码行数:19,代码来源:determinator_interpolated.cpp

示例3: is_seq_insertable

bool LevenshteinDistance::is_seq_insertable(const std::vector<Sequence> &seqs, const Sequence &sequence, const size_t n, const unsigned int min_dist) {
  size_t n_elements = seqs.size();

  size_t m = sequence.length();

  unsigned int distances[n+1][m+1];

  for (size_t i = 0; i <= n; i++) {
    distances[i][0] = i * cost_indel_;
  }
  
  for (size_t j = 0; j <= m; j++) {
    distances[0][j] = j * cost_indel_;
  }

  bool seq_is_insertable = true;

  for (size_t seq1_index = 0; seq1_index < n_elements && seq_is_insertable; seq1_index++) {
    Sequence sequence1 = seqs.at(seq1_index);

    for (size_t i = 1; i <= n; i++) {
      for (size_t j = 1; j <= m; j++) {
        unsigned int cost = 0;

        if (sequence1.at(i-1) != sequence.at(j-1)) {
          cost = cost_sub_;
        }

        distances[i][j] = std::min(std::min(distances[i-1][j-1] + cost, distances[i][j-1] + cost_indel_), distances[i-1][j] + cost_indel_);

      }
    }

    unsigned int min_distance  = distances[n][m];

    if (min_distance < min_dist)
      seq_is_insertable = false;
  }

  return seq_is_insertable;

}
开发者ID:Bioconductor-mirror,项目名称:DNABarcodes,代码行数:42,代码来源:levenshteindistance.cpp

示例4: static_min_seq_distance

unsigned int LevenshteinDistance::static_min_seq_distance(const std::vector< Sequence > &seqs, const Sequence &sequence, const size_t n, const unsigned int cost_sub, const unsigned int cost_indel) {

  size_t n_elements = seqs.size();

  size_t m = sequence.length();

  unsigned int global_min_dist = UINT_MAX;
  
  unsigned int distances[n+1][m+1];

  for (size_t i = 0; i <= n; i++) {
    distances[i][0] = i * cost_indel;
  }
  for (size_t j = 0; j <= m; j++) {
    distances[0][j] = j * cost_indel;
  }

  for (size_t seq1_index = 0; seq1_index < n_elements; seq1_index++) {
    Sequence sequence1 = seqs.at(seq1_index);

    for (size_t i = 1; i <= n; i++) {
      for (size_t j = 1; j <= m; j++) {
        unsigned int cost = cost_sub;

        if (sequence1.at(i-1) != sequence.at(j-1)) {
          cost = cost_sub;
        }

        distances[i][j] = std::min(std::min(distances[i-1][j-1] + cost, distances[i][j-1] + cost_indel), distances[i-1][j] + cost_indel);

      }
    }

    unsigned int min_distance  = distances[n][m];

    if (min_distance < global_min_dist)
      global_min_dist = min_distance;

  }

  return(global_min_dist);
}
开发者ID:Bioconductor-mirror,项目名称:DNABarcodes,代码行数:42,代码来源:levenshteindistance.cpp


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