rbbt-util 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/run_workflow.rb +118 -0
- data/lib/rbbt-util.rb +0 -3
- data/lib/rbbt/util/fix_width_table.rb +7 -0
- data/lib/rbbt/util/misc.rb +20 -4
- data/lib/rbbt/util/persistence.rb +51 -28
- data/lib/rbbt/util/resource.rb +1 -0
- data/lib/rbbt/util/task.rb +11 -0
- data/lib/rbbt/util/task/job.rb +3 -1
- data/lib/rbbt/util/tc_hash.rb +89 -20
- data/lib/rbbt/util/tsv.rb +23 -8
- data/lib/rbbt/util/tsv/accessor.rb +8 -5
- data/lib/rbbt/util/tsv/filters.rb +68 -20
- data/lib/rbbt/util/tsv/index.rb +115 -92
- data/lib/rbbt/util/tsv/manipulate.rb +10 -13
- data/lib/rbbt/util/tsv/parse.rb +1 -1
- data/lib/rbbt/util/tsv/resource.rb +8 -0
- data/lib/rbbt/util/workflow.rb +26 -8
- data/share/lib/R/util.R +71 -1
- data/test/rbbt/util/test_misc.rb +17 -0
- data/test/rbbt/util/test_persistence.rb +32 -0
- data/test/rbbt/util/test_resource.rb +1 -0
- data/test/rbbt/util/test_task.rb +14 -0
- data/test/rbbt/util/test_tc_hash.rb +16 -0
- data/test/rbbt/util/tsv/test_accessor.rb +0 -1
- data/test/rbbt/util/tsv/test_filters.rb +26 -0
- data/test/rbbt/util/tsv/test_index.rb +78 -26
- data/test/rbbt/util/tsv/test_manipulate.rb +1 -1
- metadata +10 -14
- data/bin/workflow.rb +0 -24
- data/lib/rbbt/util/bed.rb +0 -325
- data/lib/rbbt/util/cachehelper.rb +0 -100
- data/test/rbbt/util/test_bed.rb +0 -136
data/test/rbbt/util/test_bed.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
|
2
|
-
require 'rbbt/util/bed'
|
3
|
-
require 'rbbt/util/tmpfile'
|
4
|
-
|
5
|
-
class TestBed < Test::Unit::TestCase
|
6
|
-
def load_data(data)
|
7
|
-
Log.debug("Data:\n#{Open.read(data)}")
|
8
|
-
tsv = TSV.new(data, :list, :sep=>":", :cast => proc{|e| e =~ /(\s*)(_*)/; ($1.length..($1.length + $2.length - 1))})
|
9
|
-
tsv.add_field "Start" do |key, values|
|
10
|
-
values["Range"].first
|
11
|
-
end
|
12
|
-
tsv.add_field "End" do |key, values|
|
13
|
-
values["Range"].last
|
14
|
-
end
|
15
|
-
|
16
|
-
tsv
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_point
|
20
|
-
data =<<-EOF
|
21
|
-
#ID Pos
|
22
|
-
a 1
|
23
|
-
b 10
|
24
|
-
c 20
|
25
|
-
d 12
|
26
|
-
e 26
|
27
|
-
f 11
|
28
|
-
g 25
|
29
|
-
EOF
|
30
|
-
|
31
|
-
TmpFile.with_file(data) do |f|
|
32
|
-
bed = Bed.new TSV.new(f, :list, :sep=>" "), :key => "Pos" , :value => "ID"
|
33
|
-
|
34
|
-
assert_equal %w(), bed[0].sort
|
35
|
-
assert_equal %w(b), bed[10].sort
|
36
|
-
assert_equal %w(a b c d f), bed[(0..20)].sort
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_range
|
41
|
-
data =<<-EOF
|
42
|
-
#ID:Range
|
43
|
-
#:012345678901234567890
|
44
|
-
a: ______
|
45
|
-
b: ______
|
46
|
-
c: _______
|
47
|
-
d: ____
|
48
|
-
e: ______
|
49
|
-
f: ___
|
50
|
-
g: ____
|
51
|
-
EOF
|
52
|
-
|
53
|
-
TmpFile.with_file(data) do |f|
|
54
|
-
bed = Bed.new load_data(f), :range => ["Start" , "End"], :value => "ID"
|
55
|
-
|
56
|
-
assert_equal %w(), bed[0].sort
|
57
|
-
assert_equal %w(b), bed[1].sort
|
58
|
-
assert_equal %w(), bed[20].sort
|
59
|
-
assert_equal %w(), bed[(20..100)].sort
|
60
|
-
assert_equal %w(a b d), bed[3].sort
|
61
|
-
assert_equal %w(a b c d e), bed[(3..4)].sort
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_format
|
66
|
-
entry = Bed::Entry.new "Hola", 0, 10, nil
|
67
|
-
format = Bed::FixWidthTable.format(entry,1, 100)
|
68
|
-
assert_equal entry, Bed::FixWidthTable.unformat(format, 100)
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_table
|
72
|
-
TmpFile.with_file do |f|
|
73
|
-
table = Bed::FixWidthTable.new(f, 100, false)
|
74
|
-
table.add Bed::Entry.new("Entry1", 0, 10, nil), 0
|
75
|
-
table.add Bed::Entry.new("Entry2", 10, 20, nil), 10
|
76
|
-
table.add Bed::Entry.new("Entry3", 10, 20, nil), 10
|
77
|
-
|
78
|
-
table.read
|
79
|
-
|
80
|
-
assert_equal "Entry1", table[0].value
|
81
|
-
assert_equal "Entry2", table[1].value
|
82
|
-
assert_equal "Entry3", table[2].value
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_range_point
|
88
|
-
data =<<-EOF
|
89
|
-
#ID Pos
|
90
|
-
a 1
|
91
|
-
b 10
|
92
|
-
c 20
|
93
|
-
d 12
|
94
|
-
e 26
|
95
|
-
f 11
|
96
|
-
g 25
|
97
|
-
EOF
|
98
|
-
|
99
|
-
TmpFile.with_file(data) do |f|
|
100
|
-
bed = Bed.new TSV.new(f,:list, :sep=>" "), :key => "Pos" , :value => "ID", :persistence => true
|
101
|
-
|
102
|
-
bed = Bed.new TSV.new(f,:list, :sep=>" "), :key => "Pos" , :value => "ID", :persistence => true
|
103
|
-
|
104
|
-
assert_equal %w(), bed[0].sort
|
105
|
-
assert_equal %w(a b c d f), bed[(0..20)].sort
|
106
|
-
assert_equal %w(b), bed[10].sort
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def test_range_persistence
|
111
|
-
data =<<-EOF
|
112
|
-
#ID:Range
|
113
|
-
#:012345678901234567890
|
114
|
-
a: ______
|
115
|
-
b: ______
|
116
|
-
c: _______
|
117
|
-
d: ____
|
118
|
-
e: ______
|
119
|
-
f: ___
|
120
|
-
g: ____
|
121
|
-
EOF
|
122
|
-
|
123
|
-
TmpFile.with_file(data) do |f|
|
124
|
-
bed = Bed.new load_data(f), :range => ["Start" , "End"], :value => "ID", :persistence => true
|
125
|
-
|
126
|
-
bed = Bed.new load_data(f), :range => ["Start" , "End"], :value => "ID", :persistence => true
|
127
|
-
|
128
|
-
assert_equal %w(), bed[0].sort
|
129
|
-
assert_equal %w(b), bed[1].sort
|
130
|
-
assert_equal %w(), bed[20].sort
|
131
|
-
assert_equal %w(), bed[(20..100)].sort
|
132
|
-
assert_equal %w(a b d), bed[3].sort
|
133
|
-
assert_equal %w(a b c d e), bed[(3..4)].sort
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|