rbbt-util 5.43.0 → 5.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/association/util.rb +1 -1
  3. data/lib/rbbt/hpc/batch.rb +19 -17
  4. data/lib/rbbt/tsv/accessor.rb +6 -11
  5. data/lib/rbbt/tsv/dumper.rb +21 -10
  6. data/lib/rbbt/tsv/index.rb +2 -1
  7. data/lib/rbbt/util/misc/math.rb +0 -1
  8. data/lib/rbbt/util/open.rb +1 -1
  9. data/lib/rbbt/workflow/step/info.rb +1 -0
  10. data/lib/rbbt/workflow/step.rb +2 -1
  11. data/python/rbbt/__init__.py +2 -2
  12. data/share/rbbt_commands/workflow/task +1 -1
  13. metadata +4 -220
  14. data/test/rbbt/annotations/test_util.rb +0 -43
  15. data/test/rbbt/association/test_database.rb +0 -87
  16. data/test/rbbt/association/test_index.rb +0 -127
  17. data/test/rbbt/association/test_item.rb +0 -15
  18. data/test/rbbt/association/test_open.rb +0 -63
  19. data/test/rbbt/association/test_util.rb +0 -108
  20. data/test/rbbt/entity/test_identifiers.rb +0 -34
  21. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
  22. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
  23. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
  24. data/test/rbbt/hpc/test_batch.rb +0 -64
  25. data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
  26. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  27. data/test/rbbt/hpc/test_pbs.rb +0 -43
  28. data/test/rbbt/hpc/test_slurm.rb +0 -28
  29. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
  30. data/test/rbbt/knowledge_base/test_entity.rb +0 -62
  31. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  32. data/test/rbbt/knowledge_base/test_registry.rb +0 -74
  33. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  34. data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
  35. data/test/rbbt/persist/test_tsv.rb +0 -88
  36. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  37. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  38. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  39. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
  40. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  41. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  42. data/test/rbbt/resource/test_path.rb +0 -49
  43. data/test/rbbt/test_annotations.rb +0 -167
  44. data/test/rbbt/test_association.rb +0 -103
  45. data/test/rbbt/test_entity.rb +0 -252
  46. data/test/rbbt/test_fix_width_table.rb +0 -135
  47. data/test/rbbt/test_knowledge_base.rb +0 -226
  48. data/test/rbbt/test_monitor.rb +0 -11
  49. data/test/rbbt/test_packed_index.rb +0 -68
  50. data/test/rbbt/test_persist.rb +0 -85
  51. data/test/rbbt/test_resource.rb +0 -110
  52. data/test/rbbt/test_tsv.rb +0 -669
  53. data/test/rbbt/test_workflow.rb +0 -609
  54. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  55. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  56. data/test/rbbt/tsv/test_accessor.rb +0 -319
  57. data/test/rbbt/tsv/test_attach.rb +0 -715
  58. data/test/rbbt/tsv/test_change_id.rb +0 -61
  59. data/test/rbbt/tsv/test_csv.rb +0 -49
  60. data/test/rbbt/tsv/test_excel.rb +0 -171
  61. data/test/rbbt/tsv/test_field_index.rb +0 -19
  62. data/test/rbbt/tsv/test_filter.rb +0 -187
  63. data/test/rbbt/tsv/test_index.rb +0 -308
  64. data/test/rbbt/tsv/test_manipulate.rb +0 -334
  65. data/test/rbbt/tsv/test_marshal.rb +0 -24
  66. data/test/rbbt/tsv/test_matrix.rb +0 -20
  67. data/test/rbbt/tsv/test_parallel.rb +0 -7
  68. data/test/rbbt/tsv/test_parser.rb +0 -101
  69. data/test/rbbt/tsv/test_stream.rb +0 -253
  70. data/test/rbbt/tsv/test_util.rb +0 -52
  71. data/test/rbbt/util/R/test_eval.rb +0 -43
  72. data/test/rbbt/util/R/test_model.rb +0 -128
  73. data/test/rbbt/util/R/test_plot.rb +0 -38
  74. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  75. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  76. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  77. data/test/rbbt/util/log/test_progress.rb +0 -111
  78. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  79. data/test/rbbt/util/misc/test_communication.rb +0 -13
  80. data/test/rbbt/util/misc/test_development.rb +0 -26
  81. data/test/rbbt/util/misc/test_format.rb +0 -10
  82. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  83. data/test/rbbt/util/misc/test_lock.rb +0 -77
  84. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  85. data/test/rbbt/util/misc/test_omics.rb +0 -116
  86. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  87. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  88. data/test/rbbt/util/python/test_util.rb +0 -25
  89. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  90. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  91. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  92. data/test/rbbt/util/test_R.rb +0 -37
  93. data/test/rbbt/util/test_chain_methods.rb +0 -22
  94. data/test/rbbt/util/test_cmd.rb +0 -87
  95. data/test/rbbt/util/test_colorize.rb +0 -22
  96. data/test/rbbt/util/test_concurrency.rb +0 -6
  97. data/test/rbbt/util/test_config.rb +0 -69
  98. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  99. data/test/rbbt/util/test_filecache.rb +0 -36
  100. data/test/rbbt/util/test_log.rb +0 -52
  101. data/test/rbbt/util/test_migrate.rb +0 -34
  102. data/test/rbbt/util/test_misc.rb +0 -728
  103. data/test/rbbt/util/test_open.rb +0 -200
  104. data/test/rbbt/util/test_procpath.rb +0 -23
  105. data/test/rbbt/util/test_python.rb +0 -144
  106. data/test/rbbt/util/test_semaphore.rb +0 -36
  107. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  108. data/test/rbbt/util/test_simpleopt.rb +0 -11
  109. data/test/rbbt/util/test_ssh.rb +0 -10
  110. data/test/rbbt/util/test_tmpfile.rb +0 -32
  111. data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
  112. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  113. data/test/rbbt/workflow/test_doc.rb +0 -30
  114. data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
  115. data/test/rbbt/workflow/test_schedule.rb +0 -0
  116. data/test/rbbt/workflow/test_step.rb +0 -231
  117. data/test/rbbt/workflow/test_task.rb +0 -85
  118. data/test/rbbt/workflow/util/test_archive.rb +0 -27
  119. data/test/rbbt/workflow/util/test_data.rb +0 -67
  120. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
  121. data/test/test_helper.rb +0 -114
@@ -1,167 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
- require 'rbbt/annotations'
3
- require 'rbbt/util/tmpfile'
4
- require 'test/unit'
5
-
6
- module AnnotatedString
7
- extend Annotation
8
- self.annotation :annotation_str
9
-
10
- def add_annot
11
- self + annotation_str
12
- end
13
- end
14
-
15
- module AnnotatedString2
16
- extend Annotation
17
- include AnnotatedString
18
- self.annotation :annotation_str2
19
- end
20
-
21
- class TestAnnotations < Test::Unit::TestCase
22
-
23
- def test_annotated_string
24
- assert_equal %w(annotation_str), AnnotatedString.annotations.collect{|a| a.to_s}
25
- end
26
-
27
- def test_string
28
- str = "string"
29
- annotation_str = "Annotation String"
30
- AnnotatedString.setup(str, annotation_str)
31
- assert_equal [AnnotatedString], str.annotation_types
32
- assert_equal annotation_str, str.annotation_str
33
- end
34
-
35
- def test_array
36
- ary = ["string"]
37
- annotation_str = "Annotation String"
38
- ary.extend AnnotatedArray
39
- AnnotatedString.setup(ary, annotation_str)
40
- assert_equal [AnnotatedString], ary.annotation_types
41
- assert_equal annotation_str, ary.annotation_str
42
- assert_equal annotation_str, ary[0].annotation_str
43
- end
44
-
45
-
46
- def test_info
47
- ary = ["string"]
48
- annotation_str = "Annotation String"
49
- AnnotatedString.setup(ary, annotation_str)
50
-
51
- assert_equal({:annotation_str => annotation_str, :annotation_types => [AnnotatedString], :annotated_array => true}, ary.info)
52
- end
53
-
54
- def test_load
55
- str = "string"
56
- annotation_str = "Annotation String"
57
- info = {:annotation_str => annotation_str, :annotation_types => [AnnotatedString]}
58
-
59
- Annotated.load_entity(str, info)
60
- assert_equal annotation_str, str.annotation_str
61
- end
62
-
63
- def test_json
64
- str1 = "string1"
65
- annotation_str1 = "Annotation String 1"
66
- str2 = "string2"
67
- annotation_str2 = "Annotation String 2"
68
- AnnotatedString.setup(str1, annotation_str1)
69
- AnnotatedString.setup(str2, annotation_str2)
70
- end
71
-
72
- def test_tsv
73
- str1 = "string1"
74
- annotation_str1 = "Annotation String 1"
75
- str2 = "string2"
76
- annotation_str2 = "Annotation String 2"
77
- AnnotatedString.setup(str1, annotation_str1)
78
- AnnotatedString.setup(str2, annotation_str2)
79
-
80
- assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["literal"]
81
- assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
82
- assert_equal str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["literal"]
83
- assert_equal annotation_str1, Annotated.tsv([str1, str2], :all).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
84
- assert_equal annotation_str1, Annotated.tsv([str1, str2], :annotation_str, :JSON).tap{|t| t.unnamed = false}[str1.id + "#0"]["annotation_str"]
85
- end
86
-
87
- def test_literal
88
- str = "string"
89
- annotation_str = "Annotation String"
90
- AnnotatedString.setup(str, annotation_str)
91
- assert_equal ["string"], str.tsv_values("literal")
92
- end
93
-
94
- def test_load_tsv
95
- str1 = "string1"
96
- annotation_str1 = "Annotation String 1"
97
- str2 = "string2"
98
- annotation_str2 = "Annotation String 2"
99
- AnnotatedString.setup(str1, annotation_str1)
100
- AnnotatedString.setup(str2, annotation_str2)
101
- assert_equal annotation_str1, Annotated.load_tsv(Annotated.tsv([str1, str2], :all)).sort.first.annotation_str
102
- assert_equal str1, Annotated.load_tsv(Annotated.tsv([str1, str2], :literal, :JSON)).sort.first
103
- end
104
-
105
- def test_load_array_tsv
106
- str1 = "string1"
107
- str2 = "string2"
108
- a = [str1, str2]
109
- annotation_str = "Annotation String 2"
110
- AnnotatedString.setup(a, annotation_str)
111
- a.extend AnnotatedArray
112
-
113
-
114
- assert_equal annotation_str, Annotated.load_tsv(Annotated.tsv(a, :all)).annotation_str
115
-
116
- assert_equal str2, Annotated.load_tsv(Annotated.tsv(a, :literal, :JSON)).sort.last
117
- end
118
-
119
- def test_inheritance
120
- str = "string1"
121
- annotation_str1 = "Annotation String 1"
122
- annotation_str2 = "Annotation String 2"
123
- AnnotatedString2.setup(str, annotation_str1, annotation_str2)
124
- assert_equal annotation_str1, str.annotation_str
125
- assert_equal annotation_str2, str.annotation_str2
126
- end
127
-
128
- def test_annotation_methods
129
- str = "string"
130
- annotation_str = "Annotation String"
131
- AnnotatedString.setup(str, annotation_str)
132
- assert_equal str + annotation_str, str.add_annot
133
- end
134
-
135
- def test_double_array_1
136
- ary = ["string"]
137
- annotation_str = "Annotation String"
138
- ary.extend AnnotatedArray
139
- ary_ary = [ary]
140
- ary_ary.extend AnnotatedArray
141
- AnnotatedString.setup(ary, annotation_str)
142
- AnnotatedString.setup(ary_ary, annotation_str)
143
- assert_equal [AnnotatedString], ary.annotation_types
144
- assert_equal annotation_str, ary.annotation_str
145
- assert_equal annotation_str, ary[0].annotation_str
146
- end
147
-
148
- def test_double_array_2
149
- a = ["a"]
150
- b = AnnotatedString.setup([AnnotatedString.setup(["a"])])
151
- AnnotatedString.setup(a)
152
- a.extend AnnotatedArray
153
- assert AnnotatedString === b[0]
154
- b.extend AnnotatedArray
155
- assert AnnotatedString === b[0, true]
156
- assert(!a.double_array)
157
- assert(b.double_array)
158
- end
159
-
160
- def test_annotation_positional2hash
161
- str = "string"
162
- annotation_str = "Annotation String"
163
- AnnotatedString.setup(str, :annotation_str => annotation_str)
164
- assert_equal str + annotation_str, str.add_annot
165
- end
166
-
167
- end
@@ -1,103 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
- require 'rbbt/util/tmpfile'
3
- require 'test/unit'
4
-
5
- require 'rbbt/workflow'
6
- require 'rbbt/entity'
7
-
8
- require 'rbbt/association'
9
- require 'rbbt/association/open'
10
- require 'rbbt/knowledge_base'
11
- require 'rbbt/entity'
12
-
13
-
14
- TEST_ASSOCIATIONS =<<-EOF
15
- #: :sep=" "#:namespace=Hsa/jan2013
16
- #Entity1 Entity2 Score Entity3 Gene
17
- a A 1 aa TP53
18
- b B 2 bb KRAS
19
- c C|K 3|4 cc|kk PTEN|PTEN
20
- EOF
21
-
22
- class TestAssociations < Test::Unit::TestCase
23
-
24
- FAssocs = ""
25
- DAssocs = ""
26
-
27
- def setup
28
- FAssocs.replace TmpFile.tmp_file
29
- DAssocs.replace TmpFile.tmp_file
30
- Open.write(FAssocs, TEST_ASSOCIATIONS)
31
- end
32
-
33
- def teardown
34
- FileUtils.rm FAssocs
35
- FileUtils.rm_rf DAssocs
36
- end
37
-
38
- def test_simple_open
39
- database = Association.open(FAssocs, {}, :dir => DAssocs)
40
- database.unnamed = false
41
- assert_equal ["C", "K"], database["c"]["Entity2"]
42
- end
43
-
44
- def test_source_open
45
- database = Association.open(FAssocs, {:source => "Entity2", :zipped => true}, :dir => DAssocs)
46
- assert_equal ["c", "3", 'cc', "PTEN"], database["C"].flatten
47
- assert_equal ["c", "4", 'kk', "PTEN"], database["K"].flatten
48
- end
49
-
50
- def test_target_open
51
- database = Association.open(FAssocs, {:source => "Entity2", :target => "Entity3", :zipped => true}, :dir => DAssocs)
52
- assert_equal ["cc", "c", "3", "PTEN"], database["C"].flatten
53
- assert_equal ["kk", "c", "4", "PTEN"], database["K"].flatten
54
- end
55
-
56
-
57
- def test_gene_open
58
- database = Association.open(FAssocs, {:source => "Gene=~Associated Gene Name", :target => "Entity3", :zipped => true}, :dir => DAssocs)
59
- assert_equal ["aa"], database["TP53"].first
60
- end
61
-
62
-
63
- def __test_ICGC
64
- assoc = Association.open(Open.open('ftp://data.dcc.icgc.org/current/Chronic_Lymphocytic_Leukemia-ISC_MICINN-ES/simple_somatic_mutation.CLLE-ES.tsv.gz'),
65
- { :source => "gene_affected=~Ensembl Gene ID=>Associated Gene Name", :target => "icgc_donor_id=~Sample",
66
- :fields => ['consequence_type'],
67
- :namespace => 'Hsa/jan2013',
68
- :merge => true, :header_hash=>''}, :persist => false)
69
-
70
- assert_equal 9, assoc["SF3B1"]["Sample"].uniq.length
71
- end
72
-
73
- def __test_target_open
74
-
75
- database = Association.open(Pina.protein_protein,{
76
- :undirected => false,
77
- :target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession"}, :persist => false)
78
-
79
- assert( ! database["Q13547"][0].include?("O15379"))
80
-
81
- database = Association.open(Pina.protein_protein,{
82
- :undirected => true,
83
- :target => "Interactor UniProt/SwissProt Accession=~UniProt/SwissProt Accession"}, :persist => false)
84
-
85
- assert database["O15379"][0].include? "Q13547"
86
-
87
- assert database["Q13547"][0].include? "O15379"
88
- end
89
-
90
- def __test_gene_open_translate
91
- tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013")
92
- database = Association.open(FAssocs, {:source => "Gene=~Associated Gene Name", :source_format => "Ensembl Gene ID", :target => "Entity3", :zipped => true}, :dir => DAssocs)
93
- assert_equal ["aa"], database[tp53.ensembl].first
94
- end
95
-
96
- def __test_gene_target_open_translate
97
- tp53 = Gene.setup("TP53", "Associated Gene Name", "Hsa/jan2013")
98
- database = Association.open(FAssocs, {:target => "Gene=~Associated Gene Name=>Ensembl Gene ID", :source => "Entity3", :zipped => true}, :dir => DAssocs)
99
- assert_equal [tp53.ensembl], database["aa"].first
100
- end
101
-
102
-
103
- end
@@ -1,252 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
- require 'rbbt'
3
- require 'rbbt/entity'
4
- require 'rbbt/util/tmpfile'
5
- require 'test/unit'
6
-
7
- class TestA
8
- attr_accessor :foo, :bar
9
- def initialize(foo, bar)
10
- @foo = foo
11
- @bar = bar
12
- end
13
- end
14
-
15
- Entity.entity_property_cache = Rbbt.tmp.test.entity_property.find
16
- module ReversableString
17
- extend Entity
18
-
19
- self.annotation :foo, :bar
20
-
21
- property :reverse_text_ary => :array do
22
- $count += 1
23
- self.collect{|s| s.reverse}
24
- end
25
-
26
- property :reverse_text_single => :single do
27
- $count += 1
28
- self.reverse
29
- end
30
-
31
- property :reverse_text_ary_p => :array2single do
32
- $count += 1
33
- self.collect{|s| s.reverse}
34
- end
35
-
36
- property :reverse_text_single_p => :single do
37
- $count += 1
38
- self.reverse
39
- end
40
-
41
- property :reverse_text_ary_p_array => :array do
42
- $count += 1
43
- self.collect{|s| s.reverse}
44
- end
45
-
46
- property :random => :single do
47
- rand
48
- end
49
-
50
- property :annotation_list => :single do
51
- self.chars.to_a.collect{|c|
52
- ReversableString.setup(c)
53
- }
54
- end
55
-
56
- persist :reverse_text_ary_p, :marshal
57
- #persist :reverse_text_single_p, :memory
58
-
59
- persist :reverse_text_ary_p_array, :array, :dir => TmpFile.tmp_file
60
-
61
- persist :annotation_list, :annotations, :dir => TmpFile.tmp_file
62
-
63
-
64
- $processed_multiple = []
65
- property :multiple_annotation_list => :multiple do |list|
66
- $processed_multiple.concat list
67
- res = {}
68
- list.collect do |e|
69
- e.chars.to_a.collect{|c|
70
- ReversableString.setup(c)
71
- }
72
- end
73
- end
74
-
75
- persist :multiple_annotation_list, :annotations, :dir => TmpFile.tmp_file
76
- #persist :multiple_annotation_list, :annotations, :dir => Rbbt.tmp.test.annots
77
- end
78
-
79
- class TestEntity < Test::Unit::TestCase
80
-
81
- def test_property_ary
82
- a = ["String1", "String2"]
83
- ReversableString.setup(a)
84
-
85
- $count = 0
86
-
87
- assert_equal "2gnirtS", a.reverse_text_ary.last
88
- assert_equal 1, $count
89
- a._ary_property_cache.clear
90
- assert_equal "2gnirtS", a[1].reverse_text_ary
91
- assert_equal 2, $count
92
- a._ary_property_cache.clear
93
-
94
- $count = 0
95
- a.each do |string|
96
- string.reverse_text_ary
97
- assert_equal 1, $count
98
- end
99
- end
100
-
101
- def test_property_single
102
- a = ["String1", "String2"]
103
- ReversableString.setup a
104
-
105
- $count = 0
106
-
107
- assert_equal "2gnirtS", a.reverse_text_single.last
108
- assert_equal 2, $count
109
- assert_equal "2gnirtS", a[1].reverse_text_single
110
- assert_equal 3, $count
111
- end
112
-
113
- def test_property_ary_p
114
- a = ["String1", "String2"]
115
- ReversableString.setup a
116
-
117
- a.reverse_text_ary_p
118
-
119
- $count = 0
120
-
121
- assert_equal "2gnirtS", a.reverse_text_ary_p.last
122
- assert_equal "2gnirtS", a.collect{|e| e.reverse_text_ary_p }[1]
123
- assert_equal 0, $count
124
- end
125
-
126
- def test_property_single_p
127
- a = ["String1", "String2"]
128
- ReversableString.setup a
129
-
130
- $count = 0
131
-
132
- assert_equal "2gnirtS", a.reverse_text_single_p.last
133
-
134
- assert_equal 2, $count
135
-
136
- a = ["String1", "String2"]
137
- ReversableString.setup a
138
-
139
- $count = 0
140
-
141
- assert_equal "2gnirtS", a.reverse_text_single_p.last
142
- assert_equal 2, $count
143
- assert_equal "2gnirtS", a[1].reverse_text_single_p
144
- assert_equal 3, $count
145
- end
146
-
147
- def test_property_ary_p_array
148
- a = ["String1", "String2"]
149
- ReversableString.setup a
150
-
151
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
152
-
153
- $count = 0
154
-
155
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
156
- assert_equal 0, $count
157
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
158
- assert_equal 0, $count
159
- end
160
-
161
- def test_unpersist
162
- a = ["String1", "String2"]
163
- ReversableString.setup a
164
-
165
- # Before persist
166
- assert(! ReversableString.persisted?(:random))
167
-
168
- r1 = a.random
169
- r2 = a.random
170
- assert_not_equal r1, r2
171
-
172
- # After persist
173
- ReversableString.persist :random
174
- assert ReversableString.persisted?(:random)
175
-
176
- r1 = a.random
177
- r2 = a.random
178
- assert_equal r1, r2
179
-
180
- # After unpersist
181
- ReversableString.unpersist :random
182
- refute ReversableString.persisted?(:random)
183
-
184
- r1 = a.random
185
- r2 = a.random
186
- assert_not_equal r1, r2
187
-
188
- end
189
-
190
- def test_persist_annotations
191
- string = 'aaabbbccc'
192
- ReversableString.setup(string)
193
- assert_equal string.length, string.annotation_list.length
194
- assert_equal string.length, string.annotation_list.length
195
- end
196
-
197
- def test_persist_multiple_annotations
198
- string1 = 'aaabbbccc'
199
- string2 = 'AAABBBCCC'
200
- string3 = 'AAABBBCCC_3'
201
- string4 = 'AAABBBCCC_4'
202
-
203
-
204
- $processed_multiple = []
205
-
206
- array = ReversableString.setup([string1, string2])
207
- assert_equal [string1, string2].collect{|s| s.chars}, array.multiple_annotation_list
208
- assert_equal string1.length, array[0].multiple_annotation_list.length
209
- assert_equal $processed_multiple, [string1, string2]
210
-
211
- array = ReversableString.setup([string2, string3])
212
- assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
213
- assert_equal string3, array.multiple_annotation_list.last * ""
214
- assert_equal $processed_multiple, [string1, string2, string3]
215
-
216
- $processed_multiple = []
217
- array = ReversableString.setup([string2, string3])
218
- assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
219
- assert_equal string2.length, array[0].multiple_annotation_list.length
220
- assert_equal $processed_multiple, []
221
-
222
- $processed_multiple = []
223
- array = ReversableString.setup([string2, string3, string4])
224
- assert_equal string2.length, array.multiple_annotation_list[0].length
225
- assert_equal $processed_multiple, [string4]
226
-
227
- string1 = 'aaabbbccc'
228
- string2 = 'AAABBBCCC'
229
- string3 = 'AAABBBCCC_3'
230
- string4 = 'AAABBBCCC_4'
231
-
232
- $processed_multiple = []
233
- array = ReversableString.setup([string2, string3, string4])
234
- assert_equal string2.length, array[0].multiple_annotation_list.length
235
- assert_equal $processed_multiple, []
236
-
237
- end
238
-
239
- def test_clean_annotations
240
-
241
- string = "test_string"
242
- ReversableString.setup string
243
- assert string.respond_to?(:reverse_text_single)
244
- assert ! string.clean_annotations.respond_to?(:reverse_text_single)
245
-
246
- end
247
-
248
- def test_all_properties
249
- assert ReversableString.setup("TEST").all_properties.include?("reverse_text_ary")
250
- assert_equal ReversableString.setup("TEST").all_properties, ReversableString.all_properties
251
- end
252
- end
@@ -1,135 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '../', 'test_helper.rb')
2
- require 'rbbt/fix_width_table'
3
- require 'rbbt/tsv'
4
- require 'rbbt/tsv/manipulate'
5
-
6
- class TestFixWidthTable < Test::Unit::TestCase
7
- def load_data(data)
8
- tsv = TSV.open(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 = tsv.slice ["Start", "End"]
17
-
18
- tsv
19
- end
20
-
21
- def test_options
22
- TmpFile.with_file do |filename|
23
- f = FixWidthTable.new filename, 100, true
24
- f.close
25
-
26
- f1 = FixWidthTable.new filename, 100, false
27
-
28
- assert_equal true, f1.range
29
- end
30
- end
31
-
32
- def test_add
33
- TmpFile.with_file do |filename|
34
- f = FixWidthTable.new filename, 100, true
35
- f.add [1,2,0], "test1"
36
- f.add [3,4,0], "test2"
37
- f.read
38
-
39
- assert_equal 1, f.idx_pos(0)
40
- assert_equal 3, f.idx_pos(1)
41
- assert_equal 2, f.idx_pos_end(0)
42
- assert_equal 4, f.idx_pos_end(1)
43
- assert_equal 0, f.idx_overlap(0)
44
- assert_equal 0, f.idx_overlap(1)
45
- assert_equal "test1", f.idx_value(0)
46
- assert_equal "test2", f.idx_value(1)
47
-
48
- end
49
-
50
- end
51
-
52
- def test_point
53
- data =<<-EOF
54
- #: :sep=/\\s+/#:type=:single#:cast=:to_i
55
- #ID Pos
56
- a 1
57
- b 10
58
- c 20
59
- d 12
60
- e 26
61
- f 11
62
- g 25
63
- EOF
64
- TmpFile.with_file(data) do |datafile|
65
- tsv = TSV.open datafile
66
- TmpFile.with_file do |filename|
67
- f = FixWidthTable.new filename, 100, false
68
- f.add_point tsv
69
- f.read
70
-
71
- assert_equal %w(), f[0].sort
72
- assert_equal %w(b), f[10].sort
73
- assert_equal %w(a b c d f), f[(0..20)].sort
74
- end
75
- end
76
- end
77
-
78
- def test_range
79
- data =<<-EOF
80
- ##012345678901234567890
81
- #ID:Range
82
- a: ______
83
- b: ______
84
- c: _______
85
- d: ____
86
- e: ______
87
- f: ___
88
- g: ____
89
- EOF
90
- TmpFile.with_file(data) do |datafile|
91
- tsv = load_data(datafile)
92
- TmpFile.with_file do |filename|
93
- f = FixWidthTable.new filename, 100, true
94
- f.add_range tsv
95
- f.read
96
-
97
- assert_equal %w(), f[0].sort
98
- assert_equal %w(b), f[1].sort
99
- assert_equal %w(), f[20].sort
100
- assert_equal %w(), f[(20..100)].sort
101
- assert_equal %w(a b d), f[3].sort
102
- assert_equal %w(a b c d e), f[(3..4)].sort
103
- assert_equal %w(a c e), f[7].sort
104
- end
105
- end
106
- end
107
-
108
-
109
- def test_range_pos
110
- data =<<-EOF
111
- ##012345678901234567890
112
- #ID:Range
113
- a: ______
114
- b: ______
115
- c: _______
116
- d: ____
117
- e: ______
118
- f: ___
119
- g: ____
120
- EOF
121
- TmpFile.with_file(data) do |datafile|
122
- tsv = load_data(datafile)
123
- TmpFile.with_file do |filename|
124
- f = FixWidthTable.new filename, 100, true
125
- f.add_range tsv
126
- f.read
127
-
128
- assert_equal %w(), f.overlaps(0).sort
129
- assert_equal %w(1:6), f.overlaps(1).sort
130
- assert_equal %w(1:6:b), f.overlaps(1, true).sort
131
- end
132
- end
133
- end
134
- end
135
-