Module: RGFATools::PBubbles

Included in:
RGFATools
Defined in:
lib/rgfatools/p_bubbles.rb

Overview

Methods for the RGFA class, which involve a traversal of the graph following links

Instance Method Summary collapse

Instance Method Details

#remove_p_bubble(segment_end1, segment_end2, count_tag: @default[:count_tag], unit_length: @default[:unit_length]) ⇒ RGFA

Removes a p-bubble between segment_end1 and segment_end2

Parameters:

  • segment_end1 (RGFA::SegmentEnd)

    a segment end

  • segment_end2 (RGFA::SegmentEnd)

    another segment end

  • count_tag (Symbol)

    (defaults to: :RC or the value set by CopyNumber#set_default_count_tag) the count tag to use for coverage computation

  • unit_length (Integer)

    (defaults to: 1 or the value set by CopyNumber#set_count_unit_length) the unit length to use for coverage computation

Returns:


42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rgfatools/p_bubbles.rb', line 42

def remove_p_bubble(segment_end1, segment_end2,
                    count_tag: @default[:count_tag],
                    unit_length: @default[:unit_length])
  n1 = neighbours(segment_end1).sort
  n2 = neighbours(segment_end2).sort
  raise if n1 != n2.map{|se| se.invert_end_type}
  raise if n1.any? {|se| connectivity(se[0]) != [1,1]}
  remove_proven_p_bubble(segment_end1, segment_end2, n1,
                         count_tag: count_tag,
                         unit_length: unit_length)
  return self
end

#remove_p_bubblesRGFA

Removes all p-bubbles in the graph

Returns:


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rgfatools/p_bubbles.rb', line 11

def remove_p_bubbles
  visited = Set.new
  segment_names.each do |sn|
    next if visited.include?(sn)
    if connectivity(sn) == [1,1]
      s1 = neighbours([sn, :B])[0]
      s2 = neighbours([sn, :E])[0]
      n1 = neighbours(s1).sort
      n2 = neighbours(s2).sort
      n1.each {|se| visited << se[0].name}
      if n1 == n2.map{|se| se.invert_end_type}
        remove_proven_p_bubble(s1, s2, n1)
      end
    end
  end
  return self
end