本文整理汇总了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;
}
//.........这里部分代码省略.........