rbbt-util 5.43.0 → 5.44.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/etc/app.d/base.rb +1 -1
  3. data/lib/rbbt/association/util.rb +1 -1
  4. data/lib/rbbt/hpc/batch.rb +19 -17
  5. data/lib/rbbt/persist/tsv/sharder.rb +1 -1
  6. data/lib/rbbt/tsv/accessor.rb +6 -11
  7. data/lib/rbbt/tsv/dumper.rb +21 -10
  8. data/lib/rbbt/tsv/index.rb +2 -1
  9. data/lib/rbbt/util/misc/math.rb +0 -1
  10. data/lib/rbbt/util/misc/omics.rb +2 -1
  11. data/lib/rbbt/util/misc/ssw.rb +298 -0
  12. data/lib/rbbt/util/open.rb +1 -1
  13. data/lib/rbbt/workflow/step/info.rb +3 -2
  14. data/lib/rbbt/workflow/step.rb +2 -1
  15. data/python/rbbt/__init__.py +2 -2
  16. data/share/rbbt_commands/workflow/server +6 -1
  17. data/share/rbbt_commands/workflow/task +1 -1
  18. metadata +5 -220
  19. data/test/rbbt/annotations/test_util.rb +0 -43
  20. data/test/rbbt/association/test_database.rb +0 -87
  21. data/test/rbbt/association/test_index.rb +0 -127
  22. data/test/rbbt/association/test_item.rb +0 -15
  23. data/test/rbbt/association/test_open.rb +0 -63
  24. data/test/rbbt/association/test_util.rb +0 -108
  25. data/test/rbbt/entity/test_identifiers.rb +0 -34
  26. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
  27. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
  28. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
  29. data/test/rbbt/hpc/test_batch.rb +0 -64
  30. data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
  31. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  32. data/test/rbbt/hpc/test_pbs.rb +0 -43
  33. data/test/rbbt/hpc/test_slurm.rb +0 -28
  34. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
  35. data/test/rbbt/knowledge_base/test_entity.rb +0 -62
  36. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  37. data/test/rbbt/knowledge_base/test_registry.rb +0 -74
  38. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  39. data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
  40. data/test/rbbt/persist/test_tsv.rb +0 -88
  41. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  42. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  43. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  44. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
  45. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  46. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  47. data/test/rbbt/resource/test_path.rb +0 -49
  48. data/test/rbbt/test_annotations.rb +0 -167
  49. data/test/rbbt/test_association.rb +0 -103
  50. data/test/rbbt/test_entity.rb +0 -252
  51. data/test/rbbt/test_fix_width_table.rb +0 -135
  52. data/test/rbbt/test_knowledge_base.rb +0 -226
  53. data/test/rbbt/test_monitor.rb +0 -11
  54. data/test/rbbt/test_packed_index.rb +0 -68
  55. data/test/rbbt/test_persist.rb +0 -85
  56. data/test/rbbt/test_resource.rb +0 -110
  57. data/test/rbbt/test_tsv.rb +0 -669
  58. data/test/rbbt/test_workflow.rb +0 -609
  59. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  60. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  61. data/test/rbbt/tsv/test_accessor.rb +0 -319
  62. data/test/rbbt/tsv/test_attach.rb +0 -715
  63. data/test/rbbt/tsv/test_change_id.rb +0 -61
  64. data/test/rbbt/tsv/test_csv.rb +0 -49
  65. data/test/rbbt/tsv/test_excel.rb +0 -171
  66. data/test/rbbt/tsv/test_field_index.rb +0 -19
  67. data/test/rbbt/tsv/test_filter.rb +0 -187
  68. data/test/rbbt/tsv/test_index.rb +0 -308
  69. data/test/rbbt/tsv/test_manipulate.rb +0 -334
  70. data/test/rbbt/tsv/test_marshal.rb +0 -24
  71. data/test/rbbt/tsv/test_matrix.rb +0 -20
  72. data/test/rbbt/tsv/test_parallel.rb +0 -7
  73. data/test/rbbt/tsv/test_parser.rb +0 -101
  74. data/test/rbbt/tsv/test_stream.rb +0 -253
  75. data/test/rbbt/tsv/test_util.rb +0 -52
  76. data/test/rbbt/util/R/test_eval.rb +0 -43
  77. data/test/rbbt/util/R/test_model.rb +0 -128
  78. data/test/rbbt/util/R/test_plot.rb +0 -38
  79. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  80. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  81. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  82. data/test/rbbt/util/log/test_progress.rb +0 -111
  83. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  84. data/test/rbbt/util/misc/test_communication.rb +0 -13
  85. data/test/rbbt/util/misc/test_development.rb +0 -26
  86. data/test/rbbt/util/misc/test_format.rb +0 -10
  87. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  88. data/test/rbbt/util/misc/test_lock.rb +0 -77
  89. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  90. data/test/rbbt/util/misc/test_omics.rb +0 -116
  91. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  92. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  93. data/test/rbbt/util/python/test_util.rb +0 -25
  94. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  95. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  96. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  97. data/test/rbbt/util/test_R.rb +0 -37
  98. data/test/rbbt/util/test_chain_methods.rb +0 -22
  99. data/test/rbbt/util/test_cmd.rb +0 -87
  100. data/test/rbbt/util/test_colorize.rb +0 -22
  101. data/test/rbbt/util/test_concurrency.rb +0 -6
  102. data/test/rbbt/util/test_config.rb +0 -69
  103. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  104. data/test/rbbt/util/test_filecache.rb +0 -36
  105. data/test/rbbt/util/test_log.rb +0 -52
  106. data/test/rbbt/util/test_migrate.rb +0 -34
  107. data/test/rbbt/util/test_misc.rb +0 -728
  108. data/test/rbbt/util/test_open.rb +0 -200
  109. data/test/rbbt/util/test_procpath.rb +0 -23
  110. data/test/rbbt/util/test_python.rb +0 -144
  111. data/test/rbbt/util/test_semaphore.rb +0 -36
  112. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  113. data/test/rbbt/util/test_simpleopt.rb +0 -11
  114. data/test/rbbt/util/test_ssh.rb +0 -10
  115. data/test/rbbt/util/test_tmpfile.rb +0 -32
  116. data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
  117. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  118. data/test/rbbt/workflow/test_doc.rb +0 -30
  119. data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
  120. data/test/rbbt/workflow/test_schedule.rb +0 -0
  121. data/test/rbbt/workflow/test_step.rb +0 -231
  122. data/test/rbbt/workflow/test_task.rb +0 -85
  123. data/test/rbbt/workflow/util/test_archive.rb +0 -27
  124. data/test/rbbt/workflow/util/test_data.rb +0 -67
  125. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
  126. data/test/test_helper.rb +0 -114
@@ -1,61 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt-util'
3
- require 'rbbt/tsv'
4
- require 'rbbt/tsv/change_id'
5
-
6
- class TestTSVChangeID < Test::Unit::TestCase
7
-
8
- FILE1=<<-EOF
9
- #: :sep=' '
10
- #A B C
11
- a b c
12
- aa bb cc
13
- EOF
14
-
15
- FILE2=<<-EOF
16
- #: :sep=' '
17
- #X Y Z
18
- x y z
19
- xx yy zz
20
- EOF
21
-
22
- IDENTIFIERS=<<-EOF
23
- #: :sep=' '
24
- #A X
25
- a x
26
- aa xx
27
- EOF
28
-
29
- def tsv(text, options = {})
30
- options = Misc.add_defaults options, :type => :list
31
- TSV.open StringIO.new(text), options
32
- end
33
-
34
- def setup
35
- @f1 = tsv(FILE1)
36
- @f2 = tsv(FILE2)
37
- @f3 = tsv(FILE2, :key_field => "Y")
38
- @id = tsv(IDENTIFIERS)
39
- end
40
-
41
- def test_swap_id
42
- @f3.identifiers = @id
43
- assert_equal "a", @f3.swap_id("X","A")["y"]["A"]
44
- end
45
-
46
-
47
- def test_change_key
48
- @f1.identifiers = @id
49
- assert @f1.change_key("X").include? "x"
50
- end
51
-
52
- def test_translate_key
53
- @f1.identifiers = @id
54
- assert TSV.translate(@f1, @f1.key_field, "X", :persist => false).include? "x"
55
- end
56
-
57
- def test_translate_key_persist
58
- @f1.identifiers = @id
59
- assert TSV.translate(@f1, @f1.key_field, "X", :persist => true).include? "x"
60
- end
61
- end
@@ -1,49 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/tsv/csv'
3
-
4
- class TestCSV < Test::Unit::TestCase
5
- def test_csv
6
- text =<<-EOF
7
- Key,FieldA,FieldB
8
- k1,a,b
9
- k2,aa,bb
10
- EOF
11
-
12
- tsv = TSV.csv(text)
13
- assert_equal 'bb', tsv['k2']['FieldB']
14
- end
15
-
16
- def test_csv_key_field
17
- text =<<-EOF
18
- Key,FieldA,FieldB
19
- k1,a,b
20
- k2,aa,bb
21
- EOF
22
-
23
- tsv = TSV.csv(text, :key_field => 'FieldA', :type => :list)
24
- assert_equal 'bb', tsv['aa']['FieldB']
25
- end
26
-
27
- def test_csv_double
28
- text =<<-EOF
29
- Key,FieldA,FieldB
30
- k1,a,b
31
- k2,aa,bb
32
- EOF
33
-
34
- tsv = TSV.csv(text, :key_field => 'FieldA', :type => :double)
35
- assert_equal ['bb'], tsv['aa']['FieldB']
36
- end
37
-
38
- def test_csv_noheader
39
- text =<<-EOF
40
- k1,a,b
41
- k2,aa,bb
42
- EOF
43
-
44
- tsv = TSV.csv(text, :headers => false)
45
- assert_equal %w(k2 aa bb), tsv['row-1']
46
- end
47
-
48
- end
49
-
@@ -1,171 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/tsv/excel'
3
-
4
- class TestExcel < Test::Unit::TestCase
5
- def test_xls
6
- content =<<-EOF
7
- #Id ValueA ValueB OtherID
8
- row1 a|aa|aaa b Id1|Id2
9
- row2 A B Id3
10
- EOF
11
-
12
- TmpFile.with_file(content) do |filename|
13
- tsv = TSV.open(filename, :sep => /\s+/)
14
- TmpFile.with_file(nil, true, :extension => 'xlsx') do |excelfile|
15
- tsv.xls(excelfile)
16
- new = TSV.xls(excelfile)
17
- assert_equal %w(row1 row2), new.keys.sort
18
- end
19
- end
20
- end
21
-
22
- def test_xlsx
23
- content =<<-EOF
24
- #Id ValueA ValueB OtherID
25
- row1 a|aa|aaa b Id1|Id2
26
- row2 A B Id3
27
- EOF
28
-
29
- TmpFile.with_file(content) do |filename|
30
- tsv = TSV.open(filename, :sep => /\s+/)
31
- TmpFile.with_file(nil, true, :extension => 'xlsx') do |excelfile|
32
- tsv.xlsx(excelfile, :sheet => "Sheet1")
33
- new = TSV.xlsx(excelfile, :sheet => "Sheet1")
34
- assert_equal %w(row1 row2), new.keys.sort
35
- end
36
- end
37
- end
38
-
39
- def test_excel
40
- content =<<-EOF
41
- #Id ValueA ValueB OtherID
42
- row1 a|aa|aaa b Id1|Id2
43
- row2 A B Id3
44
- EOF
45
-
46
- TmpFile.with_file(content) do |filename|
47
- tsv = TSV.open(filename, :sep => /\s+/)
48
- TmpFile.with_file(nil, true, :extension => 'xlsx') do |excelfile|
49
- tsv.xlsx(excelfile, :sheet => "Sheet1")
50
- new = TSV.excel(excelfile, :sheet => "Sheet1")
51
- assert_equal %w(row1 row2), new.keys.sort
52
- new = TSV.xlsx(excelfile, :sheet => "Sheet1")
53
- assert_equal %w(row1 row2), new.keys.sort
54
- end
55
-
56
- TmpFile.with_file(nil, true, :extension => 'xls') do |excelfile|
57
- tsv.xls(excelfile, :sheet => "Sheet1")
58
- new = TSV.excel(excelfile, :sheet => "Sheet1")
59
- assert_equal %w(row1 row2), new.keys.sort
60
- new = TSV.xls(excelfile, :sheet => "Sheet1")
61
- assert_equal %w(row1 row2), new.keys.sort
62
- end
63
- end
64
- end
65
-
66
- def test_excel_sheets
67
- content =<<-EOF
68
- #Id ValueA ValueB OtherID
69
- row1 a|aa|aaa b Id1|Id2
70
- row2 A B Id3
71
- EOF
72
-
73
- TmpFile.with_file(content) do |filename|
74
- tsv = TSV.open(filename, :sep => /\s+/)
75
-
76
- TmpFile.with_file(nil, false, :extension => 'xlsx') do |excelfile|
77
- tsv.xlsx(excelfile)
78
- new = TSV.excel(excelfile)
79
- assert_equal %w(row1 row2), new.keys.sort
80
-
81
- tsv.xlsx(excelfile, :sheet => "Test")
82
- new = TSV.excel(excelfile, :sheet => "Test")
83
- assert_equal %w(row1 row2), new.keys.sort
84
-
85
- tsv.xlsx(excelfile, :sheet => "Test")
86
- new = TSV.excel(excelfile)
87
- assert_equal %w(row1 row2), new.keys.sort
88
-
89
- tsv.xlsx(excelfile)
90
- new = TSV.excel(excelfile, :sheet => "Sheet1")
91
- assert_equal %w(row1 row2), new.keys.sort
92
- end
93
-
94
-
95
- TmpFile.with_file(nil, false, :extension => 'xls') do |excelfile|
96
- tsv.xls(excelfile)
97
- new = TSV.excel(excelfile)
98
- assert_equal %w(row1 row2), new.keys.sort
99
-
100
- tsv.xls(excelfile, :sheet => "Test")
101
- new = TSV.excel(excelfile, :sheet => "Test")
102
- assert_equal %w(row1 row2), new.keys.sort
103
-
104
- tsv.xls(excelfile, :sheet => "Test")
105
- new = TSV.excel(excelfile)
106
- assert_equal %w(row1 row2), new.keys.sort
107
-
108
- tsv.xls(excelfile)
109
- new = TSV.excel(excelfile, :sheet => "Sheet1")
110
- assert_equal %w(row1 row2), new.keys.sort
111
- end
112
- end
113
- end
114
-
115
- def test_excel_unmerge
116
- content =<<-EOF
117
- #Id ValueA ValueB OtherID
118
- row1 a|aa b|bb Id1|Id2
119
- row2 A B Id3
120
- EOF
121
-
122
- TmpFile.with_file(content) do |filename|
123
- tsv = TSV.open(filename, :sep => /\s+/)
124
-
125
- TmpFile.with_file(nil, false, :extension => 'xlsx') do |excelfile|
126
- tsv.xlsx(excelfile, :unmerge => true)
127
-
128
- new = TSV.excel(excelfile, :merge => false)
129
- assert_equal %w(a), new["row1"]["ValueA"]
130
-
131
- new = TSV.excel(excelfile, :merge => true)
132
- assert_equal %w(a aa), new["row1"]["ValueA"]
133
- end
134
- end
135
- end
136
-
137
- def test_excel_multi_sheets
138
- content =<<-EOF
139
- #Id ValueA ValueB OtherID
140
- row1 a|aa|aaa b Id1|Id2
141
- row2 A B Id3
142
- EOF
143
-
144
- TmpFile.with_file(content) do |filename|
145
- tsv1 = TSV.open(filename, :sep => /\s+/)
146
- tsv2 = tsv1.annotate(tsv1.dup)
147
- tsv3 = tsv1.annotate(tsv1.dup)
148
-
149
- tsv2["row2"] = [["AA"], ["BB"], ["Id4"]]
150
- tsv3["row2"] = [["AAA"], ["BBB"], ["Id5"]]
151
-
152
- TmpFile.with_file(nil, false, :extension => 'xlsx') do |excelfile|
153
- tsv1.xlsx(excelfile, :sheet => "S1")
154
- tsv2.xlsx(excelfile, :sheet => "S2", :add_sheet => true)
155
- workbook = RubyXL::Parser.parse excelfile
156
-
157
- assert_equal %w(S1 S2), workbook.worksheets.collect{|s| s.sheet_name}
158
-
159
- new = TSV.excel(excelfile, :sheet => "S1")
160
- assert_equal %w(row1 row2), new.keys.sort
161
- assert_equal %w(A), new["row2"]["ValueA"]
162
-
163
- new = TSV.excel(excelfile, :sheet => "S2")
164
- assert_equal %w(row1 row2), new.keys.sort
165
- assert_equal %w(AA), new["row2"]["ValueA"]
166
-
167
- end
168
- end
169
- end
170
- end
171
-
@@ -1,19 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../../', 'test_helper.rb')
2
- require 'rbbt/tsv'
3
- require 'rbbt/tsv/field_index'
4
-
5
- class TestTSVFieldIndex < Test::Unit::TestCase
6
-
7
- def test_field_index
8
- content =<<-EOF
9
- #Id ValueA ValueB ValueC
10
- rowA A|AA B|BB C|CC
11
- rowa a|aa b|BB C|CC
12
- EOF
13
-
14
- TmpFile.with_file(content) do |filename|
15
- tsv = TSV.open(File.open(filename), :sep => /\s+/, :type => :double)
16
- assert_equal ["rowA"], tsv.field_index("ValueA")["A"]
17
- end
18
- end
19
- end
@@ -1,187 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'test_helper.rb')
2
- require 'rbbt/tsv'
3
- require 'rbbt/tsv/filter'
4
-
5
- class TestTSVFilters < Test::Unit::TestCase
6
- def test_collect
7
- content1 =<<-EOF
8
- #: :sep=/\\s+/#:case_insensitive=false
9
- #Id ValueA ValueB
10
- row1 a|aa|aaa b
11
- row2 A B
12
- EOF
13
-
14
- TmpFile.with_file(content1) do |filename|
15
- tsv = TSV.open filename
16
- tsv.filter
17
- tsv.add_filter "field:ValueA", ["A"]
18
- assert_equal 1, tsv.collect.size
19
- end
20
- end
21
-
22
- def test_through
23
- content1 =<<-EOF
24
- #: :sep=/\\s+/#:case_insensitive=false
25
- #Id ValueA ValueB
26
- row1 a|aa|aaa b
27
- row2 A B
28
- EOF
29
-
30
- TmpFile.with_file(content1) do |filename|
31
- tsv = TSV.open filename
32
- tsv.filter
33
- tsv.add_filter "field:ValueA", ["A"]
34
- elem = []
35
- tsv.through do |k,v| elem << k end
36
- assert_equal 1, elem.size
37
- end
38
- end
39
-
40
- def test_2_filters
41
- content1 =<<-EOF
42
- #: :sep=/\\s+/#:case_insensitive=false
43
- #Id ValueA ValueB
44
- row1 a|aa|aaa b
45
- row2 A B
46
- row3 A C
47
- EOF
48
-
49
- TmpFile.with_file(content1) do |filename|
50
- tsv = TSV.open filename
51
- tsv.filter
52
- tsv.add_filter "field:ValueA", ["A"]
53
-
54
- elem = []
55
- tsv.through do |k,v| elem << k end
56
- assert_equal 2, elem.size
57
- assert_equal ["row2", "row3"], elem.sort
58
-
59
- tsv.add_filter "field:ValueB", ["C"]
60
-
61
- elem = []
62
- tsv.through do |k,v| elem << k end
63
- assert_equal 1, elem.size
64
- end
65
- end
66
-
67
- def test_filter_persistence
68
- content1 =<<-EOF
69
- #: :sep=/\\s+/#:case_insensitive=false
70
- #Id ValueA ValueB
71
- row1 a|aa|aaa b
72
- row2 A B
73
- row3 A C
74
- EOF
75
-
76
- TmpFile.with_file(content1) do |filename|
77
- tsv = TSV.open filename
78
- tsv.filter
79
- tsv.add_filter "field:ValueA", ["A"], Rbbt.tmp.test.Filter.fieldValueA.find(:user)
80
-
81
- elem = []
82
- tsv.through do |k,v| elem << k end
83
- assert_equal 2, elem.size
84
-
85
- tsv.add_filter "field:ValueB", ["C"]
86
-
87
- elem = []
88
- tsv.through do |k,v| elem << k end
89
- assert_equal 1, elem.size
90
-
91
- tsv = TSV.open filename
92
- tsv.filter
93
- tsv.add_filter "field:ValueA", ["A"], Rbbt.tmp.test.Filter.fieldValueA.find(:user)
94
-
95
- elem = []
96
- tsv.through do |k,v| elem << k end
97
- assert_equal 2, elem.size
98
- end
99
- end
100
-
101
- def __test_filter_persistence_update
102
- content1 =<<-EOF
103
- #: :sep=/\\s+/#:case_insensitive=false
104
- #Id ValueA ValueB
105
- row1 a|aa|aaa b
106
- row2 A B
107
- EOF
108
-
109
- TmpFile.with_file(content1) do |filename|
110
- tsv = TSV.open filename
111
- tsv.filter
112
- tsv.add_filter "field:ValueA", ["A"], Rbbt.tmp.test.Filter.fieldValueA.find(:user)
113
-
114
- elem = []
115
- tsv.through do |k,v| elem << k end
116
- assert_equal 1, elem.size
117
-
118
- tsv["row3"] = [["A"], ["C"]]
119
-
120
- elem = []
121
- tsv.through do |k,v| elem << k end
122
- assert_equal 2, elem.size
123
-
124
- tsv.add_filter "field:ValueB", ["C"]
125
-
126
- elem = []
127
- tsv.through do |k,v| elem << k end
128
- assert_equal 1, elem.size
129
-
130
- tsv = TSV.open filename
131
- tsv.filter
132
- tsv.add_filter "field:ValueA", ["A"], Rbbt.tmp.test.Filter.fieldValueA.find(:user)
133
-
134
- elem = []
135
- tsv.through do |k,v| elem << k end
136
- assert_equal 1, elem.size
137
- end
138
- end
139
-
140
- def test_delete
141
- content =<<-EOF
142
- #ID ValueA ValueB Comment
143
- row1 a b c
144
- row2 A B C
145
- EOF
146
-
147
- TmpFile.with_file(content) do |filename|
148
- tsv = TSV.open(File.open(filename), :double, :sep => /\s/)
149
- assert_equal 2, tsv.keys.length
150
- tsv.delete "row2"
151
- assert_equal 1, tsv.keys.length
152
-
153
- tsv = TSV.open(File.open(filename), :double, :sep => /\s/)
154
- tsv.filter
155
- tsv.add_filter "field:ValueA", ["A"]
156
-
157
- assert_equal 1, tsv.keys.length
158
- assert_equal ["row2"], tsv.keys
159
-
160
- tsv.delete "row2"
161
- assert_equal 0, tsv.keys.length
162
-
163
- tsv.pop_filter
164
- assert_equal ["row1"], tsv.keys
165
- end
166
- end
167
-
168
- def test_filename
169
- content1 =<<-EOF
170
- #: :sep=/\\s+/#:case_insensitive=false
171
- #Id ValueA ValueB
172
- row1 a|aa|aaa b
173
- row2 A B
174
- EOF
175
-
176
- TmpFile.with_file(content1) do |filename|
177
- tsv = TSV.open filename
178
- tsv.filter
179
- tsv.add_filter "field:ValueA", ["A"]
180
- assert tsv.filename =~ /ValueA/
181
- tsv.pop_filter
182
- assert tsv.filename !~ /ValueA/
183
- end
184
-
185
- end
186
- end
187
-