bio-gadget 0.4.6 → 0.4.7

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: dca3c35773b7e985b12c3e938d30bec303e0c5cf
4
- data.tar.gz: d275ccd3b2f266af95406754876da216c0132237
3
+ metadata.gz: 993d87f1638e12bc336223e98be4dbeeeb5a8404
4
+ data.tar.gz: 95cb2d5cba5cc230d960bc0c558b3f1b1b562753
5
5
  SHA512:
6
- metadata.gz: f2892f0584f058a6a3d640486b4526f59aa3608094bf8f11b481223944b7749ce90e877ee01a7e2e93300cbe8e6158f12499d8ba75ebc5f125cbfd6eb8b1db6c
7
- data.tar.gz: 727a99f599f994d75fd1b0b1e32834b566d29819e41473e2421c564bbbed309a6c73aa8685498f52f920fdb9795a92ab2c2eef3f8a61e8ce297a683eccabd529
6
+ metadata.gz: ec8586c5e171b700596500bfbf16a9467bc65c6dd2dff2c5bd0e4b34f4775e40322cc1eecb00c81745c514edf3e59fedb8f9cb57a12586dcce4d08e6b87d24dd
7
+ data.tar.gz: da97c93be8331cf0048dd6e99cf6d66debc9985797ec909f6c2c908a6904667df2507e2170460632a5bd58a18dde44acd465843d03e572b4c55c9773fa9223f6
data/README.org CHANGED
@@ -18,6 +18,7 @@ Currently available commands are
18
18
  - demlt :: Demultiplex fastq by barcodes
19
19
  - femrg :: Extract and merge first exons
20
20
  - fqxz :: (Re)compression of *.fq(.gz|.bz2) files
21
+ - pead :: Find peak within each exon from wigs by a mojority vote.
21
22
  - qvstat :: Statistics of quality values in *.qual file
22
23
  - rgt2mtx :: Convert cuffdiff read group tracking file into tab-separated matrix
23
24
  - wig5p :: Convert bam-format alignments into wig-format table
@@ -3,6 +3,7 @@ require 'bio-gadget/dedup'
3
3
  require 'bio-gadget/demlt'
4
4
  require 'bio-gadget/femrg'
5
5
  require 'bio-gadget/fqxz'
6
+ require 'bio-gadget/peak'
6
7
  require 'bio-gadget/qvstat'
7
8
  require 'bio-gadget/rgt2mtx'
8
9
  require 'bio-gadget/wig5p'
@@ -0,0 +1,69 @@
1
+ module Bio
2
+ class Gadget < Thor
3
+
4
+ desc 'peak WIG1,WIG2,... [GTF]', <<DESC
5
+ Find peak within each exon from (gzipped) variableStep wigs by a majority vote. It will read from a standard input if no GTF option.
6
+ DESC
7
+ def peak(wigs, gtf="/dev/stdin")
8
+
9
+ nchrpos2val = Hash.new
10
+ wigs.split(/,/).each { |wig|
11
+ n = wigs.split(/,/).index(wig)
12
+ nchrpos2val[n] = Hash.new unless nchrpos2val.key?(n)
13
+ chr = ''
14
+ fp = open("| zcat #{wig} | grep -v ^track")
15
+ fp.each { |line|
16
+ cols = line.rstrip.split(/\s+/)
17
+ if cols[0] == 'variableStep'
18
+ chr = cols[1].match(/chrom=(\S+)$/).to_a[1]
19
+ nchrpos2val[n][chr] = Hash.new unless nchrpos2val[n].key?(chr)
20
+ else
21
+ nchrpos2val[n][chr][cols[0].to_i] = cols[1].to_f
22
+ end
23
+ }
24
+ fp.close
25
+ }
26
+
27
+ open("| grep exon #{gtf}").each { |line|
28
+ cols = line.rstrip.split(/\t/)
29
+ oid = cols[8].match(/oId \"([^\"]+)/).to_a[1]
30
+ oid = "#{cols[0]}.#{oid}" if cols[0] =~ /^RNA_SPIKE_/
31
+ exn = cols[8].match(/exon_number \"(\d+)\"/).to_a[1]
32
+ chr = cols[0]
33
+ str = cols[6]
34
+ start = cols[3].to_i
35
+ stop = cols[4].to_i
36
+ peak = ''
37
+ #
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])
49
+ }
50
+ tmppos = tmpposs[0]
51
+ # puts "#{n} | #{chr}:#{start}-#{stop} #{str} | #{tmpposs}"
52
+ poss[tmppos] = poss.key?(tmppos) ? poss[tmppos]+1 : 1
53
+ end
54
+ end
55
+ }
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
+ #
63
+ puts [oid, exn, peak].join("\t")
64
+ }
65
+
66
+ end
67
+
68
+ end
69
+ end
@@ -3,7 +3,7 @@ require 'thor'
3
3
  module Bio
4
4
  class Gadget < Thor
5
5
 
6
- VERSION = "0.4.6"
6
+ VERSION = "0.4.7"
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.6
4
+ version: 0.4.7
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-03 00:00:00.000000000 Z
11
+ date: 2013-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -101,6 +101,7 @@ files:
101
101
  - lib/bio-gadget/demlt.rb
102
102
  - lib/bio-gadget/femrg.rb
103
103
  - lib/bio-gadget/fqxz.rb
104
+ - lib/bio-gadget/peak.rb
104
105
  - lib/bio-gadget/qvstat.rb
105
106
  - lib/bio-gadget/rgt2mtx.rb
106
107
  - lib/bio-gadget/version.rb