File: artifacts.rb

package info (click to toggle)
ruby-rgfa 1.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 824 kB
  • sloc: ruby: 5,649; makefile: 9
file content (29 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (4)
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