MCPcopy Create free account
hub / github.com/BirolLab/abyss / worker

Function worker

SimpleGraph/SimpleGraph.cpp:670–736  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

668};
669
670static void* worker(void* pArg)
671{
672 WorkerArg& arg = *static_cast<WorkerArg*>(pArg);
673 unsigned countSeedTooShort = 0;
674 unsigned countNoEdges = 0;
675 unsigned countEdgesRemoved = 0;
676 for (;;) {
677 /** Lock the input stream. */
678 static pthread_mutex_t inMutex = PTHREAD_MUTEX_INITIALIZER;
679 pthread_mutex_lock(&inMutex);
680 EstimateRecord er;
681 bool good = bool((*arg.in) >> er);
682 pthread_mutex_unlock(&inMutex);
683 if (!good)
684 break;
685 if ((*arg.graph)[ContigNode(er.refID, false)].length < opt::minSeedLength) {
686 ++countSeedTooShort;
687 continue;
688 }
689
690 // Remove edges with insufficient support.
691 for (unsigned i = 0; i < 2; ++i) {
692 Estimates& estimates = er.estimates[i];
693 if (estimates.empty())
694 continue;
695 unsigned sizeBefore = estimates.size();
696 estimates.erase(
697 remove_if(estimates.begin(), estimates.end(), PoorSupport(opt::minEdgeWeight)),
698 estimates.end());
699 unsigned sizeAfter = estimates.size();
700 unsigned edgesRemoved = sizeBefore - sizeAfter;
701 countEdgesRemoved += edgesRemoved;
702 if (sizeAfter == 0)
703 ++countNoEdges;
704 }
705
706 // Flip the anterior distance estimates.
707 for (Estimates::iterator it = er.estimates[1].begin();
708 it != er.estimates[1].end(); ++it)
709 it->first ^= 1;
710
711 ContigPath path;
712 handleEstimate(*arg.graph, er, true, path);
713 reverseComplement(path.begin(), path.end());
714 path.push_back(ContigNode(er.refID, false));
715 handleEstimate(*arg.graph, er, false, path);
716 if (path.size() > 1) {
717 /** Lock the output stream. */
718 static pthread_mutex_t outMutex
719 = PTHREAD_MUTEX_INITIALIZER;
720 pthread_mutex_lock(&outMutex);
721 *arg.out << get(g_contigNames, er.refID)
722 << '\t' << path << '\n';
723 assert(arg.out->good());
724 pthread_mutex_unlock(&outMutex);
725 }
726 }
727

Callers

nothing calls this directly

Calls 12

ContigNodeClass · 0.85
handleEstimateFunction · 0.85
eraseMethod · 0.80
goodMethod · 0.80
PoorSupportClass · 0.70
reverseComplementFunction · 0.50
getFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected