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.
- checksums.yaml +4 -4
- data/etc/app.d/base.rb +1 -1
- data/lib/rbbt/association/util.rb +1 -1
- data/lib/rbbt/hpc/batch.rb +19 -17
- data/lib/rbbt/persist/tsv/sharder.rb +1 -1
- data/lib/rbbt/tsv/accessor.rb +6 -11
- data/lib/rbbt/tsv/dumper.rb +21 -10
- data/lib/rbbt/tsv/index.rb +2 -1
- data/lib/rbbt/util/misc/math.rb +0 -1
- data/lib/rbbt/util/misc/omics.rb +2 -1
- data/lib/rbbt/util/misc/ssw.rb +298 -0
- data/lib/rbbt/util/open.rb +1 -1
- data/lib/rbbt/workflow/step/info.rb +3 -2
- data/lib/rbbt/workflow/step.rb +2 -1
- data/python/rbbt/__init__.py +2 -2
- data/share/rbbt_commands/workflow/server +6 -1
- data/share/rbbt_commands/workflow/task +1 -1
- metadata +5 -220
- data/test/rbbt/annotations/test_util.rb +0 -43
- data/test/rbbt/association/test_database.rb +0 -87
- data/test/rbbt/association/test_index.rb +0 -127
- data/test/rbbt/association/test_item.rb +0 -15
- data/test/rbbt/association/test_open.rb +0 -63
- data/test/rbbt/association/test_util.rb +0 -108
- data/test/rbbt/entity/test_identifiers.rb +0 -34
- data/test/rbbt/hpc/orchestrate/test_batches.rb +0 -70
- data/test/rbbt/hpc/orchestrate/test_chains.rb +0 -108
- data/test/rbbt/hpc/orchestrate/test_rules.rb +0 -59
- data/test/rbbt/hpc/test_batch.rb +0 -64
- data/test/rbbt/hpc/test_hpc_test_workflows.rb +0 -0
- data/test/rbbt/hpc/test_orchestrate.rb +0 -144
- data/test/rbbt/hpc/test_pbs.rb +0 -43
- data/test/rbbt/hpc/test_slurm.rb +0 -28
- data/test/rbbt/knowledge_base/test_enrichment.rb +0 -50
- data/test/rbbt/knowledge_base/test_entity.rb +0 -62
- data/test/rbbt/knowledge_base/test_query.rb +0 -46
- data/test/rbbt/knowledge_base/test_registry.rb +0 -74
- data/test/rbbt/knowledge_base/test_syndicate.rb +0 -48
- data/test/rbbt/knowledge_base/test_traverse.rb +0 -133
- data/test/rbbt/persist/test_tsv.rb +0 -88
- data/test/rbbt/persist/tsv/test_cdb.rb +0 -18
- data/test/rbbt/persist/tsv/test_kyotocabinet.rb +0 -27
- data/test/rbbt/persist/tsv/test_leveldb.rb +0 -18
- data/test/rbbt/persist/tsv/test_lmdb.rb +0 -20
- data/test/rbbt/persist/tsv/test_sharder.rb +0 -164
- data/test/rbbt/persist/tsv/test_tokyocabinet.rb +0 -262
- data/test/rbbt/resource/test_path.rb +0 -49
- data/test/rbbt/test_annotations.rb +0 -167
- data/test/rbbt/test_association.rb +0 -103
- data/test/rbbt/test_entity.rb +0 -252
- data/test/rbbt/test_fix_width_table.rb +0 -135
- data/test/rbbt/test_knowledge_base.rb +0 -226
- data/test/rbbt/test_monitor.rb +0 -11
- data/test/rbbt/test_packed_index.rb +0 -68
- data/test/rbbt/test_persist.rb +0 -85
- data/test/rbbt/test_resource.rb +0 -110
- data/test/rbbt/test_tsv.rb +0 -669
- data/test/rbbt/test_workflow.rb +0 -609
- data/test/rbbt/tsv/parallel/test_through.rb +0 -40
- data/test/rbbt/tsv/parallel/test_traverse.rb +0 -456
- data/test/rbbt/tsv/test_accessor.rb +0 -319
- data/test/rbbt/tsv/test_attach.rb +0 -715
- data/test/rbbt/tsv/test_change_id.rb +0 -61
- data/test/rbbt/tsv/test_csv.rb +0 -49
- data/test/rbbt/tsv/test_excel.rb +0 -171
- data/test/rbbt/tsv/test_field_index.rb +0 -19
- data/test/rbbt/tsv/test_filter.rb +0 -187
- data/test/rbbt/tsv/test_index.rb +0 -308
- data/test/rbbt/tsv/test_manipulate.rb +0 -334
- data/test/rbbt/tsv/test_marshal.rb +0 -24
- data/test/rbbt/tsv/test_matrix.rb +0 -20
- data/test/rbbt/tsv/test_parallel.rb +0 -7
- data/test/rbbt/tsv/test_parser.rb +0 -101
- data/test/rbbt/tsv/test_stream.rb +0 -253
- data/test/rbbt/tsv/test_util.rb +0 -52
- data/test/rbbt/util/R/test_eval.rb +0 -43
- data/test/rbbt/util/R/test_model.rb +0 -128
- data/test/rbbt/util/R/test_plot.rb +0 -38
- data/test/rbbt/util/concurrency/processes/test_socket.rb +0 -70
- data/test/rbbt/util/concurrency/test_processes.rb +0 -192
- data/test/rbbt/util/concurrency/test_threads.rb +0 -40
- data/test/rbbt/util/log/test_progress.rb +0 -111
- data/test/rbbt/util/misc/test_bgzf.rb +0 -48
- data/test/rbbt/util/misc/test_communication.rb +0 -13
- data/test/rbbt/util/misc/test_development.rb +0 -26
- data/test/rbbt/util/misc/test_format.rb +0 -10
- data/test/rbbt/util/misc/test_indiferent_hash.rb +0 -14
- data/test/rbbt/util/misc/test_lock.rb +0 -77
- data/test/rbbt/util/misc/test_multipart_payload.rb +0 -202
- data/test/rbbt/util/misc/test_omics.rb +0 -116
- data/test/rbbt/util/misc/test_pipes.rb +0 -343
- data/test/rbbt/util/misc/test_serialize.rb +0 -24
- data/test/rbbt/util/python/test_util.rb +0 -25
- data/test/rbbt/util/simpleopt/test_get.rb +0 -12
- data/test/rbbt/util/simpleopt/test_parse.rb +0 -10
- data/test/rbbt/util/simpleopt/test_setup.rb +0 -76
- data/test/rbbt/util/test_R.rb +0 -37
- data/test/rbbt/util/test_chain_methods.rb +0 -22
- data/test/rbbt/util/test_cmd.rb +0 -87
- data/test/rbbt/util/test_colorize.rb +0 -22
- data/test/rbbt/util/test_concurrency.rb +0 -6
- data/test/rbbt/util/test_config.rb +0 -69
- data/test/rbbt/util/test_excel2tsv.rb +0 -10
- data/test/rbbt/util/test_filecache.rb +0 -36
- data/test/rbbt/util/test_log.rb +0 -52
- data/test/rbbt/util/test_migrate.rb +0 -34
- data/test/rbbt/util/test_misc.rb +0 -728
- data/test/rbbt/util/test_open.rb +0 -200
- data/test/rbbt/util/test_procpath.rb +0 -23
- data/test/rbbt/util/test_python.rb +0 -144
- data/test/rbbt/util/test_semaphore.rb +0 -36
- data/test/rbbt/util/test_simpleDSL.rb +0 -55
- data/test/rbbt/util/test_simpleopt.rb +0 -11
- data/test/rbbt/util/test_ssh.rb +0 -10
- data/test/rbbt/util/test_tmpfile.rb +0 -32
- data/test/rbbt/workflow/step/test_dependencies.rb +0 -295
- data/test/rbbt/workflow/step/test_save_load_inputs.rb +0 -136
- data/test/rbbt/workflow/test_doc.rb +0 -30
- data/test/rbbt/workflow/test_remote_workflow.rb +0 -99
- data/test/rbbt/workflow/test_schedule.rb +0 -0
- data/test/rbbt/workflow/test_step.rb +0 -231
- data/test/rbbt/workflow/test_task.rb +0 -85
- data/test/rbbt/workflow/util/test_archive.rb +0 -27
- data/test/rbbt/workflow/util/test_data.rb +0 -67
- data/test/rbbt/workflow/util/test_orchestrator.rb +0 -263
- data/test/test_helper.rb +0 -114
@@ -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
|
data/test/rbbt/test_entity.rb
DELETED
@@ -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
|
-
|
@@ -1,226 +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
|
-
require 'rbbt/entity/identifiers'
|
8
|
-
|
9
|
-
require 'rbbt/association'
|
10
|
-
require 'rbbt/knowledge_base'
|
11
|
-
|
12
|
-
module Gene
|
13
|
-
extend Entity
|
14
|
-
property :follow => :single do |kb,name,annotate=nil|
|
15
|
-
if annotate.nil? or annotate
|
16
|
-
l = kb.children(name, self).target_entity
|
17
|
-
self.annotate l if annotate and kb.source(name) == format
|
18
|
-
l
|
19
|
-
else
|
20
|
-
kb._children(name, self).collect{|v| v.partition("~").last }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
property :backtrack => :single do |kb,name,annotate=nil|
|
25
|
-
if annotate.nil? or annotate
|
26
|
-
l = kb.parents(name, self).target_entity
|
27
|
-
self.annotate l if annotate and kb.target(name) == format
|
28
|
-
l
|
29
|
-
else
|
30
|
-
kb._parents(name, self).collect{|v| v.partition("~").last }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
property :expand => :single do |kb,name,annotate=nil|
|
35
|
-
if annotate.nil? or annotate
|
36
|
-
n = kb.neighbours(name, self)
|
37
|
-
if kb.source(name) == kb.target(name)
|
38
|
-
self.annotate n.collect{|k,v| v.target}.flatten
|
39
|
-
else
|
40
|
-
n.collect{|k,v| v.target_entity.to_a}.flatten
|
41
|
-
end
|
42
|
-
else
|
43
|
-
n = kb._neighbours(name, self)
|
44
|
-
n.values.flatten.collect{|v| v.partition("~").last}
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
class TestKnowledgeBase < Test::Unit::TestCase
|
51
|
-
def setup
|
52
|
-
require 'rbbt/sources/organism'
|
53
|
-
|
54
|
-
Gene.add_identifiers Organism.identifiers("NAMESPACE"), "Ensembl Gene ID", "Associated Gene Name"
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_knowledge_base_simple
|
58
|
-
organism = Organism.default_code("Hsa")
|
59
|
-
TmpFile.with_file do |tmpdir|
|
60
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
61
|
-
kb.format = {"Gene" => "Ensembl Gene ID"}
|
62
|
-
|
63
|
-
kb.register :gene_ages, datadir_test.gene_ages
|
64
|
-
|
65
|
-
i = kb.get_index(:gene_ages)
|
66
|
-
|
67
|
-
assert_include i.match("ENSG00000000003"), "ENSG00000000003~Bilateria"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_knowledge_base_translate
|
72
|
-
organism = Organism.default_code("Hsa")
|
73
|
-
TmpFile.with_file do |tmpdir|
|
74
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
75
|
-
kb.format = {"Gene" => "Ensembl Gene ID"}
|
76
|
-
|
77
|
-
kb.register :gene_ages, datadir_test.gene_ages, :source => "FamilyAge", :target => "=>Associated Gene Name"
|
78
|
-
|
79
|
-
i = kb.get_index(:gene_ages)
|
80
|
-
|
81
|
-
assert_include i.match("Bilateria"), "Bilateria~SMAD4"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
|
86
|
-
def test_knowledge_base_reverse
|
87
|
-
organism = Organism.default_code("Hsa")
|
88
|
-
TmpFile.with_file do |tmpdir|
|
89
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
90
|
-
kb.format = {"Gene" => "Ensembl Gene ID"}
|
91
|
-
|
92
|
-
kb.register :gene_ages, datadir_test.gene_ages
|
93
|
-
|
94
|
-
ri = kb.get_index(:gene_ages).reverse
|
95
|
-
|
96
|
-
assert_include ri.match("Bilateria"), "Bilateria~ENSG00000000003"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_entity
|
101
|
-
organism = Organism.default_code("Hsa")
|
102
|
-
TmpFile.with_file do |tmpdir|
|
103
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
104
|
-
kb.format = {"Gene" => "Ensembl Gene ID"}
|
105
|
-
|
106
|
-
kb.register :gene_ages, datadir_test.gene_ages, :source => "=>Associated Gene Name"
|
107
|
-
|
108
|
-
kb.register :CollecTRI, datadir_test.CollecTRI,
|
109
|
-
:source => "Transcription Factor", :target => "Target Gene",
|
110
|
-
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
111
|
-
|
112
|
-
smad4 = Gene.setup("SMAD4", "Associated Gene Name", kb.namespace)
|
113
|
-
smad7 = Gene.setup("SMAD7", "Associated Gene Name", kb.namespace)
|
114
|
-
|
115
|
-
|
116
|
-
assert_include smad4.follow(kb, :CollecTRI), smad7
|
117
|
-
assert_include smad7.backtrack(kb, :CollecTRI), smad4
|
118
|
-
refute smad7.follow(kb, :CollecTRI).include?(smad4)
|
119
|
-
assert_include smad7.expand(kb, :CollecTRI), smad4
|
120
|
-
assert_include smad4.expand(kb, :CollecTRI), smad7
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def __test_benchmark
|
126
|
-
organism = Organism.default_code("Hsa")
|
127
|
-
TmpFile.with_file do |tmpdir|
|
128
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
129
|
-
kb.format = {"Gene" => "Ensembl Gene ID"}
|
130
|
-
|
131
|
-
kb.register :gene_ages, datadir_test.gene_ages, :source => "=>Associated Gene Name"
|
132
|
-
|
133
|
-
kb.register :CollecTRI, datadir_test.CollecTRI,
|
134
|
-
:source => "Transcription Factor", :target => "Target Gene (Associated Gene Name)",
|
135
|
-
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
136
|
-
|
137
|
-
|
138
|
-
smad4 = Gene.setup("SMAD4", "Associated Gene Name", kb.namespace)
|
139
|
-
downstream = smad4.follow(kb, :CollecTRI, true)
|
140
|
-
Gene.setup(downstream)
|
141
|
-
|
142
|
-
downstream.follow(kb, :CollecTRI)
|
143
|
-
downstream.backtrack(kb, :CollecTRI)
|
144
|
-
downstream.expand(kb, :CollecTRI)
|
145
|
-
|
146
|
-
Misc.benchmark(50) do
|
147
|
-
downstream.follow(kb, :CollecTRI)
|
148
|
-
downstream.backtrack(kb, :CollecTRI)
|
149
|
-
downstream.expand(kb, :CollecTRI)
|
150
|
-
end
|
151
|
-
|
152
|
-
Misc.benchmark(50) do
|
153
|
-
downstream.follow(kb, :CollecTRI, true)
|
154
|
-
downstream.backtrack(kb, :CollecTRI, true)
|
155
|
-
downstream.expand(kb, :CollecTRI, true)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_identifier_files
|
161
|
-
organism = Organism.default_code("Hsa")
|
162
|
-
TmpFile.with_file do |tmpdir|
|
163
|
-
Path.setup(tmpdir)
|
164
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
165
|
-
|
166
|
-
kb.register :gene_ages, datadir_test.gene_ages
|
167
|
-
|
168
|
-
assert_include kb.get_database(:gene_ages).identifier_files.first, "test/data"
|
169
|
-
assert_include kb.get_index(:gene_ages).identifier_files.first, "test/data"
|
170
|
-
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def test_knowledge_base_reuse
|
175
|
-
organism = Organism.default_code("Hsa")
|
176
|
-
TmpFile.with_file do |tmpdir|
|
177
|
-
Path.setup(tmpdir)
|
178
|
-
kb = KnowledgeBase.new tmpdir, Organism.default_code("Hsa")
|
179
|
-
kb.register :CollecTRI, datadir_test.CollecTRI,
|
180
|
-
:source => "Transcription Factor=~Associated Gene Name=>Ensembl Gene ID", :target => "Target Gene",
|
181
|
-
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"]
|
182
|
-
|
183
|
-
assert kb.get_database(:CollecTRI).identifier_files.any?
|
184
|
-
|
185
|
-
i = Association.index(datadir_test.CollecTRI, :persist_file => tmpdir.CollecTRI,
|
186
|
-
:source => "Transcription Factor=~Associated Gene Name=>Ensembl Gene ID", :target => "Target Gene",
|
187
|
-
:fields => ["[ExTRI] Confidence", "[ExTRI] PMID"],
|
188
|
-
:format => {"Gene" => "Ensembl Gene ID"},
|
189
|
-
:namespace => Organism.default_code("Hsa"))
|
190
|
-
|
191
|
-
assert i.identifier_files.any?
|
192
|
-
|
193
|
-
kb = KnowledgeBase.load(tmpdir)
|
194
|
-
|
195
|
-
assert kb.get_database(:CollecTRI).identifier_files.any?
|
196
|
-
|
197
|
-
i = kb.get_index(:CollecTRI)
|
198
|
-
|
199
|
-
assert i.identifier_files.any?
|
200
|
-
assert kb.identify_source('CollecTRI', "SMAD4") =~ /ENSG/
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
|
205
|
-
def test_flat
|
206
|
-
organism = Organism.default_code("Hsa")
|
207
|
-
TmpFile.with_file do |tmpdir|
|
208
|
-
kbfile = File.join(tmpdir, 'kb')
|
209
|
-
file = File.join(tmpdir, 'file')
|
210
|
-
kb = KnowledgeBase.new kbfile
|
211
|
-
kb.register :test_flat do
|
212
|
-
str =<<-EOF
|
213
|
-
#: :type=:flat#:sep=' '
|
214
|
-
#Key Value
|
215
|
-
a b c d e
|
216
|
-
A B C D E
|
217
|
-
EOF
|
218
|
-
Open.write(file, str)
|
219
|
-
file
|
220
|
-
end
|
221
|
-
db = kb.get_database(:test_flat)
|
222
|
-
assert db["a"].first.length > 1
|
223
|
-
end
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|