File: test_rgfatools_linear_paths.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 (52 lines) | stat: -rw-r--r-- 1,581 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require "rgfatools.rb"
require "test/unit"

class TestRGFAToolsLinearPaths < Test::Unit::TestCase

  def test_linear_path_merging
    s = ["S\t0\tACGA",
         "S\t1\tACGA",
         "S\t2\tACGA",
         "S\t3\tACGA"]
    l = ["L\t0\t+\t1\t+\t1M",
         "L\t1\t+\t2\t-\t1M",
         "L\t2\t-\t3\t+\t1M"]
    gfa = RGFA.new
    (s + l).each {|line| gfa << line }
    gfa.merge_linear_path([["0", :E],["1", :E],["2", :B],["3", :E]],
                          enable_tracking: true)
    assert_nothing_raised {gfa.segment!("0_1_2^_3")}
    assert_equal("ACGACGACGTCGA", gfa.segment("0_1_2^_3").sequence)
    gfa = RGFA.new
    gfa.enable_extensions
    (s + l).each {|line| gfa << line }
    gfa.merge_linear_path([["0", :E],["1", :E],["2", :B],["3", :E]])
    assert_nothing_raised {gfa.segment!("0_1_2^_3")}
    assert_equal("ACGACGACGTCGA", gfa.segment("0_1_2^_3").sequence)
  end

  def test_linear_path_merge_all
    s = ["S\t0\t*",
         "S\t1\t*",
         "S\t2\t*",
         "S\t3\t*"]
    l = ["L\t0\t+\t1\t+\t1M",
         "L\t1\t+\t2\t-\t1M",
         "L\t2\t-\t3\t+\t1M"]
    gfa = RGFA.new
    gfa.enable_extensions
    (s + l).each {|line| gfa << line }
    gfa.merge_linear_paths
    assert_equal([:"0_1_2^_3"], gfa.segment_names)
    l = ["L\t0\t+\t1\t+\t1M",
         "L\t0\t+\t2\t+\t1M",
         "L\t1\t+\t2\t-\t1M",
         "L\t2\t-\t3\t+\t1M"].map(&:to_rgfa_line)
    gfa = RGFA.new
    gfa.enable_extensions
    (s + l).each {|line| gfa << line }
    gfa.merge_linear_paths
    assert_equal([:"0",:"3",:"1_2^"], gfa.segments.map(&:name))
  end

end