本文整理汇总了C++中LineBuffer::position方法的典型用法代码示例。如果您正苦于以下问题:C++ LineBuffer::position方法的具体用法?C++ LineBuffer::position怎么用?C++ LineBuffer::position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LineBuffer
的用法示例。
在下文中一共展示了LineBuffer::position方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
static int process(VDB::Writer const &out, LineBuffer &ifs)
{
auto active = std::vector<ContigPair>();
auto ref = decltype(active.front().first.ref)(0); ///< the active reference (first read)
auto end = decltype(active.front().first.end)(0); ///< the largest ending position (first read) seen so far; the is the end of the active window
unsigned long long in_count = 0;
unsigned long long out_count = 0;
unsigned long long gapless_count = 0;
auto time0 = time(nullptr);
auto freq = 0.1;
auto report = freq;
for ( ; ; ) {
auto pair = ContigPair(ifs);
auto const isEOF = pair.count == 0;
if ((!active.empty() && (pair.first.ref != ref || pair.first.start >= end)) || isEOF) {
// new pair is outside the active window (or EOF);
// output the active contig pairs and empty the window
for (auto && i : active) {
if (i.first.ref == i.second.ref && i.second.start < i.first.end) {
// the region is gapless, i.e. the mate-pair gap has been filled in
i.first.end = i.second.start = 0;
}
}
for (auto i = decltype(active.size())(0); i < active.size(); ++i) {
if (active[i].first.end != 0 || active[i].second.end != 0) continue;
// active[i] is gapless
auto const group = active[i].group;
auto start = active[i].first.start;
auto end = active[i].second.end;
AGAIN:
for (auto j = decltype(i)(0); j < active.size(); ++j) {
if (j == i) continue;
auto const &J = active[j];
if (J.group != group || J.second.ref != ref || J.first.start >= end || J.second.end <= start) continue;
// active[j] overlaps active[i]
if ((J.first.end == 0 && J.second.start == 0) ///< active[j] is also gapless
|| (start < J.first.end && J.second.start < end)) ///< or active[i] covers active[j]'s gap
{
start = std::min(start, J.first.start);
end = std::max(end, J.second.end);
active[i].first.start = start;
active[i].second.end = end;
active[i].count += J.count;
if (j < i)
--i;
active.erase(active.begin() + j);
goto AGAIN;
}
}
}
std::sort(active.begin(), active.end(), ///< want order to be canonical; should be mostly in-order already
[](ContigPair const &a, ContigPair const &b) {
if (a.first.start < b.first.start) return true;
if (a.first.start > b.first.start) return false;
if (a.first.end == 0 && a.second.start == 0) {
if (b.first.end == 0 && b.second.start == 0) {
if (a.second.end < b.second.end) return false; ///< longer one goes first
if (a.second.end > b.second.end) return true;
}
else if (a.second.ref == b.second.ref) {
return true; ///< gapless one goes first
}
else {
return a.second.ref < b.second.ref;
}
}
else if (b.first.end == 0 && b.second.start == 0) {
if (a.second.ref == b.second.ref) {
return false; ///< gapless one goes first
}
else {
return a.second.ref < b.second.ref;
}
}
else {
// both have a gap
if (a.first.end < b.first.end) return true;
if (a.first.end > b.first.end) return false;
if (a.second.ref < b.second.ref) return true;
if (a.second.ref > b.second.ref) return false;
if (a.second.start < b.second.start) return true;
if (a.second.start > b.second.start) return false;
if (a.second.end < b.second.end) return true;
if (a.second.end > b.second.end) return false;
}
return a.group < b.group;
});
for (auto && i : active) {
if (i.second.start == 0 && i.first.end == 0)
++gapless_count;
i.write(out);
++out_count;
}
//.........这里部分代码省略.........