rbbt-util 5.21.68 → 5.21.69

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: 5a5a4298747149571e1f418373b2f619424bf59b
4
- data.tar.gz: 7a3ebc764edda4f545ebecab158bafd4d2d115ea
3
+ metadata.gz: 399599687a33ccd54d3e3072a1293d167e39af90
4
+ data.tar.gz: a615f143621c1d9b81346ca23b8ee432fc6a67fc
5
5
  SHA512:
6
- metadata.gz: f24daafda2a184bc396ea80fa6c8e5b3346991f0cf4aeaebad2e3d207a720b2225ed7ce6940641b42528907e6e025747bac5e33fff784c43f30119bdf42ccde2
7
- data.tar.gz: 0bdb00bb76b613d436285b787f4e91d0ee98d94aecae760932bda85432d8b0e66e33a923b5cff2b993e57cabf455ebc0e50288a1f50a8a68f807a4ae2d185d90
6
+ metadata.gz: '029a96a494c99358d38858cdb772e78314d6e923248589a2145e6b3e1d52dec61eb66429890d7ede8224be097c41c53c0a6d4ffbae23d3263f8ba9c250997a89'
7
+ data.tar.gz: 4b05254ba442351affed8db14ae7b462b06f6f92d310adf9e9336cd04e33dc626e3ed3d86c8bfb84544d81ef764e1ec5abe743fb971843df9a04fb8362d76bd4
@@ -30,36 +30,50 @@ module Association
30
30
  target_field = tsv.fields.first
31
31
  namespace = tsv.namespace
32
32
 
33
- if source_final_format and source_field != source_final_format
34
- Log.debug("Changing source format from #{tsv.key_field} to #{source_final_format}")
33
+ data = Misc.process_options options, :data
35
34
 
36
- identifier_files = tsv.identifier_files.dup
37
- identifier_files = [Organism.identifiers("NAMESPACE")] if identifier_files.empty?
38
- identifier_files.concat Entity.identifier_files(source_final_format) if defined? Entity
39
- identifier_files.uniq!
40
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
41
- identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
35
+ data ||= {}
36
+ TmpFile.with_file do |tmpfile1|
37
+ TmpFile.with_file do |tmpfile2|
38
+ tmp_data1 = Persist.open_database(tmpfile1, true, :double, "HDB")
39
+ tmp_data2 = Persist.open_database(tmpfile2, true, :double, "HDB")
40
+
41
+ if source_final_format and source_field != source_final_format
42
+ Log.debug("Changing source format from #{tsv.key_field} to #{source_final_format}")
43
+
44
+ identifier_files = tsv.identifier_files.dup
45
+ identifier_files = [Organism.identifiers("NAMESPACE")] if identifier_files.empty?
46
+ identifier_files.concat Entity.identifier_files(source_final_format) if defined? Entity
47
+ identifier_files.uniq!
48
+ identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
49
+ identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
50
+
51
+ tsv = TSV.translate(tsv, source_field, source_final_format, options.merge(:identifier_files => identifier_files, :persist_data => tmp_data1))
52
+ end
42
53
 
43
- tsv = TSV.translate(tsv, source_field, source_final_format, options.merge(:identifier_files => identifier_files))
44
- end
54
+ # Translate target
55
+ if target_final_format and target_field != target_final_format
56
+ Log.debug("Changing target format from #{target_field} to #{target_final_format}")
57
+ old_key_field = tsv.key_field
58
+ tsv.key_field = "MASK"
45
59
 
46
- # Translate target
47
- if target_final_format and target_field != target_final_format
48
- Log.debug("Changing target format from #{target_field} to #{target_final_format}")
49
- old_key_field = tsv.key_field
50
- tsv.key_field = "MASK"
60
+ identifier_files = tsv.identifier_files.dup
61
+ identifier_files.concat Entity.identifier_files(target_final_format) if defined? Entity
62
+ identifier_files.uniq!
63
+ identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
64
+ identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
51
65
 
52
- identifier_files = tsv.identifier_files.dup
53
- identifier_files.concat Entity.identifier_files(target_final_format) if defined? Entity
54
- identifier_files.uniq!
55
- identifier_files.collect!{|f| f.annotate(f.gsub(/\bNAMESPACE\b/, namespace))} if namespace
56
- identifier_files.reject!{|f| f.match(/\bNAMESPACE\b/)}
66
+ tsv = TSV.translate(tsv, target_field, target_final_format, options.merge(:identifier_files => identifier_files, :persist_data => tmp_data2))
67
+ tsv.key_field = old_key_field
68
+ end
57
69
 
58
- tsv = TSV.translate(tsv, target_field, target_final_format, options.merge(:identifier_files => identifier_files))
59
- tsv.key_field = old_key_field
60
- end
70
+ tsv.through do |k,v|
71
+ data[k] = v
72
+ end
61
73
 
62
- tsv
74
+ tsv.annotate data
75
+ end
76
+ end
63
77
  end
64
78
 
65
79
  def self.reorder_tsv(tsv, options = {})
@@ -84,7 +98,7 @@ module Association
84
98
  tsv.fields = field_headers
85
99
 
86
100
  if source_format or target_format
87
- tsv = translate tsv, source_format, target_format, :persist => true, :persist_data => data
101
+ tsv = translate tsv, source_format, target_format, :persist => true, :data => data
88
102
  else
89
103
  tsv.through do |k,v|
90
104
  data[k] = v
@@ -152,7 +166,7 @@ module Association
152
166
  tsv.fields = field_headers
153
167
 
154
168
  if source_format or target_format
155
- tsv = translate tsv, source_format, target_format, :persist => true, :persist_data => data, :data => data
169
+ tsv = translate tsv, source_format, target_format, :persist => true, :data => data
156
170
  else
157
171
  tsv.through do |k,v|
158
172
  data[k] = v
@@ -7,11 +7,11 @@ module Association
7
7
  options = options.nil? ? {} : options.dup
8
8
  persist_options = persist_options.nil? ? Misc.pull_keys(options, :persist) : persist_options.dup
9
9
 
10
- persist_options = Misc.add_defaults persist_options.dup, :persist => true
10
+ persist_options = Misc.add_defaults persist_options.dup, :persist => true, :dir => Rbbt.var.associations
11
11
  persist = persist_options[:persist]
12
12
 
13
13
  file = version_file(file, options[:namespace]) if options[:namespace] and String === file
14
- Persist.persist_tsv(file, "Association Index", options, persist_options.merge(:engine => "BDB")) do |data|
14
+ Persist.persist_tsv(file, nil, options, persist_options.merge(:engine => "BDB", :prefix => "Association Index")) do |data|
15
15
  options = Misc.add_defaults options.dup, :monitor => "Building index for #{Misc.fingerprint file}"
16
16
  recycle = options[:recycle]
17
17
  undirected = options[:undirected]
@@ -13,12 +13,12 @@ module Association
13
13
 
14
14
  options = Misc.add_defaults options, :zipped => true, :merge => true, :monitor => {:desc => "Opening database #{Misc.fingerprint file}"}
15
15
  options[:zipped] = false unless options[:merge]
16
- persist_options = Misc.add_defaults persist_options, :persist => true, :dir => Rbbt.var.associations
16
+ persist_options = Misc.add_defaults persist_options.dup, :persist => true, :dir => Rbbt.var.associations
17
17
  persist = persist_options[:persist]
18
18
 
19
19
  file = version_file(file, options[:namespace]) if options[:namespace] and String === file
20
20
 
21
- data = Persist.persist_tsv(file, "Association Database", options, persist_options) do |data|
21
+ data = Persist.persist_tsv(file, nil, options, persist_options.merge(:prefix => "Association Database")) do |data|
22
22
  file = file.call if Proc === file
23
23
 
24
24
  options = options.dup
@@ -57,7 +57,7 @@ module Association
57
57
 
58
58
  if source_specs.first and not all_fields.include? source_specs.first and defined? Entity and (_format = Entity.formats[source_specs.first.to_s])
59
59
  _source = all_fields.select{|f| Entity.formats[f.to_s] == _format }.first
60
- raise "Source not found #{source_specs}. Options: #{Misc.fingerprint all_fields}" if _target.nil?
60
+ raise "Source not found #{source_specs}. Options: #{Misc.fingerprint all_fields}" if _source.nil?
61
61
  source_specs[0] = _source
62
62
  end
63
63
 
@@ -57,7 +57,11 @@ module TSV
57
57
 
58
58
  class StringDoubleArraySerializer
59
59
  def self.dump(array)
60
- array.collect{|a| a.collect{|a| a.to_s} * "|"} * "\t"
60
+ begin
61
+ array.collect{|a| a.collect{|a| a.to_s } * "|"} * "\t"
62
+ rescue Encoding::CompatibilityError
63
+ array.collect{|a| a.collect{|a| a.to_s.force_encoding('UTF-8')} * "|"} * "\t"
64
+ end
61
65
  end
62
66
 
63
67
  def self.load(string)
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.68
4
+ version: 5.21.69
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-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake