bio-gadget 0.4.4 → 0.4.5

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: 9bf862ca4bbf3f563456a0285f3e690a08fc2556
4
- data.tar.gz: 4d4956c35b4d96374d7a73f24b37fe48dc053bfa
3
+ metadata.gz: 99193f8b25625a2260acdce7e27c0a5af6f66b93
4
+ data.tar.gz: 99e00b24de7f37937725d09d52faaf74226b7099
5
5
  SHA512:
6
- metadata.gz: e3565824e2b4dd2b7cd328e5ade202f350d8edf29e71377e502aaff7402a9266c62f833239d9596b3c2551375b703b5db89e4cb8887acba222b23aef6b41fe89
7
- data.tar.gz: 4851e1c1047ccc59e4862ba6e965b84f5dc609f926c497e0a9cbc1964bfd4d548961d9a545e5fbbce1906b743cb0cfd309d6c634b2fe846cd3094f6da182460a
6
+ metadata.gz: 78156bea1d87f720078f385f1f5032970338e4884bfb64fa147853cc06b1581e5902b5ee6ce2523a9b149234b73d51e5040267cd9698e29cc020a35db90cdbd7
7
+ data.tar.gz: 4e2d0ab4eb9841809f4fd32ccd2439908c8099dc85f277662aa79a53212afcfe49ef6e9dc2595e883dc0ed4ec831f0b849e3573aafa804a430e17aefd0eb5e99
@@ -2,10 +2,31 @@ module Bio
2
2
  class Gadget < Thor
3
3
 
4
4
  desc 'rgt2mtx [RGT]', <<DESC
5
- Convert cuffdiff read group tracking file into tab-separated matrix. If no given name of tracking file, it reads from standard input.
5
+ Convert cuffdiff read group tracking file (*.read_group_tracking) into tab-separated matrix. If no given name of tracking file, it reads from standard input.
6
6
  DESC
7
+ option 'gtf', :aliases => '-g', :type => :string, :desc => 'GTF to revert old transcript_id (oId) renamed by cuffcompare. Moreover, "RNA_SPIKE_*" chromosome names will be inserted for the transcripts aligned on the forward strand of spike-in sequences.'
8
+ option 'sample', :aliases => '-s', :type => :string, :desc => 'Mapping from condition/replicate to sample ID for the column names of output matrix. Tab-separated text with three columns of condition, replicate and the sample ID.'
7
9
  def rgt2mtx(rgt="/dev/stdin")
8
10
 
11
+ tid2oid = Hash.new
12
+ unless options['gtf'].nil?
13
+ open(options['gtf']).each { |line|
14
+ cols = line.rstrip.split(/\t/)
15
+ tid = cols[8].match(/transcript_id \"([^\"]+)/).to_a[1]
16
+ oid = cols[8].match(/oId \"([^\"]+)/).to_a[1]
17
+ oid = "#{cols[0]}.#{oid}" if cols[0] =~ /^RNA_SPIKE_/
18
+ tid2oid[tid] = oid
19
+ }
20
+ end
21
+
22
+ cr2sid = Hash.new
23
+ unless options['sample'].nil?
24
+ open(options['sample']).each { |line|
25
+ c, r, sid = line.rstrip.split(/\t/)
26
+ cr2sid["#{c}|#{r}"] = sid
27
+ }
28
+ end
29
+
9
30
  id = nil
10
31
  header = true
11
32
  raws = Hash.new
@@ -14,10 +35,16 @@ DESC
14
35
  id = cols[0] if id.nil?
15
36
  if id != cols[0]
16
37
  if header
17
- puts (['tracking_id'] + raws.keys.sort).join("\t")
38
+ if options['sample'].nil?
39
+ puts ([''] + raws.keys.sort).join("\t")
40
+ else
41
+ tmp = ['']
42
+ raws.keys.sort.each { |cr| tmp.push(cr2sid[cr]) }
43
+ puts tmp.join("\t")
44
+ end
18
45
  header = false
19
46
  end
20
- tmp = [id]
47
+ tmp = [tid2oid.key?(id) ? tid2oid[id] : id]
21
48
  raws.keys.sort.each { |k| tmp.push(raws[k]) }
22
49
  puts tmp.join("\t")
23
50
  id = cols[0]
@@ -3,7 +3,7 @@ require 'thor'
3
3
  module Bio
4
4
  class Gadget < Thor
5
5
 
6
- VERSION = "0.4.4"
6
+ VERSION = "0.4.5"
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.4
4
+ version: 0.4.5
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-04-30 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor