rbbt-util 5.20.8 → 5.20.9

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: 72d3825a7d4644c54b8498b2649e8820d610bef2
4
- data.tar.gz: 02157c505e0f582a7b3cf4517ec590b124734602
3
+ metadata.gz: 0dfd6e2f34b010a55ef904fe69c5d2f5d5c85363
4
+ data.tar.gz: b1b7fd04c9c94d2ec1a1c16cc4e883536f7a3500
5
5
  SHA512:
6
- metadata.gz: e04bcbe557031df6d184336aa9ac8c2dfab9c33f509f4b81d8cf8fd6264a5fb01fc9c360fa9c35a5855a0a485642acdd29e201956f1ffe38f1a2af7f23b19c42
7
- data.tar.gz: 040f5b2771c9b0037e64fc2b31f26e77855cab32c40406f1a978ec52cd8379df348b3feef701dc9e051db65b931bc8764a7e3067c9491547298365f34ca448ce
6
+ metadata.gz: e75cedcb0a224bdd4eb897578ed8bd08ef68b6b0c2196fb37bc31855457045d93dffa82d271ccaa47285df1b6395cd87b97a190f49cd4943a934f0ee903abb4e
7
+ data.tar.gz: dbf542a2d17b31f6975e8d3bc1fa53739d1fcc95c9aa9f805b2609833aff38fb8d0f8851ee90791434066e9165eaab4f636632868cdab7916cb43a9dc56da8a2
@@ -148,11 +148,11 @@ module Misc
148
148
  if ref == '-'
149
149
  res = '+' + m
150
150
  else
151
- res = '-' * ref.length
151
+ res = '-' * ref.length
152
152
  res << m unless m == '-'
153
153
  end
154
154
  Log.debug{"Non-standard annotation: #{[ref, m]} (#{ muts }) => #{ res }"}
155
-
155
+
156
156
  res
157
157
  end
158
158
  end
@@ -183,11 +183,11 @@ module Misc
183
183
  if ref == '-'
184
184
  res = '+' + m
185
185
  else
186
- res = '-' * ref.length
186
+ res = '-' * ref.length
187
187
  res << m unless m == '-'
188
188
  end
189
189
  Log.debug{"Non-standard annotation: #{[ref, m]} (#{ muts }) => #{ res }"}
190
-
190
+
191
191
  res
192
192
  end
193
193
  end
@@ -195,6 +195,72 @@ module Misc
195
195
  [pos, muts]
196
196
  end
197
197
 
198
+
199
+ def self.translate_dna_mutation_hgvs2rbbt(cds)
200
+ change = case
201
+ when cds =~ />/
202
+ cds.split(">").last
203
+ when cds =~ /del/
204
+ deletion = cds.split("del").last
205
+ case
206
+ when deletion =~ /^\d+$/
207
+ "-" * deletion.to_i
208
+ when deletion =~ /^[ACTG]+$/i
209
+ "-" * deletion.length
210
+ else
211
+ Log.debug "Unknown deletion: #{ deletion }"
212
+ deletion
213
+ end
214
+ when cds =~ /ins/
215
+ insertion = cds.split("ins").last
216
+ case
217
+ when insertion =~ /^\d+$/
218
+ "+" + "N" * insertion.to_i
219
+ when insertion =~ /^[NACTG]+$/i
220
+ "+" + insertion
221
+ else
222
+ Log.debug "Unknown insertion: #{insertion }"
223
+ insertion
224
+ end
225
+ else
226
+ Log.debug "Unknown change: #{cds}"
227
+ "?(" << cds << ")"
228
+ end
229
+ change
230
+ end
231
+
232
+ def self.translate_prot_mutation_hgvs2rbbt(mutation)
233
+ one_aa_code = THREE_TO_ONE_AA_CODE.values
234
+ one_aa_code << "X" << "B" << "Z" << "J" << "*" << "?"
235
+ one_aa_code_re = one_aa_code*""
236
+ subs = Regexp.new("^[#{one_aa_code_re}]\\d+[#{one_aa_code_re}]")
237
+ f_aa = Regexp.new("^[#{one_aa_code_re}]\\d+")
238
+ mutation.sub!('p.', '')
239
+ mutation = case
240
+ when mutation =~ subs
241
+ mutation
242
+ when mutation =~ /fs/
243
+ mutation =~ f_aa
244
+ if Regexp.last_match(0).nil?
245
+ Log.debug "Unknown Frameshift: #{mutation}"
246
+ nil
247
+ else
248
+ Regexp.last_match(0) + "Frameshift"
249
+ end
250
+ when mutation =~ /ins|del|>/
251
+ mutation =~ f_aa
252
+ if Regexp.last_match(0).nil?
253
+ Log.debug "Unknown Indel"
254
+ nil
255
+ else
256
+ Regexp.last_match(0) + "Indel"
257
+ end
258
+ else
259
+ Log.debug "Unknown change: #{mutation}"
260
+ nil
261
+ end
262
+ end
263
+
198
264
  def self.IUPAC_to_base(iupac)
199
265
  IUPAC2BASE[iupac]
200
266
  end
@@ -286,7 +352,7 @@ module Misc
286
352
  pos2 = f2.pos
287
353
 
288
354
  sline2, schr2, sstart2, seend2, srest2 = line2, chr2, start2, eend2, rest2
289
- while chr1 == chr2 and ((start1 <= eend2 and eend1 >= start2))
355
+ while chr1 == chr2 and ((start1 <= eend2 and eend1 >= start2))
290
356
  out.puts line1 + "\t" + line2
291
357
  if f2.eof?
292
358
  chr2 = 'next2'
@@ -294,7 +360,7 @@ module Misc
294
360
  line2, chr2, start2, eend2, rest2 = intersect_streams_read(f2,sep)
295
361
  end
296
362
  end
297
- line2, chr2, start2, eend2, rest2 = sline2, schr2, sstart2, seend2, srest2
363
+ line2, chr2, start2, eend2, rest2 = sline2, schr2, sstart2, seend2, srest2
298
364
  f2.seek(pos2)
299
365
  move = 1
300
366
  end
@@ -0,0 +1,68 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
2
+ require 'test/unit'
3
+ require 'rbbt/util/misc/omics'
4
+
5
+ class TestMiscOmics < Test::Unit::TestCase
6
+
7
+ def test_translate_dna_mutation_hgvs2rbbt
8
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.395G>A"), "A"
9
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1-124C>T"), "T"
10
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.639+6T>A"), "A"
11
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.3386-2A>G"), "G"
12
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.4090_4091insT"), "+T"
13
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.533_534insGGGG"), "+GGGG"
14
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.4249_4249delC"), "-"
15
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.464-2_465delAGTG"), "----"
16
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.209+1delGTAA"), "----"
17
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.371_397del27"), "---------------------------"
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?"), "?"
22
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?ins57"), "+NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"
23
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?insCT"), "+CT"
24
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?_?del?"), "?"
25
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.?"), "?(c.?)"
26
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(312)?"), "?(c.(312)?)"
27
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.(1669_1671)>?"), "?"
28
+ assert_equal Misc.translate_dna_mutation_hgvs2rbbt("c.1050-?"), "?(c.1050-?)"
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+?"
35
+ end
36
+
37
+ def test_translate_prot_mutation_hgvs2rbbt
38
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E255K"), "E255K"
39
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E279Z"), "E279Z"
40
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.R132?"), "R132?"
41
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.*757?"), "*757?"
42
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.A2216>?"), "A2216Indel"
43
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.M552_W557>Z"), "M552Indel"
44
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.T1151_L1152insT"), "T1151Indel"
45
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.N771_P772ins?"), "N771Indel"
46
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.T310_?insKAAQRGA"), "T310Indel"
47
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.D579del"), "D579Indel"
48
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.E746_A750delELREA"), "E746Indel"
49
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.P14fs*?"), "P14Frameshift"
50
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.*588fs?"), "*588Frameshift"
51
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs*(46_47)"), nil
52
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(A443)fs*?"), nil
53
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(574_1542)fs*?"), nil
54
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs"), nil
55
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.fs*?"), nil
56
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?fs*?"), nil
57
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(P1249)fs*?"), nil
58
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?"), nil
59
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.WQQSYLD25?"), nil
60
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(449_514)?"), nil
61
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("?"), nil
62
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.0?"), nil
63
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?_?ins?"), nil
64
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?_?insXXXX"), nil
65
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.(A775)ins?"), nil
66
+ assert_equal Misc.translate_prot_mutation_hgvs2rbbt("p.?del"), nil
67
+ end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.20.8
4
+ version: 5.20.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
@@ -433,6 +433,7 @@ files:
433
433
  - test/rbbt/util/misc/test_bgzf.rb
434
434
  - test/rbbt/util/misc/test_lock.rb
435
435
  - test/rbbt/util/misc/test_multipart_payload.rb
436
+ - test/rbbt/util/misc/test_omics.rb
436
437
  - test/rbbt/util/misc/test_pipes.rb
437
438
  - test/rbbt/util/simpleopt/test_get.rb
438
439
  - test/rbbt/util/simpleopt/test_parse.rb
@@ -495,6 +496,7 @@ test_files:
495
496
  - test/rbbt/util/misc/test_multipart_payload.rb
496
497
  - test/rbbt/util/misc/test_bgzf.rb
497
498
  - test/rbbt/util/misc/test_pipes.rb
499
+ - test/rbbt/util/misc/test_omics.rb
498
500
  - test/rbbt/util/test_concurrency.rb
499
501
  - test/rbbt/util/test_R.rb
500
502
  - test/rbbt/util/log/test_progress.rb