transrate 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +16 -1
  3. data/.travis.yml +8 -0
  4. data/README.md +45 -43
  5. data/Rakefile +36 -0
  6. data/bin/transrate +98 -50
  7. data/deps/deps.yaml +55 -0
  8. data/lib/transrate.rb +19 -4
  9. data/lib/transrate/assembly.rb +93 -182
  10. data/lib/transrate/bowtie2.rb +37 -13
  11. data/lib/transrate/cmd.rb +19 -0
  12. data/lib/transrate/comparative_metrics.rb +239 -19
  13. data/lib/transrate/contig.rb +212 -0
  14. data/lib/transrate/contig_metrics.rb +76 -0
  15. data/lib/transrate/read_metrics.rb +83 -41
  16. data/lib/transrate/samtools.rb +73 -0
  17. data/lib/transrate/transrater.rb +31 -11
  18. data/lib/transrate/version.rb +1 -1
  19. data/test/data/150uncovered.l.fq +892 -0
  20. data/test/data/150uncovered.r.fq +892 -0
  21. data/test/data/Os.protein.2.fa +95 -0
  22. data/test/data/Os.protein.fa +199 -0
  23. data/test/data/assembly.2.fa +26 -0
  24. data/test/{assembly.fasta → data/assembly.fasta} +0 -0
  25. data/test/data/bridging_reads.l.fastq +20 -0
  26. data/test/data/bridging_reads.r.fastq +20 -0
  27. data/test/data/sorghum_transcript.fa +4 -0
  28. data/test/data/tiny.sam +4 -0
  29. data/test/helper.rb +33 -2
  30. data/test/test_bowtie.rb +54 -0
  31. data/test/test_cmd.rb +15 -0
  32. data/test/test_comp_metrics.rb +177 -0
  33. data/test/test_contig.rb +61 -0
  34. data/test/test_contig_metrics.rb +50 -0
  35. data/test/test_inline.rb +10 -9
  36. data/test/test_read_metrics.rb +68 -0
  37. data/test/test_samtools.rb +22 -0
  38. data/test/test_transrate.rb +40 -0
  39. data/test/test_transrater.rb +68 -0
  40. data/transrate.gemspec +16 -10
  41. metadata +232 -57
  42. data/lib/transrate/express.rb +0 -37
  43. data/lib/transrate/log.rb +0 -16
  44. data/lib/transrate/rb_hit.rb +0 -33
  45. data/lib/transrate/reciprocal_annotation.rb +0 -105
  46. data/lib/transrate/usearch.rb +0 -66
  47. data/test/test_test.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfac9099c06f657ebaa995763f287339e1527a5d
4
- data.tar.gz: 5281dc92d37cccc7f518622c223ffcbdeef86fff
3
+ metadata.gz: cb3aec952569895cd9b811cafc879305a0636831
4
+ data.tar.gz: 45e521994f0d7e53fa956482826756987198960d
5
5
  SHA512:
6
- metadata.gz: 56715785fb5dd0f8f50cae0092d35cb5ef38c80a84c4f9575cac936f520056fac3e5c626a56d07b83bcaf12d5827472d8ca6378b33bed4efd4fcebc12a122a4c
7
- data.tar.gz: 032e000796a0df849f2650cf861c9a5756272c0cde7fb8ffd3ba0a31117e003c5806a717f10fcc021947048ba12578ae8016ad6944f0b5f22953a899c5d88198
6
+ metadata.gz: d9a4e34d60e180f0b6496868c5bad95f840b60a6fb0ffa85242cae4bffdc30e596b99b2a741807d69b75a20ecff0b5a7b919531a2663286fcb4f610d83df5044
7
+ data.tar.gz: cabfa0bb4df8906c334ba9c94bb7fc3e0f6a2e091f0136797595b4e62802a34b42546d3804a2a1a67bb7818b5aa0428b15c235c3ab176ae237cbf08cfcd566a1
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  Gemfile.lock
6
6
  coverage
7
+ test_data
7
8
  InstalledFiles
8
9
  lib/bundler/man
9
10
  pkg
@@ -13,6 +14,8 @@ test/tmp
13
14
  test/version_tmp
14
15
  tmp
15
16
  *~
17
+ .#*
18
+ \#*
16
19
 
17
20
  # YARD artifacts
18
21
  .yardoc
@@ -21,4 +24,16 @@ doc/
21
24
  .ruby-version
22
25
 
23
26
  # large test files not for repo
24
- dryrun
27
+ dryrun
28
+ *.blast
29
+ *.phr
30
+ *.pin
31
+ *.psq
32
+ *.nhr
33
+ *.nin
34
+ *.nsq
35
+ *.bt2
36
+ *.fai
37
+ *.bam
38
+ *.csv
39
+ *.coverage
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - "2.0.0"
4
+ - "2.1.0"
5
+ before_script:
6
+ - gem install bindeps
7
+ - bundle install
8
+ - bundle exec bin/transrate --install-deps
data/README.md CHANGED
@@ -3,6 +3,18 @@ Transrate
3
3
 
4
4
  Quality analysis and comparison of transcriptome assemblies.
5
5
 
6
+ [![Gem Version](https://badge.fury.io/rb/transrate.png)][gem]
7
+ [![Build Status](https://secure.travis-ci.org/Blahah/transrate.png?branch=master)][travis]
8
+ [![Dependency Status](https://gemnasium.com/Blahah/transrate.png?travis)][gemnasium]
9
+ [![Code Climate](https://codeclimate.com/github/Blahah/transrate.png)][codeclimate]
10
+ [![Coverage Status](https://coveralls.io/repos/Blahah/transrate/badge.png?branch=master)][coveralls]
11
+
12
+ [gem]: https://badge.fury.io/rb/transrate
13
+ [travis]: https://travis-ci.org/Blahah/transrate
14
+ [gemnasium]: https://gemnasium.com/Blahah/transrate
15
+ [codeclimate]: https://codeclimate.com/github/Blahah/transrate
16
+ [coveralls]: https://coveralls.io/r/Blahah/transrate
17
+
6
18
  ## Contents
7
19
 
8
20
  1. [Development status](https://github.com/Blahah/transrate#development-status)
@@ -15,24 +27,12 @@ Quality analysis and comparison of transcriptome assemblies.
15
27
  5. [Requirements](https://github.com/Blahah/transrate#requirements)
16
28
  - [Ruby](https://github.com/Blahah/transrate#ruby)
17
29
  - [RubyGems](https://github.com/Blahah/transrate#rubygems)
18
- - [USEARCH, Bowtie 2, and eXpress](https://github.com/Blahah/transrate#usearch-bowtie2-and-express)
30
+ - [Blast+, Bowtie 2](https://github.com/Blahah/transrate#blast+-and-bowtie2)
19
31
  6. [Getting help](https://github.com/Blahah/transrate#getting-help)
20
32
 
21
33
  ## Development status
22
34
 
23
- This software is in early development. Users should be aware that until the first release is made, features may change faster than the documentation is updated. Nevertheless, we welcome bug reports.
24
-
25
- [![Gem Version](https://badge.fury.io/rb/transrate.png)][gem]
26
- [![Build Status](https://secure.travis-ci.org/Blahah/transrate.png?branch=master)][travis]
27
- [![Dependency Status](https://gemnasium.com/Blahah/transrate.png?travis)][gemnasium]
28
- [![Code Climate](https://codeclimate.com/github/Blahah/transrate.png)][codeclimate]
29
- [![Coverage Status](https://coveralls.io/repos/Blahah/transrate/badge.png?branch=master)][coveralls]
30
-
31
- [gem]: https://badge.fury.io/rb/transrate
32
- [travis]: https://travis-ci.org/Blahah/transrate
33
- [gemnasium]: https://gemnasium.com/Blahah/transrate
34
- [codeclimate]: https://codeclimate.com/github/Blahah/transrate
35
- [coveralls]: https://coveralls.io/r/Blahah/transrate
35
+ This software is being actively developed. Please be aware that they may be bugs. If you find any, please report them on the [issue tracker](https://github.com/Blahah/transrate/issues).
36
36
 
37
37
  ## Transcriptome assembly quality metrics
38
38
 
@@ -40,57 +40,59 @@ This software is in early development. Users should be aware that until the firs
40
40
 
41
41
  ## Installation
42
42
 
43
- Assuming all the requirements are met (see below), you can install transrate very easily. Just run at the terminal:
43
+ Assuming you've got a recent version of Ruby installed (see below), you can install transrate very easily. Just run at the terminal:
44
44
 
45
45
  `gem install transrate`
46
46
 
47
- If you're new to linux/unix, there's a detailed tutorial for installing transrate with all the dependencies [on my blog](http://blahah.net/bioinformatics/2013/10/19/installing-transrate/).
47
+ Next all the software Transrate depends on needs to be installed. Luckily, transrate is clever enough to do this itself. Simply run
48
+
49
+ `transrate --install-deps`
50
+
51
+ Transrate will check whether its dependencies are installed, and if not will download and install them for you.
48
52
 
49
53
  ## Usage
50
54
 
51
55
  ### Command line
52
56
 
53
- `transrate --help` will give you...
57
+ `transrate --help` will display basic usage instructions.
54
58
 
55
59
  ```
56
- Transrate v0.0.10 by Richard Smith <rds45@cam.ac.uk>
60
+ Transrate v0.2.0 by Richard Smith-Unna <rds45@cam.ac.uk>
57
61
 
58
- DESCRIPTION:
59
- Analyse a de-novo transcriptome
60
- assembly using three kinds of metrics:
62
+ DESCRIPTION:
63
+ Analyse a de-novo transcriptome
64
+ assembly using three kinds of metrics:
61
65
 
62
- 1. contig-based
63
- 2. read-mapping
64
- 3. reference-based
66
+ 1. contig-based
67
+ 2. read-mapping (if --left and --right are provided)
68
+ 3. reference-based (if --reference is provided)
65
69
 
66
- Please make sure USEARCH, bowtie 2 and eXpress are installed
67
- and in the PATH.
70
+ Bug reports and feature requests at:
71
+ http://github.com/blahah/transrate
68
72
 
69
- Bug reports and feature requests at:
70
- http://github.com/blahah/transrate
73
+ USAGE:
74
+ transrate <options>
71
75
 
72
- USAGE:
73
- transrate <options>
76
+ EXAMPLES:
77
+ transrate --assembly contigs.fa --reference Athaliana_protein.fa --threads 8
74
78
 
75
- OPTIONS:
76
- --assembly, -a <s>: assembly file in FASTA format
79
+ OPTIONS:
80
+ --assembly, -a <s>: assembly file(s) in FASTA format, comma-separated
77
81
  --reference, -r <s>: reference proteome file in FASTA format
78
82
  --left, -l <s>: left reads file in FASTQ format
79
83
  --right, -i <s>: right reads file in FASTQ format
80
84
  --insertsize, -n <i>: mean insert size (default: 200)
81
85
  --insertsd, -s <i>: insert size standard deviation (default: 50)
82
86
  --threads, -t <i>: number of threads to use (default: 8)
87
+ --outfile, -o <s>: filename to use for CSV output (default: transate_results.csv)
88
+ --loglevel, -g <s>: the amount of information to print. one of [error, info, warn, debug] (default: info)
89
+ --install-deps, -d: install any missing dependencies
90
+ --profile, -p: debug option: profile the code as it runs
83
91
  --version, -v: Print version and exit
84
92
  --help, -h: Show this message
85
93
  ```
86
94
 
87
- If you don't include --left and --right read files, the read-mapping based analysis will be skipped. I recommend that you don't align all your reads - just a subset of 500,000 will give you a very good idea of the quality. You can get a subset by running (on a linux system):
88
-
89
- `head -2000000 left.fastq > left_500k.fastq`
90
-
91
- `head -2000000 right.fastq > right_500k.fastq`
92
-
93
- FASTQ records are 4 lines long, so make sure you multiply the number of reads you want by 4, and be sure to run the same command on both the left and right read files.
95
+ See the [getting started guide] on the website for more instructions, and see the [command-line options] part of the manual for details.
94
96
 
95
97
  #### Example
96
98
 
@@ -123,13 +125,13 @@ puts t.assembly_score
123
125
 
124
126
  ### Ruby
125
127
 
126
- First, you'll need Ruby v1.9.3 or greater installed. You can check with:
128
+ First, you'll need Ruby v2.0.0 or greater installed. You can check with:
127
129
 
128
130
  `ruby --version`
129
131
 
130
132
  If you don't have Ruby installed, or you need a higher version, I recommend using [RVM](http://rvm.io/) as your Ruby Version Manager. To install RVM along with the latest Ruby, just run:
131
133
 
132
- `\curl -L https://get.rvm.io | bash -s stable`
134
+ `\curl -L https://get.rvm.io | bash -s stable --ruby`
133
135
 
134
136
  ### Rubygems
135
137
 
@@ -139,9 +141,9 @@ Your Ruby installation *should* come with RubyGems, the package manager for Ruby
139
141
 
140
142
  If you don't have it installed, I recommend installing the latest version of Ruby and RubyGems using the RVM instructions above (in the [Requirements:Ruby](https://github.com/Blahah/transrate#ruby) section).
141
143
 
142
- ### Usearch, Bowtie2 and eXpress
144
+ ## Other software
143
145
 
144
- Usearch (http://drive5.com/usearch), Bowtie2 (https://sourceforge.net/projects/bowtie-bio/files/bowtie2) and eXpress (http://bio.math.berkeley.edu/eXpress/) must be installed and in your PATH. Additionally, the Usearch binary executable should be named `usearch`.
146
+ Transrate uses a variety of other software including NCBI BLAST+, Bowtie2 and Samtools. But you don't need to worry about installing those yourself - Transrate does that automatically using the [bindeps](https://github.com/Blahah/bindeps) gem.
145
147
 
146
148
  ## Getting help
147
149
 
data/Rakefile CHANGED
@@ -4,5 +4,41 @@ Rake::TestTask.new do |t|
4
4
  t.libs << 'test'
5
5
  end
6
6
 
7
+ Rake::TestTask.new do |t|
8
+ t.name = :recip
9
+ t.libs << 'test'
10
+ t.test_files = ['test/test_reciprocal.rb']
11
+ end
12
+
13
+ Rake::TestTask.new do |t|
14
+ t.name = :comp
15
+ t.libs << 'test'
16
+ t.test_files = ['test/test_comp_metrics.rb']
17
+ end
18
+
19
+ Rake::TestTask.new do |t|
20
+ t.name = :contig
21
+ t.libs << 'test'
22
+ t.test_files = ['test/test_contig_metrics.rb']
23
+ end
24
+
25
+ Rake::TestTask.new do |t|
26
+ t.name = :read
27
+ t.libs << 'test'
28
+ t.test_files = ['test/test_read_metrics.rb']
29
+ end
30
+
31
+ Rake::TestTask.new do |t|
32
+ t.name = :bowtie
33
+ t.libs << 'test'
34
+ t.test_files = ['test/test_bowtie.rb']
35
+ end
36
+
37
+ Rake::TestTask.new do |t|
38
+ t.name = :rater
39
+ t.libs << 'test'
40
+ t.test_files = ['test/test_transrater.rb']
41
+ end
42
+
7
43
  desc "Run tests"
8
44
  task :default => :test
data/bin/transrate CHANGED
@@ -3,16 +3,17 @@
3
3
  require 'trollop'
4
4
  require 'transrate'
5
5
  require 'csv'
6
+ require 'bindeps'
7
+ require 'ruby-prof'
6
8
 
7
9
  opts = Trollop::options do
8
10
  version Transrate::VERSION::STRING.dup
9
11
  banner <<-EOS
10
12
 
11
- Transrate v#{Transrate::VERSION::STRING.dup} by Richard Smith <rds45@cam.ac.uk>
13
+ Transrate v#{Transrate::VERSION::STRING.dup} by Richard Smith-Unna <rds45@cam.ac.uk>
12
14
 
13
15
  DESCRIPTION:
14
- Analyse a de-novo transcriptome
15
- assembly using three kinds of metrics:
16
+ Analyse a de-novo transcriptome assembly using three kinds of metrics:
16
17
 
17
18
  1. contig-based
18
19
  2. read-mapping (if --left and --right are provided)
@@ -25,13 +26,19 @@ opts = Trollop::options do
25
26
  transrate <options>
26
27
 
27
28
  EXAMPLES:
29
+ # just check dependencies and install any that are missing
30
+ transrate --install-deps
31
+ # contig metrics only
32
+ transrate --assembly contigs.fa
33
+ # contig and reference-based metrics with 8 threads
28
34
  transrate --assembly contigs.fa --reference Athaliana_protein.fa --threads 8
35
+ # contig and read-based metrics for two assemblies with 32 threads
36
+ transrate --assembly one.fa,two.fa --left l.fq --right r.fq --threads 32
29
37
 
30
38
  OPTIONS:
31
39
 
32
40
  EOS
33
41
  opt :assembly, "assembly file(s) in FASTA format, comma-separated",
34
- :required => true,
35
42
  :type => String
36
43
  opt :reference, "reference proteome file in FASTA format",
37
44
  :type => String
@@ -48,7 +55,36 @@ opts = Trollop::options do
48
55
  opt :threads, "number of threads to use",
49
56
  :default => 8,
50
57
  :type => Integer
51
- opt :quiet, "don't print results - only save to file"
58
+ opt :outfile, "filename to use for CSV output",
59
+ :default => 'transate_results.csv'
60
+ opt :loglevel, "the amount of information to print. " +
61
+ "one of [error, info, warn, debug]",
62
+ :default => 'info'
63
+ opt :install_deps, "install any missing dependencies"
64
+ opt :profile, "debug option: profile the code as it runs"
65
+ end
66
+
67
+ if opts.install_deps
68
+ puts "Checking dependencies"
69
+ gem_dir = Gem.loaded_specs['transrate'].full_gem_path
70
+ gem_deps = File.join(gem_dir, 'deps', 'deps.yaml')
71
+ Bindeps.require gem_deps
72
+ puts "All dependencies installed"
73
+ exit
74
+ end
75
+
76
+ unless opts.assembly
77
+ raise ArgumentError.new "Option --assembly must be specified. " +
78
+ "Try --help for help."
79
+ end
80
+
81
+ if opts.reference && !File.exist?(opts.reference)
82
+ raise IOError.new "Reference fasta file does not exist: #{opts.reference}"
83
+ end
84
+
85
+ if opts.profile
86
+ logger.info "Starting profiler"
87
+ RubyProf.start
52
88
  end
53
89
 
54
90
  def pretty_print_hash hash, width
@@ -57,101 +93,105 @@ def pretty_print_hash hash, width
57
93
  if v.to_f.round(2).to_s.split('.').last.to_i > 0
58
94
  v = v.to_f.round(2)
59
95
  end
96
+ if v.is_a? Float
97
+ v = v.round(2)
98
+ end
60
99
  pad = (width - (k.to_s.length + v.to_s.length))
61
- "#{k.to_s.split('_').join(' ')}" +
100
+ pad = [pad, 0].max
101
+ logger.info "#{k.to_s.split('_').join(' ')}" +
62
102
  "#{" " * pad}" +
63
103
  "#{v}"
64
- end.join("\n")
65
- end
66
-
67
- # don't log if --quiet is set
68
- $quiet = opts.quiet
69
- def log msg
70
- unless $quiet
71
- puts msg
72
104
  end
73
105
  end
74
106
 
75
107
  include Transrate
76
108
 
77
- r = opts.reference ? Assembly.new(opts.reference) : nil
78
- report_width = 30
109
+ unless %w[error info warn debug].include? opts.loglevel
110
+ raise "Loglevel #{opts.loglevel} is not valid. " +
111
+ "It must be one of: error, info, warn, debug."
112
+ end
113
+
114
+ logger.level = Yell::Level.new opts.loglevel.to_sym
115
+
116
+ logger.info "Loading reference dataset"
117
+
118
+ r = opts.reference ? Assembly.new(opts.reference) : nil
119
+ report_width = 35
79
120
 
80
121
  # loop through the assemblies, storing their outputs in an array of hashes
81
122
  all = []
82
123
  opts.assembly.split(',').each do |assembly|
83
124
 
125
+ logger.info "Loading assembly: #{assembly}"
126
+
84
127
  a = Assembly.new assembly
128
+ transrater = Transrater.new(a, r,
129
+ left: opts.left,
130
+ right: opts.right,
131
+ insertsize: opts.insertsize,
132
+ insertsd: opts.insertsd,
133
+ threads: opts.threads)
85
134
 
86
- transrater = Transrater.new(a, r,
87
- opts.left,
88
- opts.right,
89
- opts.insertsize,
90
- opts.insertsd)
91
135
 
92
- log "\nAnalysing assembly: #{assembly}\n\n"
136
+ logger.info "Analysing assembly: #{assembly}"
93
137
 
94
138
  contig_results = {}
95
139
 
96
- log "Calculating contig metrics..."
140
+ logger.info "Calculating contig metrics..."
97
141
  t0 = Time.now
98
142
  contig_results = transrater.assembly_metrics.basic_stats
99
-
143
+ contig_results.merge! transrater.assembly.contig_metrics.results
100
144
  if contig_results
101
- log "\n"
102
- log "Contig metrics:"
103
- log "-" * report_width
104
- log pretty_print_hash(contig_results, report_width)
145
+ logger.info "Contig metrics:"
146
+ logger.info "-" * report_width
147
+ pretty_print_hash(contig_results, report_width)
105
148
  end
106
149
 
107
- log "Contig metrics done in #{Time.now - t0} seconds"
150
+ logger.info "Contig metrics done in #{Time.now - t0} seconds"
108
151
 
109
152
  read_results = {}
110
153
 
111
154
  if (opts.left && opts.right)
112
- log "\ncalculating read diagnostics..."
155
+ logger.info "Calculating read diagnostics..."
113
156
  t0 = Time.now
114
- read_results = transrater.read_metrics(opts.left, opts.right).read_stats
157
+ read_results = transrater.read_metrics(opts.left,
158
+ opts.right).read_stats
115
159
 
116
160
  if read_results
117
- log "\n"
118
- log "Read mapping metrics:"
119
- log "-" * report_width
120
- log pretty_print_hash(read_results, report_width)
161
+ logger.info "Read mapping metrics:"
162
+ logger.info "-" * report_width
163
+ pretty_print_hash(read_results, report_width)
121
164
  end
122
165
 
123
- log "Read metrics done in #{Time.now - t0} seconds"
166
+ logger.info "Read metrics done in #{Time.now - t0} seconds"
124
167
  else
125
- log "\nNo reads provided, skipping read diagnostics"
168
+ logger.info "No reads provided, skipping read diagnostics"
126
169
  end
127
170
 
128
171
  comparative_results={}
129
172
 
130
173
  if opts.reference
131
- log "\nCalculating comparative metrics..."
174
+ logger.info "Calculating comparative metrics..."
132
175
  t0 = Time.now
133
176
  comparative_metrics = transrater.comparative_metrics
134
177
  comparative_results = comparative_metrics.comp_stats
135
178
 
136
179
  if comparative_results
137
- log "\n"
138
- log "Comparative metrics:"
139
- log "-" * report_width
140
- log pretty_print_hash(comparative_results, report_width)
180
+ logger.info "Comparative metrics:"
181
+ logger.info "-" * report_width
182
+ pretty_print_hash(comparative_results, report_width)
141
183
  end
142
184
 
143
- log "Comparative metrics done in #{Time.now - t0} seconds"
144
-
185
+ logger.info "Comparative metrics done in #{Time.now - t0} seconds"
145
186
 
146
- log "\n"
147
- log "-" * report_width
187
+ logger.info "-" * report_width
148
188
  score = transrater.assembly_score
149
189
  unless score.nil?
150
- log "OVERALL SCORE: #{score.to_f.round(2) * 100}%"
151
- log "-" * report_width
190
+ logger.info "OVERALL SCORE: #{score.to_f.round(2) * 100}%"
191
+ logger.info "-" * report_width
152
192
  end
153
193
  else
154
- log "\nNo reference provided, skipping comparative diagnostics"
194
+ logger.info "No reference provided, skipping comparative diagnostics"
155
195
  end
156
196
 
157
197
  all << contig_results.
@@ -163,6 +203,7 @@ end
163
203
 
164
204
  # write out all resuls to .csv
165
205
  outfile = opts.out || 'transrate.csv'
206
+ logger.info "Writing analysis results to #{outfile}"
166
207
  CSV.open(outfile, 'wb') do |file|
167
208
  keys = all[0].keys
168
209
  keys.delete(:assembly)
@@ -171,4 +212,11 @@ CSV.open(outfile, 'wb') do |file|
171
212
  all.each do |row|
172
213
  file << head.map { |x| row[x] }
173
214
  end
174
- end
215
+ end
216
+
217
+ if opts.profile
218
+ logger.info "Writing profiling results to transrate_profile.txt"
219
+ result = RubyProf.stop
220
+ printer = RubyProf::FlatPrinter.new(result)
221
+ printer.print(File.open('transrate_profile.txt', 'w'))
222
+ end