bio-gadget 0.4.6 → 0.4.7
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 +4 -4
- data/README.org +1 -0
- data/lib/bio-gadget.rb +1 -0
- data/lib/bio-gadget/peak.rb +69 -0
- data/lib/bio-gadget/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 993d87f1638e12bc336223e98be4dbeeeb5a8404
|
|
4
|
+
data.tar.gz: 95cb2d5cba5cc230d960bc0c558b3f1b1b562753
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/bio-gadget.rb
CHANGED
|
@@ -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
|
data/lib/bio-gadget/version.rb
CHANGED
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.
|
|
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-
|
|
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
|