void starling_read_buffer:: rebuffer_read_segment(const align_id_t read_id, const seg_id_t seg_id, const pos_t new_buffer_pos) { // double check that the read exists: const read_data_t::iterator i(_read_data.find(read_id)); if(i == _read_data.end()) return; read_segment& rseg(i->second->get_segment(seg_id)); // remove from old pos list: const pos_group_t::iterator j(_pos_group.find(rseg.buffer_pos)); assert(j != _pos_group.end()); const segment_t segkey(std::make_pair(read_id,seg_id)); assert(j->second.count(segkey)==1); j->second.erase(segkey); // alter data within read: rseg.buffer_pos=new_buffer_pos; // add to new pos list: (_pos_group[new_buffer_pos]).insert(segkey); }
// initial step: // 0) id all indels in full_pr // 1) convert these into genotype elements (including simple homopolymer normalization) // 2) reduce to two most popular alleles for all alleles which conflict // 3) print lots of stuff out for the active region // void starling_pos_processor_base:: get_region_haplotypes(const known_pos_range full_pr, const known_pos_range /*active_pr*/) { // only works for the first sample right now: static const unsigned sample_no(0); //for(unsigned sample_no(0);sample_no<_n_samples;++sample_no).. sample_info& sif(sample(sample_no)); // step 0: identify all candidate indels in full region: htype_buffer hdata; // iterate through indels in each region, find and iterate through supporting reads for each indel: // const indel_buffer& ibuff(sif.indel_sync().ibuff()); typedef indel_buffer::const_iterator ciiter; const std::pair<ciiter,ciiter> ipair(ibuff.pos_range_iter(full_pr.begin_pos,full_pr.end_pos)); for (ciiter i(ipair.first); i!=ipair.second; ++i) { const indel_key& ik(i->first); const indel_data& id(get_indel_data(i)); // check that indel really falls into candidate range: if (! (full_pr.is_pos_intersect(ik.pos) || full_pr.is_pos_intersect(ik.right_pos()))) continue; // only consider candidates: if (! sif.indel_sync().is_candidate_indel(_client_opt,ik,id)) continue; get_htypes_for_indel(_client_dopt,sif.read_buff,_ref,ik,id,hdata); // convert indel to htype_element and insert: // convert_indel_to_htype(ik,id,_ref_seq); } #ifdef DEBUG_HTYPE if (! hdata.empty()) hdata.dump(std::cerr); #endif #if 0 // get expanded region for read search: const known_pos_range expanded_pr(full_pr.begin_pos-(_client_opt.max_indel_size+XXXMAX_READ_SIZE),full_pr.end_pos); // iterate through reads in region: for (pos_t pos(begin); pos<end; ++pos) { read_segment_iter ri(sif.read_buff.get_pos_read_segment_iter(pos)); for (read_segment_iter::ret_val r; true; ri.next()) { r=ri.get_ptr(); if (NULL==r.first) break; read_segment& rseg(r.first->get_segment(r.second)); { indel_set_t cal_indels; get_alignment_indels(cal,opt.max_indel_size,cal_indels); } //rseg.blah.... } } #endif #if 0 const indel_buffer& ibuff(sif.indel_sync().ibuff()); const std::pair<ciiter,ciiter> ipair(ibuff.pos_range_iter(full_pr.begin_pos,full_pr.end_pos)); for (ciiter i(ipair.first); i!=ipair.second; ++i) { const indel_key& ik(i->first); const indel_data& id(get_indel_data(i)); // check that indel really falls into candidate range: if (! (full_pr.is_pos_intersect(ik.pos()) || full_pr.is_pos_intersect(ik.right_pos()))) continue; // only consider candidates: if (! sif.indel_sync().is_candidate_indel(_client_opt,ik,id)) continue; // convert indel to htype_element and insert: convert_indel_to_htype(ik,id,_ref_seq); } #endif #if 0 const known_pos_range full_pr(start_pos,start_pos+region_size); const known_pos_range active_pr(full_start_pos+region_size/4,start_pos+region_size); const pos_t begin(region_size/4); const pos_t end(begin+(region_size/2)); // step 1: identify loci in region: const indel_buffer& ibuff(isync.ibuff()); typedef indel_buffer::const_iterator ciiter; const std::pair<ciiter,ciiter> ipair(ibuff.pos_range_iter(pr.begin_pos,pr.end_pos)); for (ciiter i(ipair.first); i!=ipair.second; ++i) { const indel_key& ik(i->first); const indel_data& id(get_indel_data(i)); #if 1 // iterate through reads in region: for (pos_t pos(begin); pos<end; ++pos) { read_segment_iter ri(sif.read_buff.get_pos_read_segment_iter(pos)); for (read_segment_iter::ret_val r; true; ri.next()) { r=ri.get_ptr(); if (NULL==r.first) break; read_segment& rseg(r.first->get_segment(r.second)); //rseg.blah.... } } #endif } #endif }