transrate 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/transrate +129 -77
  3. data/lib/transrate/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 691eaf0cbf7a2273841277680178a34cd0801bd7
4
- data.tar.gz: 1a84acd029aa35ae1e89b39ad8fed7c08397aed0
3
+ metadata.gz: 11e11ad4e926162c2f5abf2a77c77be603dee85a
4
+ data.tar.gz: cd9d544e1ab00d43314bba1b3fcebf2fb9cac2f9
5
5
  SHA512:
6
- metadata.gz: 9b6ed04d9d95a3997585051ca38d427b4f47385097258e7fe60dc040a222dbd372373d9ed246163dc1d2fac5fa4d2e5e0f8397c2b6702258ec6ce3340510bc01
7
- data.tar.gz: 95bec4a0beb4bd1a7d94a81ec94a91f06f3f9bb8e07bbe8f85450a6f31d65d0ab938a3d40b462999e21eecf02759e1e796fa2593de7970b5d2f09e50e4e39f98
6
+ metadata.gz: 39385d5c1e6badec90cfc732cd50daa78a38fb7756ccd97223dfcc512de2445c04cdb03c79910e367c2f141653d33a298325d67565e13d4ee5b0fde0a424ae66
7
+ data.tar.gz: 75b91afe62981e0b71e16fb9e80325ba7950f44d2b81716565d123bef591085f3b273d44d1ed75882b25533724ae2e6a86efa3c500a0c3f3ee96bf3efa9ef13e
data/bin/transrate CHANGED
@@ -2,37 +2,53 @@
2
2
 
3
3
  require 'trollop'
4
4
  require 'transrate'
5
+ require 'csv'
5
6
 
6
7
  opts = Trollop::options do
7
8
  version Transrate::VERSION::STRING.dup
8
9
  banner <<-EOS
9
10
 
10
- Transrate v#{Transrate::VERSION::STRING.dup} by Richard Smith <rds45@cam.ac.uk>
11
-
12
- DESCRIPTION:
13
- Analyse a de-novo transcriptome
14
- assembly using three kinds of metrics:
15
-
16
- 1. contig-based
17
- 2. read-mapping (if --left and --right are provided)
18
- 3. reference-based (if --reference is provided)
19
-
20
- Bug reports and feature requests at:
21
- http://github.com/blahah/transrate
22
-
23
- USAGE:
24
- transrate <options>
25
-
26
- OPTIONS:
27
-
28
- EOS
29
- opt :assembly, "assembly file in FASTA format", :required => true, :type => String
30
- opt :reference, "reference proteome file in FASTA format", :type => String
31
- opt :left, "left reads file in FASTQ format", :type => String
32
- opt :right, "right reads file in FASTQ format", :type => String
33
- opt :insertsize, "mean insert size", :default => 200, :type => Integer
34
- opt :insertsd, "insert size standard deviation", :default => 50, :type => Integer
35
- opt :threads, "number of threads to use", :default => 8, :type => Integer
11
+ Transrate v#{Transrate::VERSION::STRING.dup} by Richard Smith <rds45@cam.ac.uk>
12
+
13
+ DESCRIPTION:
14
+ Analyse a de-novo transcriptome
15
+ assembly using three kinds of metrics:
16
+
17
+ 1. contig-based
18
+ 2. read-mapping (if --left and --right are provided)
19
+ 3. reference-based (if --reference is provided)
20
+
21
+ Bug reports and feature requests at:
22
+ http://github.com/blahah/transrate
23
+
24
+ USAGE:
25
+ transrate <options>
26
+
27
+ EXAMPLES:
28
+ transrate --assembly contigs.fa --reference Athaliana_protein.fa --threads 8
29
+
30
+ OPTIONS:
31
+
32
+ EOS
33
+ opt :assembly, "assembly file(s) in FASTA format, comma-separated",
34
+ :required => true,
35
+ :type => String
36
+ opt :reference, "reference proteome file in FASTA format",
37
+ :type => String
38
+ opt :left, "left reads file in FASTQ format",
39
+ :type => String
40
+ opt :right, "right reads file in FASTQ format",
41
+ :type => String
42
+ opt :insertsize, "mean insert size",
43
+ :default => 200,
44
+ :type => Integer
45
+ opt :insertsd, "insert size standard deviation",
46
+ :default => 50,
47
+ :type => Integer
48
+ opt :threads, "number of threads to use",
49
+ :default => 8,
50
+ :type => Integer
51
+ opt :quiet, "don't print results - only save to file"
36
52
  end
37
53
 
38
54
  def pretty_print_hash hash, width
@@ -48,72 +64,108 @@ def pretty_print_hash hash, width
48
64
  end.join("\n")
49
65
  end
50
66
 
67
+ # don't log if --quiet is set
68
+ $quiet = opts.quiet
69
+ def log msg
70
+ unless $quiet
71
+ puts msg
72
+ end
73
+ end
74
+
51
75
  include Transrate
52
76
 
53
- a = Assembly.new opts.assembly
54
77
  r = opts.reference ? Assembly.new(opts.reference) : nil
78
+ report_width = 30
55
79
 
