void starling_read:: set_genome_align(const alignment& al) { assert(get_full_segment().genome_align().empty()); assert(! al.empty()); get_full_segment()._genome_align=al; const seg_id_t n_seg(apath_exon_count(al.path)); if(n_seg<=1) return; // deal with segmented reads now: assert(! is_segmented()); _segment_ptr.reset(new starling_segmented_read(n_seg)); using namespace ALIGNPATH; seg_id_t seg_id(1); pos_t read_pos(0); pos_t ref_pos(al.pos); pos_t seg_start_read_pos(read_pos); pos_t seg_start_ref_pos(ref_pos); path_t seg_path; const unsigned as(al.path.size()); for(unsigned i(0); i<as; ++i) { const path_segment& ps(al.path[i]); const pos_t last_read_pos(read_pos); if(is_segment_type_ref_length(ps.type)) ref_pos += ps.length; if(is_segment_type_read_length(ps.type)) read_pos += ps.length; if(ps.type!=SKIP) seg_path.push_back(ps); if(ps.type==SKIP || ((i+1)==as)) { const pos_t end_read_pos( (ps.type==SKIP) ? last_read_pos : read_pos ); assert(end_read_pos>seg_start_read_pos); const unsigned size(end_read_pos-seg_start_read_pos); const read_segment rseg(size,seg_start_read_pos,this); _segment_ptr->set_segment(seg_id,rseg); alignment& new_al(get_segment(seg_id)._genome_align); new_al.path=seg_path; new_al.pos=seg_start_ref_pos; new_al.is_fwd_strand=al.is_fwd_strand; seg_id++; seg_start_read_pos=read_pos; seg_start_ref_pos=ref_pos; seg_path.clear(); } } }