rbbt-util 5.33.16 → 5.33.17

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
  SHA256:
3
- metadata.gz: 6e5130f02695dfc9fb622a6ddcca18f3d493880a75dcacf93b34ce1194373cda
4
- data.tar.gz: 4c7f78132943b3e348327e5383caaef732f2b1f2dd08b1c8c0b634aeb62f4120
3
+ metadata.gz: ef7021b030246f34a470e907ed0da23723ba102dbb86bbdba64f48dac3a1c551
4
+ data.tar.gz: bf455f3edccac1d760129e14c71dbee3c81f84cfdda987ca1b22df45fe08a3c6
5
5
  SHA512:
6
- metadata.gz: 2762dee76acc3e9bf926383ae9163060b74566bc8a260ea3f6941d79cbe49e367f5436bbcffd1ca8a4bc6fd981e86a562144daee1d35e6fd26548e818056f8a2
7
- data.tar.gz: e7e84344202c0974dcc4b3f27b03685d8820affa6d730f00ad45a309c8d755c5c0a5906aab776e266b38f329abe67b0701259a4f71679778670efe6c09b5d776
6
+ metadata.gz: e38f98896f399cb14c79b1d255bea8b6fc29764179796071ec62d8770034a72108dc66da97ace861fbc96c395deb474ab1f2b68eacb13f1c2e6bfa5dac08bd6c
7
+ data.tar.gz: da24eb3193968cd411947bc0bc57a675ffd413a6c6599c9a40e398731494c48f92a57eba0aa614a3e29f0f62403444c522439131d43e0dbf13d2dbf0e5e400bd
data/lib/rbbt/tsv/util.rb CHANGED
@@ -1,12 +1,39 @@
1
1
  require 'rbbt/resource/path'
2
2
  module TSV
3
3
 
4
+ def self.stream_column(file, column)
5
+ header = TSV.parse_header(file)
6
+ pos = header.fields.index(column) + 1
7
+ sep2 = header.options[:sep2] || "|"
8
+ case header.type.to_s
9
+ when nil, "double"
10
+ TSV.traverse file, :type => :array, :into => :stream do |line|
11
+ next if line =~ /^#/
12
+ line.split("\t")[pos].gsub(sep2, "\n")
13
+ end
14
+ when "single"
15
+ TSV.traverse file, :type => :array, :into => :stream do |line|
16
+ next if line =~ /^#/
17
+ line.split("\t")[1]
18
+ end
19
+ when "flat"
20
+ TSV.traverse file, :type => :array, :into => :stream do |line|
21
+ next if line =~ /^#/
22
+ line.split("\t")[1..-1] * "\n"
23
+ end
24
+ when 'list'
25
+ TSV.traverse file, :type => :array, :into => :stream do |line|
26
+ next if line =~ /^#/
27
+ line.split("\t")[pos]
28
+ end
29
+ end
30
+ end
31
+
4
32
  def self.guess_id(identifier_file, values, options = {})
5
33
  field_matches = TSV.field_match_counts(identifier_file, values, options)
6
34
  field_matches.sort_by{|field, count| count.to_i}.last
7
35
  end
8
36
 
9
-
10
37
  def self.field_match_counts(file, values, options = {})
11
38
  options = Misc.add_defaults options, :persist_prefix => "Field_Matches"
12
39
  persist_options = Misc.pull_keys options, :persist
@@ -203,33 +203,48 @@ module Misc
203
203
 
204
204
 
205
205
  def self.translate_dna_mutation_hgvs2rbbt(cds)
206
- change = case
207
- when cds =~ />/
208
- cds.split(">").last
209
- when cds =~ /del/
210
- deletion = cds.split("del").last.chomp
206
+ change = begin
211
207
  case
212
- when deletion =~ /^\d+$/
213
- "-" * deletion.to_i
214
- when deletion =~ /^[ACTG]+$/i
215
- "-" * deletion.length
216
- else
217
- Log.debug "Unknown deletion: #{ deletion }"
218
- deletion
219
- end
220
- when cds =~ /ins/
221
- insertion = cds.split("ins").last
222
- case
223
- when insertion =~ /^\d+$/
224
- "+" + "N" * insertion.to_i
225
- when insertion =~ /^[NACTG]+$/i
226
- "+" + insertion
208
+ when cds =~ />/
209
+ cds.split(">").last
210
+ when cds =~ /delins/
211
+ del, ins = cds.split("delins")
212
+ start, eend = del.split("_")
213
+ del_size = eend.to_i - start.to_i + 1
214
+ if ins =~ /^[ACTG]+$/i
215
+ ("-" * del_size) + ins
216
+ else
217
+ Log.debug "Unknown delins: #{ cds }"
218
+ "?(" << cds << ")"
219
+ end
220
+ when cds =~ /del/
221
+ deletion = cds.split("del").last.chomp
222
+ case
223
+ when deletion =~ /^\d+$/
224
+ "-" * deletion.to_i
225
+ when deletion =~ /^[ACTG]+$/i
226
+ "-" * deletion.length
227
+ else
228
+ Log.debug "Unknown deletion: #{ cds }"
229
+ "?(" << cds << ")"
230
+ end
231
+ when cds =~ /ins/
232
+ insertion = cds.split("ins").last
233
+ case
234
+ when insertion =~ /^\d+$/
235
+ "+" + "N" * insertion.to_i
236
+ when insertion =~ /^[NACTG]+$/i
237
+ "+" + insertion
238
+ else
239
+ Log.debug "Unknown insertion: #{cds }"
240
+ "?(" << cds << ")"
241
+ end
227
242
  else
