transrate 1.0.0.alpha.2 → 1.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/transrate +8 -4
- data/deps/deps.yaml +1 -1
- data/lib/transrate.rb +3 -1
- data/lib/transrate/contig.rb +5 -1
- data/lib/transrate/express.rb +7 -1
- data/lib/transrate/read_metrics.rb +24 -14
- data/lib/transrate/samtools.rb +2 -2
- data/lib/transrate/version.rb +1 -1
- data/test/test_bin.rb +4 -0
- data/test/test_read_metrics.rb +3 -3
- data/test/test_transrater.rb +1 -1
- data/transrate.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e36efc13482215880b40860b64a69253f3dc886b
|
4
|
+
data.tar.gz: 89f65043547cedb0552a7b620ea845c003f77637
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e3ce4a80fc7bf7ef37f4a2322101f375b6efcf8bbed5dc8034f1bcbf871d2349292e2cc1a22f393bcabe3cddff60f4e1afd25d5267b1d3a2a7ea12e8a09ebf0
|
7
|
+
data.tar.gz: ee91ff26631d3204f43698a3afc4acfd0fc34a2068bde2c868897e347ff2bd8ca05225bc878267fc8454d58bd3a628fd7636735f9e8bd0472a7e3f90d1d829b9
|
data/bin/transrate
CHANGED
@@ -6,11 +6,14 @@ require 'csv'
|
|
6
6
|
require 'bindeps'
|
7
7
|
require 'ruby-prof'
|
8
8
|
|
9
|
+
ARGV[0] = "--help" if ARGV.length() == 0
|
10
|
+
|
9
11
|
opts = Trollop::options do
|
10
12
|
version Transrate::VERSION::STRING.dup
|
11
13
|
banner <<-EOS
|
12
14
|
|
13
|
-
Transrate v#{Transrate::VERSION::STRING.dup}
|
15
|
+
Transrate v#{Transrate::VERSION::STRING.dup}
|
16
|
+
by Richard Smith-Unna <rds45@cam.ac.uk> and Chris Boursnell
|
14
17
|
|
15
18
|
DESCRIPTION:
|
16
19
|
Analyse a de-novo transcriptome assembly using three kinds of metrics:
|
@@ -26,8 +29,10 @@ opts = Trollop::options do
|
|
26
29
|
transrate <options>
|
27
30
|
|
28
31
|
EXAMPLES:
|
29
|
-
#
|
32
|
+
# check dependencies and install any that are missing
|
30
33
|
transrate --install-deps
|
34
|
+
# get the transrate score for the assembly and each contig
|
35
|
+
transrate --assembly contigs.fa --left left.fq --right right.fq
|
31
36
|
# contig metrics only
|
32
37
|
transrate --assembly contigs.fa
|
33
38
|
# contig and reference-based metrics with 8 threads
|
@@ -57,7 +62,6 @@ opts = Trollop::options do
|
|
57
62
|
opt :install_deps, "install any missing dependencies"
|
58
63
|
opt :profile, "debug option: profile the code as it runs"
|
59
64
|
end
|
60
|
-
|
61
65
|
gem_dir = Gem.loaded_specs['transrate'].full_gem_path
|
62
66
|
gem_deps = File.join(gem_dir, 'deps', 'deps.yaml')
|
63
67
|
if opts.install_deps
|
@@ -70,7 +74,7 @@ else
|
|
70
74
|
if missing.length > 0
|
71
75
|
puts "Dependencies are missing:"
|
72
76
|
missing.each do |dep|
|
73
|
-
puts " - #{dep}"
|
77
|
+
puts " - #{dep.name} (#{dep.version})"
|
74
78
|
end
|
75
79
|
puts "To install all missing dependencies, run `transrate --install-deps`"
|
76
80
|
exit(1)
|
data/deps/deps.yaml
CHANGED
data/lib/transrate.rb
CHANGED
@@ -22,7 +22,9 @@ module Transrate
|
|
22
22
|
|
23
23
|
# Create the universal logger and include it in Object
|
24
24
|
# making the logger object available everywhere
|
25
|
-
Yell.new(
|
25
|
+
format = Yell::Formatter.new("[%5L] %d : %m", "%Y-%m-%d %H:%M:%S")
|
26
|
+
# http://xkcd.com/1179/
|
27
|
+
Yell.new(:format => format) do |l|
|
26
28
|
l.level = :info
|
27
29
|
l.name = Object
|
28
30
|
l.adapter STDOUT, level: [:debug, :info, :warn]
|
data/lib/transrate/contig.rb
CHANGED
@@ -10,6 +10,7 @@ module Transrate
|
|
10
10
|
def_delegators :@seq, :size, :length
|
11
11
|
attr_accessor :seq, :name
|
12
12
|
# read-based metrics
|
13
|
+
attr_accessor :eff_length, :eff_count, :tpm
|
13
14
|
attr_accessor :coverage, :uncovered_bases, :p_uncovered_bases
|
14
15
|
attr_accessor :p_seq_true, :p_unique
|
15
16
|
attr_accessor :low_uniqueness_bases, :in_bridges
|
@@ -64,7 +65,10 @@ module Transrate
|
|
64
65
|
:score => score,
|
65
66
|
:p_unique => p_unique,
|
66
67
|
:p_not_segmented => p_not_segmented,
|
67
|
-
:
|
68
|
+
:eff_length => eff_length,
|
69
|
+
:eff_count => eff_count,
|
70
|
+
:tpm => tpm,
|
71
|
+
:coverage => coverage
|
68
72
|
}
|
69
73
|
end
|
70
74
|
|
data/lib/transrate/express.rb
CHANGED
@@ -68,8 +68,14 @@ module Transrate
|
|
68
68
|
end
|
69
69
|
line = line.chomp.split("\t")
|
70
70
|
target = line[1]
|
71
|
+
effective_length = line[3]
|
71
72
|
effective_count = line[7]
|
72
|
-
|
73
|
+
tpm = line[14]
|
74
|
+
expression[target] = {
|
75
|
+
:eff_len => effective_length.to_i,
|
76
|
+
:eff_count => effective_count.to_f,
|
77
|
+
:tpm => tpm.to_f
|
78
|
+
}
|
73
79
|
end
|
74
80
|
expression
|
75
81
|
end
|
@@ -57,24 +57,30 @@ module Transrate
|
|
57
57
|
# classify bam file into valid and invalid alignments
|
58
58
|
sorted_bam = "#{File.basename(bamfile, '.bam')}.merged.sorted.bam"
|
59
59
|
readsorted_bam = "#{File.basename(bamfile, '.bam')}.valid.sorted.bam"
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
merged_bam = "#{File.basename(bamfile, '.bam')}.merged.bam"
|
61
|
+
unless File.exist? sorted_bam
|
62
|
+
unless File.exist? readsorted_bam
|
63
|
+
valid_bam, invalid_bam = split_bam bamfile
|
64
|
+
readsorted_bam = Samtools.readsort_bam valid_bam
|
65
|
+
File.delete valid_bam
|
66
|
+
end
|
64
67
|
end
|
65
68
|
|
66
69
|
# pass valid alignments to eXpress for assignment
|
67
70
|
# always have to run the eXpress command to load the results
|
68
71
|
assigned_bam = assign_and_quantify readsorted_bam
|
72
|
+
File.delete readsorted_bam if File.exist? readsorted_bam
|
69
73
|
|
70
74
|
# merge the assigned alignments back with the invalid ones
|
71
75
|
unless File.exist? sorted_bam
|
72
|
-
File.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
76
|
+
unless File.exist? merged_bam
|
77
|
+
Samtools.merge_bam(invalid_bam, assigned_bam,
|
78
|
+
merged_bam, threads=threads)
|
79
|
+
|
80
|
+
File.delete invalid_bam
|
81
|
+
File.delete assigned_bam
|
82
|
+
end
|
83
|
+
sorted_bam = Samtools.sort_bam(merged_bam, [4, threads].min)
|
78
84
|
File.delete merged_bam
|
79
85
|
end
|
80
86
|
|
@@ -154,11 +160,15 @@ module Transrate
|
|
154
160
|
end
|
155
161
|
|
156
162
|
def analyse_expression express_output
|
157
|
-
express_output.each_pair do |name,
|
158
|
-
@contigs_uncovered += 1 if eff_count < 1
|
159
|
-
@contigs_lowcovered += 1 if eff_count < 10
|
163
|
+
express_output.each_pair do |name, expr|
|
160
164
|
contig = @assembly[name]
|
161
|
-
|
165
|
+
coverage = expr[:eff_count] * @read_length / expr[:eff_len]
|
166
|
+
@contigs_uncovered += 1 if coverage < 1
|
167
|
+
@contigs_lowcovered += 1 if coverage < 10
|
168
|
+
contig.coverage = coverage.round(2)
|
169
|
+
contig.eff_length = expr[:eff_len]
|
170
|
+
contig.eff_count = expr[:eff_count]
|
171
|
+
contig.tpm = expr[:tpm]
|
162
172
|
end
|
163
173
|
end
|
164
174
|
|
data/lib/transrate/samtools.rb
CHANGED
@@ -47,7 +47,7 @@ module Transrate
|
|
47
47
|
sorted = File.basename(bamfile, '.bam') + '.sorted'
|
48
48
|
if !File.exist?("#{sorted}.bam")
|
49
49
|
cmd = "sort"
|
50
|
-
cmd << "
|
50
|
+
cmd << " -@ #{threads}"
|
51
51
|
cmd << " #{File.expand_path bamfile} #{sorted}"
|
52
52
|
Samtools.run cmd
|
53
53
|
end
|
@@ -63,7 +63,7 @@ module Transrate
|
|
63
63
|
sorted = File.basename(bamfile, '.bam') + '.sorted'
|
64
64
|
if !File.exist?("#{sorted}.bam")
|
65
65
|
cmd = "sort"
|
66
|
-
cmd << "
|
66
|
+
cmd << " -@ #{threads}"
|
67
67
|
cmd << " -n" # sort by read name only
|
68
68
|
cmd << " #{File.expand_path bamfile} #{sorted}"
|
69
69
|
Samtools.run cmd
|
data/lib/transrate/version.rb
CHANGED
data/test/test_bin.rb
CHANGED
@@ -93,6 +93,10 @@ class TestTransrateBin < Test::Unit::TestCase
|
|
93
93
|
cmd << " --right #{right.join(",")}"
|
94
94
|
c = Transrate::Cmd.new("#{cmd}")
|
95
95
|
c.run
|
96
|
+
if !(c.status.success?)
|
97
|
+
puts c.stdout
|
98
|
+
puts c.stderr
|
99
|
+
end
|
96
100
|
assert_equal true, c.status.success?, "exit status"
|
97
101
|
assert File.exist?("transrate_assemblies.csv")
|
98
102
|
assert File.exist?("transrate_sorghum_transcript.fa_contigs.csv"),
|
data/test/test_read_metrics.rb
CHANGED
@@ -73,12 +73,12 @@ class TestReadMetrics < Test::Unit::TestCase
|
|
73
73
|
unc_a = contigs[0].uncovered_bases
|
74
74
|
unc_b = contigs[1].uncovered_bases
|
75
75
|
assert_equal 11, unc_a, "uncovered bases"
|
76
|
-
assert_equal
|
76
|
+
assert_equal 2, unc_b, "uncovered bases"
|
77
77
|
|
78
78
|
prop_unc_a = a[:p_bases_covered]
|
79
79
|
prop_unc_b = b[:p_bases_covered]
|
80
80
|
assert_equal 0.98497, prop_unc_a.round(5), "proportion covered bases"
|
81
|
-
assert_equal 0.
|
81
|
+
assert_equal 0.99757, prop_unc_b.round(5), "proportion covered bases"
|
82
82
|
|
83
83
|
end
|
84
84
|
end
|
@@ -100,7 +100,7 @@ class TestReadMetrics < Test::Unit::TestCase
|
|
100
100
|
edit_a = a[:p_not_segmented].round(5)
|
101
101
|
edit_b = b[:p_not_segmented].round(5)
|
102
102
|
assert_equal 0.11444, edit_a, "probability not segmented 1"
|
103
|
-
assert_equal 0.
|
103
|
+
assert_equal 0.82779, edit_b, "probability not segmented 2"
|
104
104
|
|
105
105
|
end
|
106
106
|
end
|
data/test/test_transrater.rb
CHANGED
@@ -59,7 +59,7 @@ class TestTransrater < Test::Unit::TestCase
|
|
59
59
|
Dir.chdir tmpdir do
|
60
60
|
all = @rater.all_metrics(@left, @right)
|
61
61
|
score = @rater.assembly_score
|
62
|
-
assert_equal 0.
|
62
|
+
assert_equal 0.40908, score.round(5) # regression test
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/transrate.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
|
20
20
|
gem.add_dependency 'yell', '~> 2.0', '>= 2.0.4'
|
21
21
|
gem.add_dependency 'trollop', '~> 2.0'
|
22
|
-
gem.add_dependency 'bindeps', '~> 0.1', '>= 0.1.
|
22
|
+
gem.add_dependency 'bindeps', '~> 0.1', '>= 0.1.3'
|
23
23
|
gem.add_dependency 'bio', '~> 1.4', '>= 1.4.3'
|
24
24
|
gem.add_dependency 'crb-blast', '~> 0.4', '>= 0.4.2'
|
25
25
|
gem.add_dependency 'ruby-prof', '~> 0.15', '>= 0.15.1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.alpha.
|
4
|
+
version: 1.0.0.alpha.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Smith-Unna
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yell
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0.1'
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0.1.
|
57
|
+
version: 0.1.3
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
version: '0.1'
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.1.
|
67
|
+
version: 0.1.3
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: bio
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|