bio-gadget 0.4.7 → 0.4.8

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: 993d87f1638e12bc336223e98be4dbeeeb5a8404
4
- data.tar.gz: 95cb2d5cba5cc230d960bc0c558b3f1b1b562753
3
+ metadata.gz: 919243e81fb8eecaf1e9af9f85914439f3aa27d5
4
+ data.tar.gz: 5c1a8c551f09e46857720493b9495fe499778d27
5
5
  SHA512:
6
- metadata.gz: ec8586c5e171b700596500bfbf16a9467bc65c6dd2dff2c5bd0e4b34f4775e40322cc1eecb00c81745c514edf3e59fedb8f9cb57a12586dcce4d08e6b87d24dd
7
- data.tar.gz: da97c93be8331cf0048dd6e99cf6d66debc9985797ec909f6c2c908a6904667df2507e2170460632a5bd58a18dde44acd465843d03e572b4c55c9773fa9223f6
6
+ metadata.gz: 20827e3e37d7360508c52b49d3f4ccfb0b034a647656088c56f9aedd1015794ce766a6069b3b48fd18285461488de9bec764753e141752156c354b3c91e3fe5a
7
+ data.tar.gz: aae01b065bf04def5d836cfc18c2b3ada4d8c8210f23d2b26796d32cffbfaebd2c0e20b5bad4a69e2cd5dc68e243c04921cdbe1587c3ae0560881c0238bbee75
@@ -1,3 +1,6 @@
1
+ require 'mkfifo'
2
+ require 'parallel'
3
+
1
4
  module Bio
2
5
  class Gadget < Thor
3
6
 
@@ -24,6 +27,7 @@ DESC
24
27
  fp.close
25
28
  }
26
29
 
30
+ chr2exon = Hash.new
27
31
  open("| grep exon #{gtf}").each { |line|
28
32
  cols = line.rstrip.split(/\t/)
29
33
  oid = cols[8].match(/oId \"([^\"]+)/).to_a[1]
@@ -33,35 +37,56 @@ DESC
33
37
  str = cols[6]
34
38
  start = cols[3].to_i
35
39
  stop = cols[4].to_i
36
- peak = ''
40
+ chr2exon[chr] = Array.new unless chr2exon.key?(chr)
41
+ chr2exon[chr].push([str, oid, exn, start, stop])
42
+ }
43
+
44
+ fifopath = mytemppath('fifo-')
45
+ File.mkfifo(fifopath)
46
+
47
+ pid = Kernel.fork {
48
+ exec "cat #{fifopath}"
49
+ }
50
+
51
+ fp = open(fifopath, 'w')
52
+ Parallel.each(chr2exon.keys,
53
+ :in_processes => Parallel.processor_count) { |chr|
37
54
  #
38
- poss = Hash.new
39
- nchrpos2val.each { |n, chrpos2val|
40
- if chrpos2val.key?(chr)
41
- pos2val = chrpos2val[chr]
42
- tmppos2val = Hash.new
43
- pos2val.each { |pos, val|
44
- tmppos2val[pos] = val if start <= pos && pos <= stop
45
- }
46
- if tmppos2val.size > 0
47
- tmpposs = tmppos2val.keys.sort { |a, b|
48
- tmppos2val[b] == tmppos2val[a] ? (str == '+' ? (a <=> b) : (b <=> a)) : (tmppos2val[b] <=> tmppos2val[a])
55
+ chr2exon[chr].each { |str, oid, exn, start, stop|
56
+ #
57
+ peak = ''
58
+ poss = Hash.new
59
+ nchrpos2val.each { |n, chrpos2val|
60
+ if chrpos2val.key?(chr)
61
+ pos2val = chrpos2val[chr]
62
+ tmppos2val = Hash.new
63
+ pos2val.each { |pos, val|
64
+ tmppos2val[pos] = val if start <= pos && pos <= stop
49
65
  }
50
- tmppos = tmpposs[0]
51
- # puts "#{n} | #{chr}:#{start}-#{stop} #{str} | #{tmpposs}"
52
- poss[tmppos] = poss.key?(tmppos) ? poss[tmppos]+1 : 1
66
+ if tmppos2val.size > 0
67
+ tmpposs = tmppos2val.keys.sort { |a, b|
68
+ tmppos2val[b] == tmppos2val[a] ? (str == '+' ? (a <=> b) : (b <=> a)) : (tmppos2val[b] <=> tmppos2val[a])
69
+ }
70
+ tmppos = tmpposs[0]
71
+ # puts "#{n} | #{chr}:#{start}-#{stop} #{str} | #{tmpposs}"
72
+ poss[tmppos] = poss.key?(tmppos) ? poss[tmppos]+1 : 1
73
+ end
53
74
  end
75
+ }
76
+ if poss.size > 0
77
+ peaks = poss.keys.sort { |a, b|
78
+ poss[b] == poss[a] ? (str == '+' ? (a <=> b) : (b <=> a)) : (poss[b] <=> poss[a])
79
+ }
80
+ peak = peaks[0]
54
81
  end
82
+ #
83
+ fp.syswrite([oid, exn, peak].join("\t") + "\n")
55
84
  }
56
- if poss.size > 0
57
- peaks = poss.keys.sort { |a, b|
58
- poss[b] == poss[a] ? (str == '+' ? (a <=> b) : (b <=> a)) : (poss[b] <=> poss[a])
59
- }
60
- peak = peaks[0]
61
- end
62
85
  #
63
- puts [oid, exn, peak].join("\t")
64
86
  }
87
+ fp.close
88
+
89
+ Process.waitall
65
90
 
66
91
  end
67
92
 
@@ -3,7 +3,7 @@ require 'thor'
3
3
  module Bio
4
4
  class Gadget < Thor
5
5
 
6
- VERSION = "0.4.7"
6
+ VERSION = "0.4.8"
7
7
 
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-gadget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Katayama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-30 00:00:00.000000000 Z
11
+ date: 2013-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor