Skip to content

Commit 9e34ff0

Browse files
committed
refactor as gem, abstract bowtie and readmappings as classes
1 parent f45d690 commit 9e34ff0

19 files changed

+717
-539
lines changed

Gemfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source "https://rubygems.org"
2+
3+
gemspec

Gemfile.lock

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
PATH
2+
remote: .
3+
specs:
4+
transrate (0.0.1)
5+
bettersam
6+
bio
7+
rake (~> 10.1.0)
8+
trollop (~> 2.0)
9+
which
10+
11+
GEM
12+
remote: https://rubygems.org/
13+
specs:
14+
ansi (1.4.3)
15+
bettersam (0.0.1.alpha)
16+
bio (1.4.3)
17+
colorize (0.5.8)
18+
coveralls (0.6.7)
19+
colorize
20+
multi_json (~> 1.3)
21+
rest-client
22+
simplecov (>= 0.7)
23+
thor
24+
facade (1.0.5)
25+
mime-types (1.23)
26+
multi_json (1.7.7)
27+
pathname2 (1.6.5)
28+
facade
29+
rake (10.1.0)
30+
rest-client (1.6.7)
31+
mime-types (>= 1.16)
32+
shoulda-context (1.1.5)
33+
simplecov (0.7.1)
34+
multi_json (~> 1.0)
35+
simplecov-html (~> 0.7.1)
36+
simplecov-html (0.7.1)
37+
thor (0.16.0)
38+
trollop (2.0)
39+
turn (0.9.6)
40+
ansi
41+
which (0.0.2)
42+
pathname2 (>= 1.4.4)
43+
44+
PLATFORMS
45+
ruby
46+
47+
DEPENDENCIES
48+
coveralls (~> 0.6.7)
49+
shoulda-context
50+
simplecov
51+
transrate!
52+
turn

assembly.rb

-240
This file was deleted.

bin/transrate

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#! /usr/bin/env ruby
2+
3+
require 'trollop'
4+
require 'transrate'
5+
6+
opts = Trollop::options do
7+
version "v0.0.1a"
8+
banner <<-EOS
9+
10+
Transrate v0.0.1a by Richard Smith <[email protected]>
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
18+
3. reference-based
19+
20+
Please make sure USEARCH and bowtie2 are both installed
21+
and in the PATH.
22+
23+
Bug reports and feature requests at:
24+
https://github.com/blahah/transrate
25+
26+
USAGE:
27+
transrate <options>
28+
29+
OPTIONS:
30+
31+
EOS
32+
opt :assembly, "assembly file in FASTA format", :required => true, :type => String
33+
opt :reference, "reference proteome file in FASTA format", :required => true, :type => String
34+
opt :left, "left reads file in FASTQ format", :type => String
35+
opt :right, "right reads file in FASTQ format", :type => String
36+
opt :insertsize, "mean insert size", :default => 200, :type => Integer
37+
opt :insertsd, "insert size standard deviation", :default => 50, :type => Integer
38+
opt :threads, "number of threads to use", :default => 8, :type => Integer
39+
end
40+
41+
def pretty_print_hash hash, width
42+
hash.map{ |k, v| "#{k.to_s}#{" " * (width - (k.length + v.to_i.to_s.length))}#{v.to_i}" }.join("\n")
43+
end
44+
45+
include Transrate
46+
47+
a = Assembly.new opts.assembly
48+
r = Assembly.new opts.reference
49+
50+
puts "\n\nAnalysing assembly: #{opts.assembly}\n\n"
51+
52+
puts "calculating contig stats..."
53+
t0 = Time.now
54+
contig_results = a.basic_stats
55+
puts "...done in #{Time.now - t0} seconds"
56+
57+
read_results = nil
58+
if (opts.left && opts.right)
59+
puts "\ncalculating read diagnostics..."
60+
t0 = Time.now
61+
read_metrics = ReadMetrics.new a
62+
read_results = read_metrics.run(opts.left, opts.right)
63+
puts "...done in #{Time.now - t0} seconds"
64+
else
65+
puts "\nno reads provided, skipping read diagnostics"
66+
end
67+
68+
puts "\ncalculating comparative metrics..."
69+
t0 = Time.now
70+
comparative_metrics = ComparativeMetrics.new(a, r)
71+
comparative_results = comparative_metrics.run
72+
puts "...done in #{Time.now - t0} seconds"
73+
74+
report_width = 30
75+
76+
if contig_results
77+
puts "\n\n"
78+
puts "Contig metrics:"
79+
puts "-" * report_width
80+
puts pretty_print_hash(contig_results, report_width)
81+
end
82+
83+
if read_results
84+
puts "\n\n"
85+
puts "Read mapping metrics:"
86+
puts "-" * report_width
87+
puts pretty_print_hash(read_results, report_width)
88+
end
89+
90+
if comparative_results
91+
puts "\n\n"
92+
puts "Comparative metrics:"
93+
puts "-" * report_width
94+
puts pretty_print_hash(comparative_results, report_width)
95+
end

0 commit comments

Comments
 (0)