本文整理汇总了C++中ContigPaths::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ContigPaths::empty方法的具体用法?C++ ContigPaths::empty怎么用?C++ ContigPaths::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContigPaths
的用法示例。
在下文中一共展示了ContigPaths::empty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: constructAmbiguousPath
/** Return an ambiguous path that agrees with all the given paths. */
static ContigPath constructAmbiguousPath(const Graph &g,
const ContigNode& origin, const ContigPaths& paths)
{
assert(!paths.empty());
// Find the size of the smallest path.
const ContigPath& firstSol = paths.front();
size_t min_len = firstSol.size();
for (ContigPaths::const_iterator it = paths.begin() + 1;
it != paths.end(); ++it)
min_len = min(min_len, it->size());
// Find the longest prefix.
ContigPath vppath;
size_t longestPrefix;
bool commonPrefix = true;
for (longestPrefix = 0;
longestPrefix < min_len; longestPrefix++) {
const ContigNode& common_path_node = firstSol[longestPrefix];
for (ContigPaths::const_iterator solIter = paths.begin();
solIter != paths.end(); ++solIter) {
const ContigNode& pathnode = (*solIter)[longestPrefix];
if (pathnode != common_path_node) {
// Found the longest prefix.
commonPrefix = false;
break;
}
}
if (!commonPrefix)
break;
vppath.push_back(common_path_node);
}
// Find the longest suffix.
ContigPath vspath;
size_t longestSuffix;
bool commonSuffix = true;
for (longestSuffix = 0;
longestSuffix < min_len-longestPrefix; longestSuffix++) {
const ContigNode& common_path_node
= firstSol[firstSol.size()-longestSuffix-1];
for (ContigPaths::const_iterator solIter = paths.begin();
solIter != paths.end(); ++solIter) {
const ContigNode& pathnode
= (*solIter)[solIter->size()-longestSuffix-1];
if (pathnode != common_path_node) {
// Found the longest suffix.
commonSuffix = false;
break;
}
}
if (!commonSuffix)
break;
vspath.push_back(common_path_node);
}
ContigPath out;
out.reserve(vppath.size() + 1 + vspath.size());
out.insert(out.end(), vppath.begin(), vppath.end());
if (longestSuffix > 0) {
const ContigPath& longestPath(
*max_element(paths.begin(), paths.end(),
ComparePathLength(g, origin)));
unsigned length = calculatePathLength(g, origin, longestPath,
longestPrefix, longestSuffix);
// Account for the overlap on the right.
int dist = length + getDistance(g,
longestSuffix == longestPath.size() ? origin
: *(longestPath.rbegin() + longestSuffix),
*(longestPath.rbegin() + longestSuffix - 1));
// Add k-1 because it is the convention.
int numN = dist + opt::k - 1;
assert(numN > 0);
out.push_back(ContigNode(numN, 'N'));
out.insert(out.end(), vspath.rbegin(), vspath.rend());
}
return out;
}
示例2: handleEstimate
/** Find a path for the specified distance estimates.
* @param out [out] the solution path
*/
static void handleEstimate(const Graph& g,
const EstimateRecord& er, bool dirIdx,
ContigPath& out)
{
if (er.estimates[dirIdx].empty())
return;
ContigNode origin(er.refID, dirIdx);
ostringstream vout_ss;
ostream bitBucket(NULL);
ostream& vout = opt::verbose > 0 ? vout_ss : bitBucket;
vout << "\n* " << get(vertex_name, g, origin) << '\n';
unsigned minNumPairs = UINT_MAX;
// generate the reachable set
Constraints constraints;
for (Estimates::const_iterator iter
= er.estimates[dirIdx].begin();
iter != er.estimates[dirIdx].end(); ++iter) {
ContigNode v = iter->first;
const DistanceEst& ep = iter->second;
minNumPairs = min(minNumPairs, ep.numPairs);
constraints.push_back(Constraint(v,
ep.distance + allowedError(ep.stdDev)));
}
vout << "Constraints:";
printConstraints(vout, g, constraints) << '\n';
ContigPaths solutions;
unsigned numVisited = 0;
constrainedSearch(g, origin, constraints, solutions, numVisited);
bool tooComplex = numVisited >= opt::maxCost;
bool tooManySolutions = solutions.size() > opt::maxPaths;
set<ContigID> repeats = findRepeats(er.refID, solutions);
if (!repeats.empty()) {
vout << "Repeats:";
for (set<ContigID>::const_iterator it = repeats.begin();
it != repeats.end(); ++it)
vout << ' ' << get(g_contigNames, *it);
vout << '\n';
}
unsigned numPossiblePaths = solutions.size();
if (numPossiblePaths > 0)
vout << "Paths: " << numPossiblePaths << '\n';
for (ContigPaths::iterator solIter = solutions.begin();
solIter != solutions.end();) {
vout << *solIter << '\n';
// Calculate the path distance to each node and see if
// it is within the estimated distance.
map<ContigNode, int> distanceMap
= makeDistanceMap(g, origin, *solIter);
// Remove solutions whose distance estimates are not correct.
unsigned validCount = 0, invalidCount = 0, ignoredCount = 0;
for (Estimates::const_iterator iter
= er.estimates[dirIdx].begin();
iter != er.estimates[dirIdx].end(); ++iter) {
ContigNode v = iter->first;
const DistanceEst& ep = iter->second;
vout << get(vertex_name, g, v) << ',' << ep << '\t';
map<ContigNode, int>::iterator dmIter
= distanceMap.find(v);
if (dmIter == distanceMap.end()) {
// This contig is a repeat.
ignoredCount++;
vout << "ignored\n";
continue;
}
// translate distance by -overlap to match
// coordinate space used by the estimate
int actualDistance = dmIter->second;
int diff = actualDistance - ep.distance;
unsigned buffer = allowedError(ep.stdDev);
bool invalid = (unsigned)abs(diff) > buffer;
bool repeat = repeats.count(v.contigIndex()) > 0;
bool ignored = invalid && repeat;
if (ignored)
ignoredCount++;
else if (invalid)
invalidCount++;
else
validCount++;
vout << "dist: " << actualDistance
<< " diff: " << diff
<< " buffer: " << buffer
<< " n: " << ep.numPairs
<< (ignored ? " ignored" : invalid ? " invalid" : "")
<< '\n';
}
//.........这里部分代码省略.........
示例3: fillGap
/** Return the consensus sequence of the specified gap. */
static ContigPath fillGap(const Graph& g,
const AmbPathConstraint& apConstraint,
vector<bool>& seen,
ofstream& outFasta)
{
if (opt::verbose > 1)
cerr << "\n* "
<< get(vertex_name, g, apConstraint.source) << ' '
<< apConstraint.dist << "N "
<< get(vertex_name, g, apConstraint.dest) << '\n';
Constraints constraints;
constraints.push_back(Constraint(apConstraint.dest,
apConstraint.dist + opt::distanceError));
ContigPaths solutions;
unsigned numVisited = 0;
constrainedSearch(g, apConstraint.source,
constraints, solutions, numVisited);
bool tooComplex = numVisited >= opt::maxCost;
for (ContigPaths::iterator solIt = solutions.begin();
solIt != solutions.end(); solIt++)
solIt->insert(solIt->begin(), apConstraint.source);
ContigPath consensus;
bool tooManySolutions = solutions.size() > opt::numBranches;
if (tooComplex) {
stats.tooComplex++;
if (opt::verbose > 1)
cerr << solutions.size() << " paths (too complex)\n";
} else if (tooManySolutions) {
stats.numTooManySolutions++;
if (opt::verbose > 1)
cerr << solutions.size() << " paths (too many)\n";
} else if (solutions.empty()) {
stats.numNoSolutions++;
if (opt::verbose > 1)
cerr << "no paths\n";
} else if (solutions.size() == 1) {
if (opt::verbose > 1)
cerr << "1 path\n" << solutions.front() << '\n';
stats.numMerged++;
} else {
assert(solutions.size() > 1);
if (opt::verbose > 2)
copy(solutions.begin(), solutions.end(),
ostream_iterator<ContigPath>(cerr, "\n"));
else if (opt::verbose > 1)
cerr << solutions.size() << " paths\n";
consensus = align(g, solutions, outFasta);
if (!consensus.empty()) {
stats.numMerged++;
// Mark contigs that are used in a consensus.
markSeen(seen, solutions, true);
if (opt::verbose > 1)
cerr << consensus << '\n';
} else
stats.notMerged++;
}
return consensus;
}