rbbt-util 5.21.110 → 5.21.111

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76533fd3b7702e342b7d237102246b920f687fb2
4
- data.tar.gz: 2c2ab122805de8b07a901e001294b56f65c49eed
3
+ metadata.gz: b261af4cdb9a029acc7e272d72b1bc3baa775129
4
+ data.tar.gz: 2f1fb775eca6be25b97b9852686f0c38e3f36ea2
5
5
  SHA512:
6
- metadata.gz: d2b46293054ceca952bff6da1f9c5200f278645911b55dd8b235b634ff0170f193fac20f5797d52d946f910eec894b44bae3a79b457c3c02cc8e0d011cd85f82
7
- data.tar.gz: f3f15bb7057ea0521bdcbec6290cdde7e3dcd891abe2832008a6d17f944580a6a2fc284a9c442d421501be023c347f0003b01e1838911f363302c6059057c60e
6
+ metadata.gz: 1801165f0f672913afe6869ece7f776f115889ec58d12c043f8687cb0e04ee821a054d14430b7335aded7c818f341ef51cfe9bdf1851410b7a21413eb92ddebd
7
+ data.tar.gz: 5db9691995576aa930cc8a724dc4df18b542d2c7b711a253627f5764f6467f4e4b3f00f8d328ebb9c1ca7bcf3bb0424d580ab0f346c3bc3413197da3104725a0
@@ -157,6 +157,7 @@ class WorkflowRESTClient
157
157
  end
158
158
 
159
159
  def done?
160
+ init_job unless @url
160
161
  @done || status.to_s == 'done'
161
162
  end
162
163
 
@@ -239,13 +239,13 @@ module TSV
239
239
  same_key = true
240
240
  begin
241
241
  case
242
- when (key_field == other.key_field and same_key)
242
+ when (Misc.match_fields(key_field, other.key_field) and same_key)
243
243
  Log.debug "Attachment with same key: #{other.key_field}"
244
244
  attach_same_key other, fields
245
- when (not in_namespace and self.fields.include?(other.key_field))
245
+ when (not in_namespace and self.fields.select{|f| Misc.match_fields(f, other.key_field)}.any?)
246
246
  Log.debug "Found other key field: #{other.key_field}"
247
247
  attach_source_key other, other.key_field, :fields => fields, :one2one => one2one
248
- when (in_namespace and self.fields_in_namespace.include?(other.key_field))
248
+ when (in_namespace and self.fields_in_namespace.select{|f| Misc.match_fields(f, other.key_field)}.any?)
249
249
  Log.debug "Found other key field in #{in_namespace}: #{other.key_field}"
250
250
  attach_source_key other, other.key_field, :fields => fields, :one2one => one2one
251
251
  else
@@ -64,7 +64,8 @@ module TSV
64
64
  field_positions = fields.collect{|field| other.identify_field field}
65
65
  field_names = field_positions.collect{|pos| pos == :key ? other.key_field : other.fields[pos] }
66
66
 
67
- source_pos = identify_field source
67
+ corrected_source = all_fields.select{|f| Misc.match_fields(f, source) }.first
68
+ source_pos = identify_field corrected_source
68
69
 
69
70
  other.with_unnamed do
70
71
  with_unnamed do
@@ -99,6 +100,7 @@ module TSV
99
100
 
100
101
  new = Misc.zip_fields(all_new_values).each{|field_entry|
101
102
  field_entry.flatten!
103
+ field_entry.compact!
102
104
  }
103
105
 
104
106
  self[key] = values.concat new
@@ -229,13 +231,13 @@ module TSV
229
231
  ids.each_with_index do |list, i|
230
232
  break if i == ids.length - 1
231
233
  match = list.select{|field|
232
- ids[i + 1].select{|f| field == f}.any?
234
+ ids[i + 1].select{|f| Misc.match_fields(field, f) }.any?
233
235
  }
234
236
  return nil if match.empty?
235
237
  id_list << match.first
236
238
  end
237
239
 
238
- if id_list.last != files.last.all_fields.first
240
+ if ! Misc.match_fields(id_list.last, files.last.all_fields.first)
239
241
  id_list << files.last.all_fields.first
240
242
  id_list.zip(files)
241
243
  else
@@ -258,8 +260,12 @@ module TSV
258
260
  while not path.empty?
259
261
  next_key, next_file = path.shift
260
262
 
263
+ next_fields = next_file.all_fields
264
+ corrected_next_key = next_fields.select{|f| Misc.match_fields(f, next_key)}.first
265
+ corrected_current_key = next_fields.select{|f| Misc.match_fields(f, current_key)}.first
266
+
261
267
  if current_index.nil?
262
- current_index = next_file.index(:target => next_key, :fields => [current_key], :persist => persist_input)
268
+ current_index = next_file.index(:target => corrected_next_key, :fields => [corrected_current_key], :persist => persist_input)
263
269
  current_index = current_index.select :key => data_file.keys
264
270
  else
265
271
  next_index = next_file.index :target => next_key, :fields => [current_key], :persist => persist_input
@@ -1,5 +1,18 @@
1
1
  module Misc
2
2
 
3
+ def self.match_fields(field1, field2)
4
+ return true if field1 == field2
5
+ if m = field1.match(/\((.*)\)/)
6
+ field1 = m[1]
7
+ end
8
+
9
+ if m = field2.match(/\((.*)\)/)
10
+ field2 = m[1]
11
+ end
12
+
13
+ field1 == field2
14
+ end
15
+
3
16
  def self.prepare_entity(entity, field, options = {})
4
17
  return entity unless defined? Entity
5
18
  return entity unless String === entity or Array === entity
@@ -371,7 +371,7 @@ class Step
371
371
 
372
372
  status = self.status
373
373
 
374
- if done? and not (status == :done or status == :ending) and not status == :noinfo
374
+ if done? and not (status == :done or status == :ending or status == :producing) and not status == :noinfo
375
375
  return true
376
376
  end
377
377
  if status == :done and not done?
@@ -97,11 +97,12 @@ class Step
97
97
  end
98
98
 
99
99
  def checks
100
- dependency_checks + input_checks
100
+ (dependency_checks + input_checks).uniq
101
101
  end
102
102
 
103
103
  def updated?
104
104
  return true unless done?
105
+
105
106
  outdated_time = []
106
107
  outdated_dep = []
107
108
  checks.each do |dep|
@@ -113,8 +114,10 @@ class Step
113
114
  end
114
115
  end
115
116
 
116
- outdated = outdated_time + outdated_dep
117
- outdated.empty?
117
+ Log.low "Some newer files found: #{Misc.fingerprint outdated_time}" if outdated_time.any?
118
+ Log.low "Some outdated files found: #{Misc.fingerprint outdated_dep}" if outdated_dep.any?
119
+
120
+ (outdated_time + outdated_dep).empty?
118
121
  end
119
122
 
120
123
  def kill_children
@@ -479,5 +479,57 @@ A Id3
479
479
  assert res["row2"].include? "Id3"
480
480
  assert ! res["row2"].include?("b")
481
481
  end
482
+
483
+ def test_attached_parenthesis
484
+
485
+ content1 =<<-EOF
486
+ #Id,ValueA,bar (ValueB)
487
+ row1,a|aa|aaa,b
488
+ row2,A,B
489
+ EOF
490
+
491
+ content2 =<<-EOF
492
+ #foo (ValueA),OtherID
493
+ a,Id1|Id2
494
+ A,Id3
495
+ EOF
496
+
497
+ content3 =<<-EOF
498
+ #ValueB,ValueC
499
+ b,c
500
+ B,C
501
+ EOF
502
+
503
+ content4 =<<-EOF
504
+ #foobar (Id),ValueD
505
+ row1,d
506
+ row5,D
507
+ EOF
508
+
509
+ tsv1 = tsv2 = tsv3 = tsv4 = index = nil
510
+ TmpFile.with_file(content1) do |filename|
511
+ tsv1 = TSV.open(File.open(filename), :double, :sep => ',')
512
+ end
513
+
514
+ TmpFile.with_file(content2) do |filename|
515
+ tsv2 = TSV.open(File.open(filename), :double, :sep => ',')
516
+ end
517
+
518
+ TmpFile.with_file(content3) do |filename|
519
+ tsv3 = TSV.open(File.open(filename), :double, :sep => ',')
520
+ end
521
+
522
+ TmpFile.with_file(content4) do |filename|
523
+ tsv4 = TSV.open(File.open(filename), :double, :sep => ',')
524
+ end
525
+
526
+
527
+ assert_equal tsv1.attach(tsv2)["row1"]["OtherID"], %w(Id1 Id2)
528
+ assert_equal tsv1.attach(tsv2)["row2"]["OtherID"], %w(Id3)
529
+
530
+ assert_equal tsv1.attach(tsv4)["row1"]["ValueD"], %w(d)
531
+ assert_equal tsv4.attach(tsv1)["row1"]["bar (ValueB)"], %w(b)
532
+ assert_equal tsv3.attach(tsv1)["b"]["ValueD"], %w(d)
533
+ end
482
534
  end
483
535
 
@@ -479,10 +479,10 @@ eum fugiat quo voluptas nulla pariatur?"
479
479
  assert_equal Misc.obj2md5(obj2), Misc.obj2md5(obj3)
480
480
  hash = Hash[*(0..obj1.length).zip(obj1).flatten]
481
481
 
482
- Misc.benchmark(10000) do
482
+ Misc.benchmark(1000) do
483
483
  Misc.hash2md5(hash)
484
484
  end
485
- Misc.benchmark(10000) do
485
+ Misc.benchmark(1000) do
486
486
  Misc.obj2md5(obj1)
487
487
  end
488
488
  Misc.profile do
@@ -564,4 +564,14 @@ eum fugiat quo voluptas nulla pariatur?"
564
564
  EOF
565
565
  assert Misc.parse_sql_values(str)[1][1] == "bb(,)b"
566
566
  end
567
+
568
+ def test_match_fields
569
+ f1 = "Target (Associated Gene Name)"
570
+ f2 = "Source (Associated Gene Name)"
571
+ f3 = "Associated Gene Name"
572
+
573
+ assert Misc.match_fields(f1, f2)
574
+ assert Misc.match_fields(f1, f3)
575
+ assert Misc.match_fields(f3, f1)
576
+ end
567
577
  end
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.21.110
4
+ version: 5.21.111
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-27 00:00:00.000000000 Z
11
+ date: 2017-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake