rbbt-util 5.42.0 → 5.44.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/annotations/util.rb +1 -1
  3. data/lib/rbbt/association/database.rb +2 -1
  4. data/lib/rbbt/association/index.rb +1 -0
  5. data/lib/rbbt/association/util.rb +14 -4
  6. data/lib/rbbt/entity.rb +6 -5
  7. data/lib/rbbt/hpc/batch.rb +19 -17
  8. data/lib/rbbt/hpc/orchestrate/batches.rb +1 -1
  9. data/lib/rbbt/hpc/orchestrate/chains.rb +3 -4
  10. data/lib/rbbt/knowledge_base/traverse.rb +24 -16
  11. data/lib/rbbt/persist/tsv/tokyocabinet.rb +1 -1
  12. data/lib/rbbt/resource/path.rb +7 -2
  13. data/lib/rbbt/resource.rb +1 -1
  14. data/lib/rbbt/tsv/accessor.rb +6 -11
  15. data/lib/rbbt/tsv/dumper.rb +21 -10
  16. data/lib/rbbt/tsv/index.rb +2 -1
  17. data/lib/rbbt/tsv/parallel/traverse.rb +44 -0
  18. data/lib/rbbt/tsv/parser.rb +7 -6
  19. data/lib/rbbt/tsv/serializers.rb +1 -1
  20. data/lib/rbbt/tsv/util.rb +12 -0
  21. data/lib/rbbt/util/log/progress.rb +1 -1
  22. data/lib/rbbt/util/misc/bgzf.rb +5 -4
  23. data/lib/rbbt/util/misc/development.rb +4 -4
  24. data/lib/rbbt/util/misc/math.rb +0 -1
  25. data/lib/rbbt/util/misc.rb +1 -1
  26. data/lib/rbbt/util/open.rb +1 -1
  27. data/lib/rbbt/workflow/remote_workflow/driver/rest.rb +8 -3
  28. data/lib/rbbt/workflow/remote_workflow/remote_step.rb +4 -0
  29. data/lib/rbbt/workflow/step/info.rb +1 -0
  30. data/lib/rbbt/workflow/step.rb +2 -1
  31. data/lib/rbbt/workflow/util/trace.rb +2 -2
  32. data/lib/rbbt/workflow.rb +2 -2
  33. data/python/rbbt/__init__.py +2 -2
  34. data/share/rbbt_commands/workflow/task +1 -1
  35. metadata +4 -220
  36. data/test/rbbt/annotations/test_util.rb +0 -43
  37. data/test/rbbt/association/test_database.rb +0 -89
  38. data/test/rbbt/association/test_index.rb +0 -127
  39. data/test/rbbt/association/test_item.rb +0 -15
  40. data/test/rbbt/association/test_open.rb +0 -63
  41. data/test/rbbt/association/test_util.rb +0 -108
  42. data/test/rbbt/entity/test_identifiers.rb +0 -74
  43. data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -113
  44. data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -139
  45. data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -92
  46. data/test/rbbt/hpc/test_batch.rb +0 -68
  47. data/test/rbbt/hpc/test_orchestrate.rb +0 -144
  48. data/test/rbbt/hpc/test_pbs.rb +0 -43
  49. data/test/rbbt/hpc/test_slurm.rb +0 -32
  50. data/test/rbbt/knowledge_base/test_enrichment.rb +0 -48
  51. data/test/rbbt/knowledge_base/test_entity.rb +0 -42
  52. data/test/rbbt/knowledge_base/test_query.rb +0 -46
  53. data/test/rbbt/knowledge_base/test_registry.rb +0 -81
  54. data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
  55. data/test/rbbt/knowledge_base/test_traverse.rb +0 -85
  56. data/test/rbbt/persist/test_tsv.rb +0 -88
  57. data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
  58. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
  59. data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
  60. data/test/rbbt/persist/tsv/test_lmdb.rb +0 -18
  61. data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
  62. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
  63. data/test/rbbt/resource/test_path.rb +0 -49
  64. data/test/rbbt/test_annotations.rb +0 -167
  65. data/test/rbbt/test_association.rb +0 -103
  66. data/test/rbbt/test_entity.rb +0 -249
  67. data/test/rbbt/test_fix_width_table.rb +0 -135
  68. data/test/rbbt/test_hpc.rb +0 -16
  69. data/test/rbbt/test_knowledge_base.rb +0 -149
  70. data/test/rbbt/test_monitor.rb +0 -11
  71. data/test/rbbt/test_packed_index.rb +0 -68
  72. data/test/rbbt/test_persist.rb +0 -85
  73. data/test/rbbt/test_resource.rb +0 -110
  74. data/test/rbbt/test_tsv.rb +0 -669
  75. data/test/rbbt/test_workflow.rb +0 -604
  76. data/test/rbbt/tsv/parallel/test_through.rb +0 -40
  77. data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
  78. data/test/rbbt/tsv/test_accessor.rb +0 -315
  79. data/test/rbbt/tsv/test_attach.rb +0 -718
  80. data/test/rbbt/tsv/test_change_id.rb +0 -61
  81. data/test/rbbt/tsv/test_csv.rb +0 -49
  82. data/test/rbbt/tsv/test_excel.rb +0 -171
  83. data/test/rbbt/tsv/test_field_index.rb +0 -19
  84. data/test/rbbt/tsv/test_filter.rb +0 -187
  85. data/test/rbbt/tsv/test_index.rb +0 -302
  86. data/test/rbbt/tsv/test_manipulate.rb +0 -337
  87. data/test/rbbt/tsv/test_marshal.rb +0 -24
  88. data/test/rbbt/tsv/test_matrix.rb +0 -20
  89. data/test/rbbt/tsv/test_parallel.rb +0 -7
  90. data/test/rbbt/tsv/test_parser.rb +0 -101
  91. data/test/rbbt/tsv/test_stream.rb +0 -253
  92. data/test/rbbt/tsv/test_util.rb +0 -52
  93. data/test/rbbt/util/R/test_eval.rb +0 -43
  94. data/test/rbbt/util/R/test_model.rb +0 -130
  95. data/test/rbbt/util/R/test_plot.rb +0 -38
  96. data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
  97. data/test/rbbt/util/concurrency/test_processes.rb +0 -192
  98. data/test/rbbt/util/concurrency/test_threads.rb +0 -40
  99. data/test/rbbt/util/log/test_progress.rb +0 -111
  100. data/test/rbbt/util/misc/test_bgzf.rb +0 -48
  101. data/test/rbbt/util/misc/test_communication.rb +0 -11
  102. data/test/rbbt/util/misc/test_development.rb +0 -26
  103. data/test/rbbt/util/misc/test_format.rb +0 -10
  104. data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
  105. data/test/rbbt/util/misc/test_lock.rb +0 -77
  106. data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
  107. data/test/rbbt/util/misc/test_omics.rb +0 -116
  108. data/test/rbbt/util/misc/test_pipes.rb +0 -343
  109. data/test/rbbt/util/misc/test_serialize.rb +0 -24
  110. data/test/rbbt/util/python/test_util.rb +0 -25
  111. data/test/rbbt/util/simpleopt/test_get.rb +0 -12
  112. data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
  113. data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
  114. data/test/rbbt/util/test_R.rb +0 -37
  115. data/test/rbbt/util/test_chain_methods.rb +0 -22
  116. data/test/rbbt/util/test_cmd.rb +0 -87
  117. data/test/rbbt/util/test_colorize.rb +0 -22
  118. data/test/rbbt/util/test_concurrency.rb +0 -6
  119. data/test/rbbt/util/test_config.rb +0 -69
  120. data/test/rbbt/util/test_excel2tsv.rb +0 -10
  121. data/test/rbbt/util/test_filecache.rb +0 -36
  122. data/test/rbbt/util/test_log.rb +0 -52
  123. data/test/rbbt/util/test_migrate.rb +0 -36
  124. data/test/rbbt/util/test_misc.rb +0 -723
  125. data/test/rbbt/util/test_open.rb +0 -200
  126. data/test/rbbt/util/test_procpath.rb +0 -23
  127. data/test/rbbt/util/test_python.rb +0 -140
  128. data/test/rbbt/util/test_semaphore.rb +0 -36
  129. data/test/rbbt/util/test_simpleDSL.rb +0 -55
  130. data/test/rbbt/util/test_simpleopt.rb +0 -11
  131. data/test/rbbt/util/test_ssh.rb +0 -10
  132. data/test/rbbt/util/test_tmpfile.rb +0 -32
  133. data/test/rbbt/workflow/step/test_dependencies.rb +0 -299
  134. data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
  135. data/test/rbbt/workflow/test_doc.rb +0 -30
  136. data/test/rbbt/workflow/test_remote_workflow.rb +0 -98
  137. data/test/rbbt/workflow/test_schedule.rb +0 -0
  138. data/test/rbbt/workflow/test_step.rb +0 -231
  139. data/test/rbbt/workflow/test_task.rb +0 -85
  140. data/test/rbbt/workflow/util/test_archive.rb +0 -31
  141. data/test/rbbt/workflow/util/test_data.rb +0 -67
  142. data/test/rbbt/workflow/util/test_orchestrator.rb +0 -273
  143. data/test/test_helper.rb +0 -90
@@ -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,249 +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
- $count = 0
137
-
138
- assert_equal "2gnirtS", a.reverse_text_single_p.last
139
- assert_equal 0, $count
140
- assert_equal "2gnirtS", a[1].reverse_text_single_p
141
- assert_equal 1, $count
142
- end
143
-
144
- def test_property_ary_p_array
145
- a = ["String1", "String2"]
146
- ReversableString.setup a
147
-
148
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
149
-
150
- $count = 0
151
-
152
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
153
- assert_equal 0, $count
154
- assert_equal "2gnirtS", a.reverse_text_ary_p_array.last
155
- assert_equal 0, $count
156
- end
157
-
158
- def test_unpersist
159
- a = ["String1", "String2"]
160
- ReversableString.setup a
161
-
162
- # Before persist
163
- assert(! ReversableString.persisted?(:random))
164
-
165
- r1 = a.random
166
- r2 = a.random
167
- assert_not_equal r1, r2
168
-
169
- # After persist
170
- ReversableString.persist :random
171
- assert(ReversableString.persisted?(:random))
172
-
173
- r1 = a.random
174
- r2 = a.random
175
- assert_equal r1, r2
176
-
177
- # After unpersist
178
- ReversableString.unpersist :random
179
- assert(! ReversableString.persisted?(:random))
180
-
181
- r1 = a.random
182
- r2 = a.random
183
- assert_not_equal r1, r2
184
-
185
- end
186
-
187
- def test_persist_annotations
188
- string = 'aaabbbccc'
189
- ReversableString.setup(string)
190
- assert_equal string.length, string.annotation_list.length
191
- assert_equal string.length, string.annotation_list.length
192
- end
193
-
194
- def test_persist_multiple_annotations
195
- string1 = 'aaabbbccc'
196
- string2 = 'AAABBBCCC'
197
- string3 = 'AAABBBCCC_3'
198
- string4 = 'AAABBBCCC_4'
199
-
200
-
201
- $processed_multiple = []
202
-
203
- array = ReversableString.setup([string1, string2])
204
- assert_equal [string1, string2].collect{|s| s.chars}, array.multiple_annotation_list
205
- assert_equal string1.length, array[0].multiple_annotation_list.length
206
- assert_equal $processed_multiple, [string1, string2]
207
-
208
- array = ReversableString.setup([string2, string3])
209
- assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
210
- assert_equal string3, array.multiple_annotation_list.last * ""
211
- assert_equal $processed_multiple, [string1, string2, string3]
212
-
213
- $processed_multiple = []
214
- array = ReversableString.setup([string2, string3])
215
- assert_equal [string2, string3].collect{|s| s.chars}, array.multiple_annotation_list
216
- assert_equal string2.length, array[0].multiple_annotation_list.length
217
- assert_equal $processed_multiple, []
218
-
219
- $processed_multiple = []
220
- array = ReversableString.setup([string2, string3, string4])
221
- assert_equal string2.length, array.multiple_annotation_list[0].length
222
- assert_equal $processed_multiple, [string4]
223
-
224
- string1 = 'aaabbbccc'
225
- string2 = 'AAABBBCCC'
226
- string3 = 'AAABBBCCC_3'
227
- string4 = 'AAABBBCCC_4'
228
-
229
- $processed_multiple = []
230
- array = ReversableString.setup([string2, string3, string4])
231
- assert_equal string2.length, array[0].multiple_annotation_list.length
232
- assert_equal $processed_multiple, []
233
-
234
- end
235
-
236
- def test_clean_annotations
237
-
238
- string = "test_string"
239
- ReversableString.setup string
240
- assert string.respond_to?(:reverse_text_single)
241
- assert ! string.clean_annotations.respond_to?(:reverse_text_single)
242
-
243
- end
244
-
245
- def test_all_properties
246
- assert ReversableString.setup("TEST").all_properties.include?("reverse_text_ary")
247
- assert_equal ReversableString.setup("TEST").all_properties, ReversableString.all_properties
248
- end
249
- 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
-
@@ -1,16 +0,0 @@
1
- require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'test_helper.rb')
2
- require 'rbbt/hpc'
3
- require 'rbbt/workflow'
4
-
5
-
6
- class TestHPC < Test::Unit::TestCase
7
- def test_relay
8
-
9
- Log.severity = 0
10
- Workflow.require_workflow "Translation"
11
- job = Translation.job(:translate, nil, :genes => %w(TP53 KRAS))
12
- Marenostrum.relay job
13
-
14
- end
15
- end
16
-