228
- Log.debug "Unknown insertion: #{insertion }"
229
- insertion
243
+ Log.debug "Unknown change: #{cds}"
244
+ "?(" << cds << ")"
230
245
  end
231
- else
232
- Log.debug "Unknown change: #{cds}"
246
+ rescue
247
+ Log.debug "Error processing change: #{cds}"
233
248
  "?(" << cds << ")"
234
249
  end
235
250
  change
@@ -323,11 +338,11 @@ module Misc
323
338
  line.partition(sep).last
324
339
  end
325
340
  end
326
-
341
+
327
342
  def self.sort_genomic_locations_strict(stream, sep = ":")
328
343
  sort_stream(stream, '#', "-k1,1V -k2,2n -t#{sep}")
329
344
  end
330
-
345
+
331
346
  def self.sort_genomic_locations(stream, sep = ":")
332
347
  sort_stream(stream, '#', "-k1,1 -k2,2n -t#{sep}")
333
348
  end
@@ -483,7 +498,7 @@ module Misc
483
498
  sin << [chr, start, eend, id] * "\t" << "\n"
484
499
  end
485
500
  end
486
-
501
+
487
502
  TmpFile.with_file do |tmpfile|
488
503
  Misc.consume_stream(nio, false, tmpfile)
489
504
 
@@ -145,7 +145,11 @@ class Step
145
145
  end
146
146
 
147
147
  def input_dependencies
148
- @input_dependencies ||= (recursive_inputs.flatten.select{|i| Step === i } + recursive_inputs.flatten.select{|dep| Path === dep && Step === dep.resource }.collect{|dep| dep.resource })
148
+ @input_dependencies ||= (recursive_inputs.flatten.select{|i| Step === i } +
149
+ recursive_inputs.flatten.
150
+ select{|dep| Path === dep && Step === dep.resource }.
151
+ select{|dep| ! dep.resource.started? }. # Ignore input_deps already started
152
+ collect{|dep| dep.resource })
149
153
  end
150
154
 
151
155
  def execute_dependency(dependency, log = true)
@@ -16,22 +16,22 @@ class TestMiscOmics < Test::Unit::TestCase
16
16
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.209+1delGTAA"), "----"
17
17
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.371_397del27"), "---------------------------"
18
18
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1359+2_1359+11delTTAGAAGAGC"), "----------"
19
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.ins?"), "?"
20
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins?"), "?"
21
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.184_185ins?"), "?"
19
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.ins?"), "?(c.ins?)"
20
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins?"), "?(c.?_?ins?)"
21
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.184_185ins?"), "?(c.184_185ins?)"
22
22
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins57"), "+NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
23
23
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?insCT"), "+CT"
24
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?del?"), "?"
24
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?del?"), "?(c.?_?del?)"
25
25
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?"), "?(c.?)"
26
26
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(312)?"), "?(c.(312)?)"
27
27
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(1669_1671)>?"), "?"
28
28
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1050-?"), "?(c.1050-?)"
29
29
  assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(1347_1540)?"), "?(c.(1347_1540)?)"
30
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_850+?del"), "c.1-?_850+?"
31
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.2289_?del(7236)"), "(7236)"
32
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(3916_3927)del?"), "?"
33
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1705_?del?"), "?"
34
- assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_421+?del"), "c.1-?_421+?"
30
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_850+?del"), "?(c.1-?_850+?del)"
31
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.2289_?del(7236)"), "?(c.2289_?del(7236))"
32
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(3916_3927)del?"), "?(c.(3916_3927)del?)"
33
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1705_?del?"), "?(c.1705_?del?)"
34
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-?_421+?del"), "?(c.1-?_421+?del)"
35
35
  end
36
36
 
37
37
  def test_translate_prot_mutation_hgvs2rbbt
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.33.16
4
+ version: 5.33.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake