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


C++ Allele::get_seq方法代码示例

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


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

示例1: mutate

void PopState::mutate(Mutation m, int tot) {
   int pos = scape->rng->uniform_int(0, tot);
   pair<Allele *, int> res = find_mutation_allele_and_position(pos);
   Allele *a = res.first;
   int x = res.second;
   int len;
   Sequence seq(a->get_seq());
   string type;

   /* do mutation type-specific stuff */
   switch (m) {
      case point:{
         type = "point";
         len = 1;
         char replacement = scape->pick_mutation(seq.code(x));
         seq.replace(x, replacement);
         break;
      }
      case deletion: {
         len = (int)scape->rng->rnb(deletion_neg_bin_n, deletion_neg_bin_p);
         type =  "deletion";

         /* throw out mutations that go beyond the end of the sequence or are 
          * zero length */
         if (x+len > (int)seq.length() || len == 0) return; 

         seq.delete_part(x, len);
         break;
      }
      case duplication: {
         len = (int)scape->rng->rnb(duplication_neg_bin_n, 
            duplication_neg_bin_p);
         type = "duplication";

         /* throw out mutations that go beyond the end of the sequence or are 
          * zero length */
         if (x+len > (int)seq.length() || len == 0) return; 

         seq.duplicate_part(x, len);
         break;
      }
      default:
         throw SimError("invalid mutation type");
   }

   /* see if the allele already exists */
   AlleleList::iterator i = alleles.find(seq);
   bool isnew = false;
   if (i == alleles.end()) {
      alleles[seq] = new Allele(seq, 1, generation, scape);
      alleles[seq]->mutations = a->mutations+1;
      isnew = true;
   } else {
      i->second->copies++;
   }

   /* see if we should print mutation information */
   if (real_time_flags[string("mutational_effects")]) {
      Sequence bg = a->get_seq();
      string from, to;
      from = bg.subseq(from, x, len);
      switch (m) {
         case point:
            to = seq.subseq(to, x, len);
            break;
         case deletion: 
            to.clear();
            break;
         case duplication: 
            to = bg.subseq(to, x, len);
            to = to + to;
            break;
         default:
            throw SimError("invalid mutation type");
      }
      cout << "gen: " << generation << " pstat_mutational_effects: " 
         << "background: " << bg 
         << " old_id: " << a->allele_id 
         << " new_id: " << alleles[seq]->allele_id
         << " copies: " << a->copies 
         << " type: " << type
         << " site: " << x
         << " len: " << len
         << " from: '" << from << "'"
         << " to: '" << to << "'"
         << " bfit: " << a->fitness
         << " mfit: " << alleles[seq]->fitness
         << " new: " << seq
         << " isnew: " << isnew
         << endl;
   }

   if (a->copies <= 0) throw SimError("too few alleles");
   if (a->copies == 1) {
      AlleleList::iterator k = alleles.find(a->get_seq());
      if (k == alleles.end()) throw SimError("where did the allele go?");
      if (real_time_flags[string("allele_loss")]) {
         cout << "gen: " << generation << " pstat_allele_loss: " 
            << k->second->allele_id << endl;
      }
//.........这里部分代码省略.........
开发者ID:kbullaughey,项目名称:rescape,代码行数:101,代码来源:popsim.cpp


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