56
- transrater = Transrater.new(a, r,
57
- opts.left,
58
- opts.right,
59
- opts.insertsize,
60
- opts.insertsd)
80
+ # loop through the assemblies, storing their outputs in an array of hashes
81
+ all = []
82
+ opts.assembly.split(',').each do |assembly|
61
83
 
62
- puts "\nAnalysing assembly: #{opts.assembly}\n\n"
84
+ a = Assembly.new assembly
63
85
 
64
- report_width = 30
86
+ transrater = Transrater.new(a, r,
87
+ opts.left,
88
+ opts.right,
89
+ opts.insertsize,
90
+ opts.insertsd)
65
91
 
66
- puts "Calculating contig metrics..."
67
- t0 = Time.now
68
- contig_results = transrater.assembly_metrics.basic_stats
92
+ log "\nAnalysing assembly: #{assembly}\n\n"
69
93
 
70
- if contig_results
71
- puts "\n"
72
- puts "Contig metrics:"
73
- puts "-" * report_width
74
- puts pretty_print_hash(contig_results, report_width)
75
- end
94
+ contig_results = {}
76
95
 
77
- puts "Contig metrics done in #{Time.now - t0} seconds"
78
-
79
- read_results = nil
80
- if (opts.left && opts.right)
81
- puts "\ncalculating read diagnostics..."
96
+ log "Calculating contig metrics..."
82
97
  t0 = Time.now
83
- read_results = transrater.read_metrics(opts.left, opts.right).read_stats
98
+ contig_results = transrater.assembly_metrics.basic_stats
84
99
 
85
- if read_results
86
- puts "\n"
87
- puts "Read mapping metrics:"
88
- puts "-" * report_width
89
- puts pretty_print_hash(read_results, report_width)
100
+ if contig_results
101
+ log "\n"
102
+ log "Contig metrics:"
103
+ log "-" * report_width
104
+ log pretty_print_hash(contig_results, report_width)
90
105
  end
91
106
 
92
- puts "Read metrics done in #{Time.now - t0} seconds"
93
- else
94
- puts "\nNo reads provided, skipping read diagnostics"
95
- end
107
+ log "Contig metrics done in #{Time.now - t0} seconds"
96
108
 
97
- if opts.reference
98
- puts "\nCalculating comparative metrics..."
99
- t0 = Time.now
100
- comparative_metrics = transrater.comparative_metrics
101
- comparative_results = comparative_metrics.comp_stats
102
-
103
- if comparative_results
104
- puts "\n"
105
- puts "Comparative metrics:"
106
- puts "-" * report_width
107
- puts pretty_print_hash(comparative_results, report_width)
109
+ read_results = {}
110
+
111
+ if (opts.left && opts.right)
112
+ log "\ncalculating read diagnostics..."
113
+ t0 = Time.now
114
+ read_results = transrater.read_metrics(opts.left, opts.right).read_stats
115
+
116
+ if read_results
117
+ log "\n"
118
+ log "Read mapping metrics:"
119
+ log "-" * report_width
120
+ log pretty_print_hash(read_results, report_width)
121
+ end
122
+
123
+ log "Read metrics done in #{Time.now - t0} seconds"
124
+ else
125
+ log "\nNo reads provided, skipping read diagnostics"
108
126
  end
109
127
 
110
- puts "Comparative metrics done in #{Time.now - t0} seconds"
111
- end
128
+ comparative_results={}
129
+
130
+ if opts.reference
131
+ log "\nCalculating comparative metrics..."
132
+ t0 = Time.now
133
+ comparative_metrics = transrater.comparative_metrics
134
+ comparative_results = comparative_metrics.comp_stats
135
+
136
+ if comparative_results
137
+ log "\n"
138
+ log "Comparative metrics:"
139
+ log "-" * report_width
140
+ log pretty_print_hash(comparative_results, report_width)
141
+ end
142
+
143
+ log "Comparative metrics done in #{Time.now - t0} seconds"
144
+ end
145
+
146
+ log "\n"
147
+ log "-" * report_width
148
+ score = transrater.assembly_score
149
+ unless score.nil?
150
+ log "OVERALL SCORE: #{score.to_f.round(2) * 100}%"
151
+ log "-" * report_width
152
+ end
153
+
154
+ all << contig_results.
155
+ merge(read_results).
156
+ merge(comparative_results).
157
+ merge({ :assembly => assembly })
112
158
 
113
- puts "\n"
114
- puts "-" * report_width
115
- score = transrater.assembly_score
116
- unless score.nil?
117
- puts "OVERALL SCORE: #{score.to_f.round(2) * 100}%"
118
- puts "-" * report_width
119
159
  end
160
+
161
+ # write out all resuls to .csv
162
+ outfile = opts.out || 'transrate.csv'
163
+ CSV.open(outfile, 'wb') do |file|
164
+ keys = all[0].keys
165
+ keys.delete(:assembly)
166
+ head = [:assembly] + keys
167
+ file << head
168
+ all.each do |row|
169
+ file << head.map { |x| row[x] }
170
+ end
171
+ end
@@ -10,7 +10,7 @@ module Transrate
10
10
  module VERSION
11
11
  MAJOR = 0
12
12
  MINOR = 0
13
- PATCH = 15
13
+ PATCH = 16
14
14
  BUILD = nil
15
15
 
16
16
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake