lib/ims_indel/consensus.rb
# find insertion pair from cons_Bs and cons_Fs
find insertion pair from cons_Bs and cons_Fs
find insertion pair from cons_Bs and cons_Fs
def find_insert_pair(backward_consensus, forward_consensus, pair_within)
      insert_pair = []
      forward_consensus_dup = forward_consensus.dup
      backward_consensus.each do |consensus_b|
        start_pos_b = consensus_b.start_pos - pair_within
        end_pos_b = consensus_b.end_pos + pair_within
        skip = 0
        forward_consensus_dup.each_with_index do |consensus_f, index|
          start_pos_f = consensus_f.start_pos - pair_within
          end_pos_f = consensus_f.end_pos + pair_within
          if end_pos_f < start_pos_b
            skip = index
            next
          elsif (start_pos_f <= end_pos_b && end_pos_b <= end_pos_f) || (start_pos_f <= start_pos_b && start_pos_b <= end_pos_f)
            insert_pair << [consensus_b, consensus_f]
          elsif end_pos_b < start_pos_f
            forward_consensus_dup = forward_consensus_dup[skip..-1] 
            break
          end
        end
      end
      return insert_pair
    end
def find_insert_pair ( backward_consensus , forward_consensus , pair_within ) insert_pair = [ ] forward_consensus_dup = forward_consensus . dup backward_consensus . each do | consensus_b | start_pos_b = consensus_b . start_pos - pair_within end_pos_b = consensus_b . end_pos + pair_within skip = 0 forward_consensus_dup . each_with_index do | consensus_f , index | start_pos_f = consensus_f . start_pos - pair_within end_pos_f = consensus_f . end_pos + pair_within if end_pos_f < start_pos_b skip = index next elsif ( start_pos_f <= end_pos_b && end_pos_b <= end_pos_f ) || ( start_pos_f <= start_pos_b && start_pos_b <= end_pos_f ) insert_pair << [ consensus_b , consensus_f ] elsif end_pos_b < start_pos_f forward_consensus_dup = forward_consensus_dup [ skip .. - 1 ] break end end end return insert_pair end
find insertion pair from cons_Bs and cons_Fs
find insertion pair from cons_Bs and cons_Fs
# update
backward_consensus
forward_consensus
pair_within