1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#
# Methods which edit the graph components without traversal
#
module RGFATools::Artifacts
# Remove connected components whose sum of lengths of the segments
# is under a specified value.
# @param minlen [Integer] the minimum length
# @return [RGFA] self
def remove_small_components(minlen)
rm(connected_components.select {|cc|
cc.map{|sn|segment(sn).length}.reduce(:+) < minlen })
self
end
# Remove end segments, whose sequence length is under a specified value.
# @param minlen [Integer] the minimum length
# @return [RGFA] self
def remove_dead_ends(minlen)
segments.each do |s|
c = connectivity(s)
rm(s) if s.length < minlen and
(c[0] == 0 or c[1] == 0) and
!cut_segment?(s)
end
self
end
end
|