rbbt-util 5.8.2 → 5.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 242874c88c6d442034c3e929a735f9d8b5613f53
4
- data.tar.gz: e7b40e285fbc4faf3961fdda643c9278eba21096
3
+ metadata.gz: 8f878977d61954ff0e75db2c46a479f60cdb9ac0
4
+ data.tar.gz: 0d525ca80ffcc1bb9ab128968406e399552fa4d5
5
5
  SHA512:
6
- metadata.gz: 022e09717e9f321571373dcd56e3f1a589fdcf37d731a9db885535964e59f1209c6071017d7efe15a60cdc309538c675d2db9dbf9baae21564c1fc7e071ae13a
7
- data.tar.gz: 244ad59bc44e11e54a015efd5ac17f69c496b35051807118ac9b931fb08a3196d47a6030966007dca9d4402e4be6738cbc1f19fd484f8c3a4daa66372bf191fc
6
+ metadata.gz: a35853cd5698117c360befd9dc876a36b2c590c3eaa171424700bdd1d28ba75106d28badfb0d76534dd975fe0fe50a43cc92794c3be5b44b66077e649296ab0c
7
+ data.tar.gz: d4522e6efe04efaa658e19bfee22cf15b41dce5a771e2e5be3137a518691b80dbd6aebf0a638696f6f1d632db6bffc97b4ad8e9266d5236d22bb62ed42a1d435
@@ -1479,6 +1479,17 @@ end
1479
1479
  sout
1480
1480
  end
1481
1481
 
1482
+ def self.append_zipped(current, new)
1483
+ current.each do |v|
1484
+ n = new.shift
1485
+ if Array === n
1486
+ v.concat new
1487
+ else
1488
+ v << n
1489
+ end
1490
+ end
1491
+ current
1492
+ end
1482
1493
 
1483
1494
  def self.zip_fields(array)
1484
1495
  return [] if array.empty? or (first = array.first).nil?
@@ -1574,6 +1585,16 @@ module IndiferentHash
1574
1585
  hash.extend IndiferentHash
1575
1586
  end
1576
1587
 
1588
+ def merge(other)
1589
+ new = self.dup
1590
+ IndiferentHash.setup(new)
1591
+ other.each do |k,value|
1592
+ new.delete k
1593
+ new[k] = value
1594
+ end
1595
+ new
1596
+ end
1597
+
1577
1598
  def [](key)
1578
1599
  res = super(key)
1579
1600
  return res unless res.nil?
@@ -10,7 +10,7 @@ def run_task(workflow, task, name)
10
10
  example_dir = workflow.libdir.examples[task][name].find
11
11
  Log.debug "Using #{example_dir}"
12
12
 
13
- ARGV.replace([workflow.to_s, task, '--load_inputs', example_dir, '--jobname', name,'--O','/dev/null'] + $saved_args)
13
+ ARGV.replace([workflow.to_s, task, '--load_inputs', example_dir, '--jobname', name,'--pf'] + $saved_args)
14
14
 
15
15
  @pid = Process.fork{
16
16
  load Rbbt.share.rbbt_commands.workflow.task.find
@@ -17,10 +17,10 @@ def load_inputs(dir, task)
17
17
  inputs[input.to_sym] = file
18
18
  else
19
19
  Log.debug "Loading #{ input } from #{file}"
20
- inputs[input.to_sym] = file.read
20
+ inputs[input.to_sym] = file.read.strip
21
21
  end
22
22
  end
23
- inputs
23
+ IndiferentHash.setup(inputs)
24
24
  end
25
25
 
26
26
  def report_options(options)
@@ -136,6 +136,7 @@ options = SOPT.get <<EOF
136
136
  -as--array_separator* Change the character that separates elements of Arrays, ',', '|', or '\\n' by default:
137
137
  -jn--jobname* Job name to use. The name 'Default' is used by default:
138
138
  -pn--printname Print the name of the job and exit without starting it:
139
+ -pf--printpath Print the path of the job result:
139
140
  -cl--clean Clean the last step of the job so that it gets recomputed:
140
141
  -rcl--recursive_clean Clean the last step and its dependencies to recompute the job completely:
141
142
  --fork Run job asyncronously:
@@ -203,7 +204,7 @@ name = options.delete(:jobname) || "Default"
203
204
  # get job args
204
205
  sopt_option_string = SOPT_options(workflow, task)
205
206
  if options[:load_inputs]
206
- job_options = load_inputs(options[:load_inputs], task)
207
+ job_options = load_inputs(options[:load_inputs], task).merge(SOPT.get(sopt_option_string))
207
208
  else
208
209
  job_options = SOPT.get sopt_option_string
209
210
  end
@@ -282,6 +283,13 @@ begin
282
283
  else
283
284
  Log.low "Job name: #{job.name}"
284
285
  end
286
+
287
+ if options.delete(:printpath)
288
+ puts job.path
289
+ exit 0
290
+ else
291
+ Log.low "Job name: #{job.name}"
292
+ end
285
293
  rescue ParameterException
286
294
  SOPT.delete_inputs(workflow.rec_inputs(task.name))
287
295
  usage(workflow, task, $!)
@@ -6,12 +6,12 @@ require 'rbbt/entity'
6
6
 
7
7
  class TestMisc < Test::Unit::TestCase
8
8
 
9
- def _test_parse_cmd_params
9
+ def test_parse_cmd_params
10
10
  ddd Misc.parse_cmd_params("workflow task Translation translate -f 'Associated Gene Name' -l -")
11
11
  end
12
12
 
13
13
 
14
- def _test_fixutf8
14
+ def test_fixutf8
15
15
  string = "abc\xffdef"
16
16
  string = string.force_encoding("UTF-8") if string.respond_to? :force_encoding
17
17
  assert(! string.valid_encoding?) if string.respond_to? :valid_encoding?
@@ -20,37 +20,37 @@ class TestMisc < Test::Unit::TestCase
20
20
  assert( Misc.fixutf8(string).valid_encoding) if string.respond_to? :valid_encoding
21
21
  end
22
22
 
23
- def _test_colors_for
23
+ def test_colors_for
24
24
  colors, used = Misc.colors_for([1,2,2,1,2,1,2,2,3,3,2,3,2])
25
25
  assert_equal Misc::COLOR_LIST[1], used[2]
26
26
  end
27
27
 
28
- def _test_total_length
28
+ def test_total_length
29
29
  ranges = [(0..100), (50..150), (120..160)]
30
30
  ranges = [(0..100), (50..150), (120..160), (51..70)]
31
31
  assert_equal 161, Misc.total_length(ranges)
32
32
  end
33
33
 
34
- def _test_id_filename?
34
+ def test_id_filename?
35
35
  TmpFile.with_file("") do |file|
36
36
  assert Misc.is_filename?(file)
37
37
  assert ! Misc.is_filename?("TEST STRING")
38
38
  end
39
39
  end
40
40
 
41
- def _test_merge_sorted_arrays
41
+ def test_merge_sorted_arrays
42
42
  assert_equal [1,2,3,4], Misc.merge_sorted_arrays([1,3], [2,4])
43
43
  end
44
44
 
45
- def _test_intersect_sorted_arrays
45
+ def test_intersect_sorted_arrays
46
46
  assert_equal [2,4], Misc.intersect_sorted_arrays([1,2,3,4], [2,4])
47
47
  end
48
48
 
49
- def _test_sorted_array_matches
49
+ def test_sorted_array_matches
50
50
  assert_equal [1,3], Misc.sorted_array_hits(%w(a b c d e), %w(b d))
51
51
  end
52
52
 
53
- def _test_binary_include?
53
+ def test_binary_include?
54
54
  a = %w(a b c d e).sort
55
55
  assert Misc.binary_include?(a, "a")
56
56
  assert(!Misc.binary_include?(a, "z"))
@@ -59,24 +59,24 @@ class TestMisc < Test::Unit::TestCase
59
59
  assert(Misc.binary_include?(a, "d"))
60
60
  end
61
61
 
62
- def _test_process_to_hash
62
+ def test_process_to_hash
63
63
  list = [1,2,3,4]
64
64
  assert_equal 4, Misc.process_to_hash(list){|l| l.collect{|e| e * 2}}[2]
65
65
  end
66
66
 
67
- # def _test_pdf2text_example
67
+ # def test_pdf2text_example
68
68
  # assert PDF2Text.pdf2text(datafile_test('example.pdf')).read =~ /An Example Paper/i
69
69
  # end
70
70
  #
71
- # def _test_pdf2text_EPAR
71
+ # def test_pdf2text_EPAR
72
72
  # assert PDF2Text.pdf2text("http://www.ema.europa.eu/docs/en_GB/document_library/EPAR_-_Scientific_Discussion/human/000402/WC500033103.pdf").read =~ /Tamiflu/i
73
73
  # end
74
74
  #
75
- # def _test_pdf2text_wrong
75
+ # def test_pdf2text_wrong
76
76
  # assert_raise CMD::CMDError do PDF2Text.pdf2text("http://www.ema.europa.eu/docs/en_GB#").read end
77
77
  # end
78
78
 
79
- def _test_string2hash
79
+ def test_string2hash
80
80
  assert(Misc.string2hash("--user-agent=firefox").include? "--user-agent")
81
81
  assert_equal(true, Misc.string2hash(":true")[:true])
82
82
  assert_equal(true, Misc.string2hash("true")["true"])
@@ -87,7 +87,7 @@ class TestMisc < Test::Unit::TestCase
87
87
  assert_equal(:j, Misc.string2hash("a=b#c=d#:h=:j")[:h])
88
88
  end
89
89
 
90
- def _test_named_array
90
+ def test_named_array
91
91
  a = NamedArray.setup([1,2,3,4], %w(a b c d))
92
92
  assert_equal(1, a['a'])
93
93
  end
@@ -102,8 +102,8 @@ class TestMisc < Test::Unit::TestCase
102
102
  end
103
103
  end
104
104
 
105
- # def _test_chunk
106
- # _test =<<-EOF
105
+ # def test_chunk
106
+ # test =<<-EOF
107
107
  #This is an example file. Entries are separated by Entry
108
108
  #-- Entry
109
109
  #1
@@ -118,7 +118,7 @@ class TestMisc < Test::Unit::TestCase
118
118
  # assert_equal "1\n2\n3", Misc.chunk(test, /^-- Entry/).first.strip
119
119
  # end
120
120
 
121
- def _test_hash2string
121
+ def test_hash2string
122
122
  hash = {}
123
123
  assert_equal hash, Misc.string2hash(Misc.hash2string(hash))
124
124
 
@@ -136,14 +136,14 @@ class TestMisc < Test::Unit::TestCase
136
136
 
137
137
  end
138
138
 
139
- def _test_merge
139
+ def test_merge
140
140
  a = [[1],[2]]
141
141
  a = NamedArray.setup a, %w(1 2)
142
142
  a.merge [3,4]
143
143
  assert_equal [1,3], a[0]
144
144
  end
145
145
 
146
- def _test_indiferent_hash
146
+ def test_indiferent_hash
147
147
  a = {:a => 1, "b" => 2}
148
148
  a.extend IndiferentHash
149
149
 
@@ -153,7 +153,7 @@ class TestMisc < Test::Unit::TestCase
153
153
  assert_equal 2, a[:b]
154
154
  end
155
155
 
156
- def _test_lockfile
156
+ def test_lockfile
157
157
 
158
158
  TmpFile.with_file do |tmpfile|
159
159
  pids = []
@@ -177,7 +177,7 @@ class TestMisc < Test::Unit::TestCase
177
177
  end
178
178
  end
179
179
 
180
- def _test_positions2hash
180
+ def test_positions2hash
181
181
  inputs = Misc.positional2hash([:one, :two, :three], 1, :two => 2, :four => 4)
182
182
  assert_equal 1, inputs[:one]
183
183
  assert_equal 2, inputs[:two]
@@ -185,41 +185,42 @@ class TestMisc < Test::Unit::TestCase
185
185
  assert_equal nil, inputs[:four]
186
186
  end
187
187
 
188
- def _test_mean
188
+ def test_mean
189
189
  assert_equal 2, Misc.mean([1,2,3])
190
190
  assert_equal 3, Misc.mean([1,2,3,4,5])
191
191
  end
192
192
 
193
- def __test_sd
194
- assert_equal Math.sqrt(2), Misc.sd([1,3])
193
+ def test_zip_fields
194
+ current = [[:a,1], [:b,2]]
195
+ assert_equal [[:a, :b],[1,2]], Misc.zip_fields(current)
196
+ assert_equal current, Misc.zip_fields(Misc.zip_fields(current))
195
197
  end
196
198
 
197
- def _test_align_small
198
- reference = "AABCDEBD"
199
- sequence = "ABCD"
200
- assert_equal '-ABCD---', Misc.fast_align(reference, sequence).last
199
+ def test_add_zipped
200
+ current = [[:a,1], [:b,2]]
201
+ new = %w(A B)
202
+ Misc.append_zipped current, new
203
+ assert_equal [[:a,1,"A"], [:b,2,"B"]], current
201
204
  end
202
205
 
203
- def _test_align_real
204
- reference = "SGNECNKAIDGNKDTFWHTFYGANGDPKPPPHTYTIDMKTTQNVNGLSMLPRQDGNQNGWIGRHEVYLSSDGTNW"
205
- sequence = "TYTIDMKTTQNVNGLSML"
206
- assert_equal "--------------------------------TYTIDMKTTQNVNGLSML-------------------------", Misc.fast_align(reference, sequence).last
206
+ def __test_sd
207
+ assert_equal Math.sqrt(2), Misc.sd([1,3])
207
208
  end
208
209
 
209
- def _test_divide
210
+ def test_divide
210
211
  assert_equal 2, Misc.divide(%w(1 2 3 4 5 6 7 8 9),2).length
211
212
  end
212
213
 
213
- def _test_ordered_divide
214
+ def test_ordered_divide
214
215
  assert_equal 5, Misc.ordered_divide(%w(1 2 3 4 5 6 7 8 9),2).length
215
216
  end
216
217
 
217
- def _test_collapse_ranges
218
+ def test_collapse_ranges
218
219
  ranges = [(0..100), (50..150), (51..61),(200..250), (300..324),(320..350)]
219
220
  assert_equal [(0..150),(200..250), (300..350)], Misc.collapse_ranges(ranges)
220
221
  end
221
222
 
222
- def _test_humanize
223
+ def test_humanize
223
224
  str1 = "test_string"
224
225
  str2 = "TEST_string"
225
226
  str3 = "test"
@@ -231,22 +232,22 @@ class TestMisc < Test::Unit::TestCase
231
232
  assert_equal "mutation_enrichment", Misc.snake_case("MutationEnrichment")
232
233
  end
233
234
 
234
- def _test_snake_case
235
+ def test_snake_case
235
236
  str1 = "ACRONIMTest"
236
237
  str2 = "ACRONIM_test"
237
238
  assert_equal "ACRONIM_test", Misc.snake_case(str1)
238
239
  assert_equal "ACRONIM_test", Misc.snake_case(str2)
239
240
  end
240
241
 
241
- def _test_correct_vcf_mutations
242
+ def test_correct_vcf_mutations
242
243
  assert_equal [737407, ["-----", "-----G", "-----GTTAAT"]], Misc.correct_vcf_mutation(737406, "GTTAAT", "G,GG,GGTTAAT")
243
244
  end
244
245
 
245
- def _test_fingerprint
246
+ def test_fingerprint
246
247
  assert_equal '{a=>1}', Misc.fingerprint({:a => 1})
247
248
  end
248
249
 
249
- def _test_tarize
250
+ def test_tarize
250
251
  path = File.expand_path('/home/mvazquezg/git/rbbt-util/lib')
251
252
  stream = Misc.tarize(path)
252
253
  TmpFile.with_file do |res|
@@ -256,7 +257,7 @@ class TestMisc < Test::Unit::TestCase
256
257
  end
257
258
  end
258
259
 
259
- def _test_camel_case
260
+ def test_camel_case
260
261
  assert_equal "DbSNP", Misc.camel_case("db_SNP")
261
262
  assert_equal "D3Js", Misc.camel_case("D3Js")
262
263
  assert_equal "Structure", Misc.camel_case("Structure")
@@ -264,7 +265,7 @@ class TestMisc < Test::Unit::TestCase
264
265
  assert_equal "COSMIC", Misc.camel_case("COSMIC")
265
266
  end
266
267
 
267
- def _test_pipe
268
+ def test_pipe
268
269
  t = 5
269
270
  stream = Misc.open_pipe do |sin|
270
271
  t.times do |i|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.8.2
4
+ version: 5.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake