本文整理汇总了C++中Alignment::SerializeToString方法的典型用法代码示例。如果您正苦于以下问题:C++ Alignment::SerializeToString方法的具体用法?C++ Alignment::SerializeToString怎么用?C++ Alignment::SerializeToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alignment
的用法示例。
在下文中一共展示了Alignment::SerializeToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alignment
// generates a perfect alignment from the graph
Alignment Sampler::alignment(size_t length) {
string seq;
Alignment aln;
Path* path = aln.mutable_path();
pos_t pos = position();
char c = pos_char(pos);
// we do something wildly inefficient but conceptually clean
// for each position in the mapping we add a mapping
// at the end we will simplify the alignment, merging redundant mappings
do {
// add in the char for the current position
seq += c;
Mapping* mapping = path->add_mapping();
*mapping->mutable_position() = make_position(pos);
Edit* edit = mapping->add_edit();
edit->set_from_length(1);
edit->set_to_length(1);
// decide the next position
auto nextc = next_pos_chars(pos);
// no new positions mean we are done; we've reached the end of the graph
if (nextc.empty()) break;
// what positions do we go to next?
vector<pos_t> nextp;
for (auto& n : nextc) nextp.push_back(n.first);
// pick one at random
uniform_int_distribution<int> next_dist(0, nextc.size()-1);
// update our position
pos = nextp.at(next_dist(rng));
// update our char
c = nextc[pos];
} while (seq.size() < length);
// save our sequence in the alignment
aln.set_sequence(seq);
aln = simplify(aln);
{ // name the alignment
string data;
aln.SerializeToString(&data);
int n;
#pragma omp critical(nonce)
n = nonce++;
data += std::to_string(n);
const string hash = sha1head(data, 16);
aln.set_name(hash);
}
// and simplify it
aln.set_identity(identity(aln.path()));
return aln;
}
示例2: hash_alignment
const string hash_alignment(const Alignment& aln) {
string data;
aln.SerializeToString(&data);
return sha1sum(data);
}