/** Function get_seeds() * * Produce seeds: rID-> (s0, s1, s2...) for each fragment given two * fq files f and f2 */ void get_seeds (ii64vec_t& list_seeds, const std::string& f, const std::string& f2, int seed_len, int batch, bool silent) { std::ifstream fh, fh2; xny::openfile<std::ifstream>(fh, f); xny::openfile<std::ifstream>(fh2, f2); bio::fastq_input_iterator<> fq(fh), end, fq2(fh2); int total_read_pairs = 0; strvec_t pairs; while (fq != end && fq2 != end) { add_fq_reads_only (pairs, batch/2, fq, end); add_fq_reads_only (pairs, batch/2, fq2, end); generate_seeds (list_seeds, pairs, seed_len); total_read_pairs += pairs.size()/2; pairs.clear(); } // while if (!silent) { std::cout << "\t\ttotal frags: " << total_read_pairs << "\n"; } xny::closefile(fh); xny::closefile(fh2); } // get_seeds
void Optimization::optimize() { tt.tic(); current_iteration = 0; start_dist = 0.1; current_dist = start_dist; _current_seeds = 0; while (max_iterations>current_iteration&&min_dist<dist_update) { //emit emit_progress(0); std::vector<Method_Coefficients> seeds = generate_seeds(this->coefficients_end); for(std::vector<Method_Coefficients>::iterator kit = seeds.begin(); kit < seeds.end(); kit++) { Method_Coefficients seed = *kit; make_coefficients_positive(seed); WorkerSphereFollowing * worker = new WorkerSphereFollowing(1); // worker->set_control(this->controller); worker->setOptimize(shared_from_this()); worker->set_coefficients(seed); worker->setA(coefficients_end.a); worker->setB(coefficients_end.b); worker->setFac(coefficients_end.fact); worker->setMinRad(coefficients_end.minRad); worker->setCloudPtr(_cloud_ptr); worker->setTreeID(treeID); worker->setIsStem(isStem); this->start(worker); } current_iteration ++; this->waitForDone(); end_dist = current_dist; start_dist = end_dist; update_sd(); coefficients_start = coefficients_end; } std::vector<float> minRadii; minRadii.push_back(0.015); minRadii.push_back(0.02); minRadii.push_back(0.025); minRadii.push_back(0.03); minRadii.push_back(0.035); minRadii.push_back(0.04); minRadii.push_back(0.045); if(!qFuzzyCompare(coefficients_start.minRad,0.0025f)) { for(std::vector<float>::iterator f_it = minRadii.begin(); f_it < minRadii.end(); f_it++) { float radius = *f_it; WorkerSphereFollowing * worker = new WorkerSphereFollowing(1); // worker->set_control(this->controller); worker->setOptimize(shared_from_this()); worker->set_coefficients(coefficients_start); worker->setA(coefficients_end.a); worker->setB(coefficients_end.b); worker->setFac(coefficients_end.fact); worker->setMinRad(radius); worker->setCloudPtr(_cloud_ptr); worker->setTreeID(treeID); worker->setIsStem(isStem); this->start(worker); } } this->waitForDone(); end_dist = current_dist; start_dist = end_dist; update_sd(); coefficients_start = coefficients_end; }