void rice::pastry::testing::ClosestRegrTest::run() { for (auto i = int32_t(0); i < NUM_NODES_; i++) { auto node = npc(factory)->newNode(getBootstrap()); { synchronized synchronized_0(node); { while (!npc(node)->isReady()) { try { npc(node)->wait(500); } catch (::java::lang::InterruptedException* ie) { return; } } } } if(i > 0) test(i, java_cast< ::rice::pastry::direct::DirectNodeHandle* >(npc(node)->getLocalHandle())); npc(::java::lang::System::out())->println(::java::lang::StringBuilder().append(u"CREATED NODE "_j)->append(i) ->append(u" "_j) ->append(static_cast< ::java::lang::Object* >(npc(node)->getNodeId()))->toString()); npc(pastryNodes)->add(static_cast< ::java::lang::Object* >(node)); auto ave = getAvgNumEntries(pastryNodes); npc(::java::lang::System::out())->println(::java::lang::StringBuilder().append(u"Avg Num Entries:"_j)->append(ave)->toString()); } npc(::java::lang::System::out())->println(::java::lang::StringBuilder().append(u"SO FAR: "_j)->append(incorrect) ->append(u"/"_j) ->append(NUM_NODES_) ->append(u" PERCENTAGE: "_j) ->append((sum / incorrect))->toString()); }
void BrowserManager::Impl::BrowserManagerEntry() { std::string bootstrapPath = getBootstrap(); bool thread_exit = false; PushEvent([] { CefMainArgs mainArgs; CefSettings settings; settings.log_severity = LOGSEVERITY_VERBOSE; settings.windowless_rendering_enabled = true; settings.no_sandbox = true; CefString(&settings.cache_path).FromASCII(obs_module_config_path("")); CefString(&settings.browser_subprocess_path) = getBootstrap(); CefRefPtr<BrowserApp> app(new BrowserApp()); CefExecuteProcess(mainArgs, app, nullptr); CefInitialize(mainArgs, settings, app, nullptr); CefRegisterSchemeHandlerFactory("http", "absolute", new BrowserSchemeHandlerFactory()); CefRunMessageLoop(); CefShutdown(); }); while (true) { if (os_event_timedwait(dispatchEvent, 10) != ETIMEDOUT) { pthread_mutex_lock(&dispatchLock); while (!queue.empty()) { auto event = queue[0]; event(); queue.erase(queue.begin()); } thread_exit = !threadAlive; pthread_mutex_unlock(&dispatchLock); if (thread_exit) { return; } } } }
// perform classification in separate threads void Classifier::runThread(FastaReader &reader) { DnaSequence seq; boost::mt19937 randGen(0); RandomGen generator(randGen); while(seq = reader.readSequence()) { // reproducible randomness randGen.seed(reader.numRead()); // get a query sequence and convert to kmers KmerSequence fwdSeq = kmerizer_.kmerize(seq); // and the reverse complement KmerSequence revSeq = kmerizer_.revComp(fwdSeq); // search against database using both forward and reverse sequences searchHit fwdHit = referenceData_.search(fwdSeq); searchHit revHit = referenceData_.search(revSeq); // use the direction which gave the highest scoring hit KmerSequence &querySeq = fwdHit.score > revHit.score ? fwdSeq : revSeq; searchHit &hit = fwdHit.score > revHit.score ? fwdHit : revHit; std::vector<float> bootstraps(referenceData_.numLevels(), 0.f); std::vector<std::string> annotations(referenceData_.numLevels(), "AMBIGUOUS"); // make each level annotations into a list of uniques for (unsigned int i=0; i< hit.annotationIds.size(); i++) { std::sort(hit.annotationIds[i].begin(), hit.annotationIds[i].end()); std::vector<unsigned int>::iterator it; it = std::unique(hit.annotationIds[i].begin(), hit.annotationIds[i].end()); hit.annotationIds[i].resize(std::distance(hit.annotationIds[i].begin(), it)); if (hit.annotationIds[i].size() == 1) annotations[i] = referenceData_.annotationFromId(*hit.annotationIds[i].begin()); } // bootstrap if(numBootstrap_ > 0) bootstraps = getBootstrap(querySeq, generator, hit); // output std::stringstream s; s << std::setprecision(2) << std::fixed; s << querySeq.header.substr(0, querySeq.header.find("\t")) << "\t"; s << hit.score << "\t"; //for(unsigned int i=0; i<bootstraps.size(); i++) unsigned int i=bootstraps.size(); while(i--) { s << annotations[i] << "\t"; s << bootstraps[i]; if(i>0) { s << "\t"; } else { // dump ambiguous species if (hit.annotationIds[i].size() > 1 && outputAmbiguous_) { s << "\t"; for(std::vector<unsigned int>::iterator it = hit.annotationIds[i].begin(); it != hit.annotationIds[i].end(); ++it) { if (it != hit.annotationIds[i].begin()) s << ","; s << referenceData_.annotationFromId(*it); } } s << std::endl; } } boost::mutex::scoped_lock lock(mutex_); std::cout << s.str(); } }