assembly_pipe 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +22 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/assembly_pipe.gemspec +67 -0
- data/bin/assembly_pipe +152 -0
- data/lib/assembly_pipe.rb +145 -0
- data/lib/queue/word_analyzer.rb +10 -0
- data/test/data/test_logfile.txt +856 -0
- data/test/helper.rb +19 -0
- data/test/test_assembly_pipe.rb +38 -0
- metadata +127 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "minitest", ">= 0"
|
10
|
+
gem "yard", "~> 0.6.0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.6.2"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.6.2)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
minitest (2.3.1)
|
10
|
+
rake (0.9.2)
|
11
|
+
rcov (0.9.9)
|
12
|
+
yard (0.6.8)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 1.0.0)
|
19
|
+
jeweler (~> 1.6.2)
|
20
|
+
minitest
|
21
|
+
rcov
|
22
|
+
yard (~> 0.6.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 robsyme
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= assembly_pipe
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to assembly_pipe
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 robsyme. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "assembly_pipe"
|
18
|
+
gem.homepage = "http://github.com/robsyme/assembly_pipe"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Generating reports from genome assemblies}
|
21
|
+
gem.description = %Q{A sketch that may not see the light of day assembly pipeline and report generation}
|
22
|
+
gem.email = "rob.syme@gmail.com"
|
23
|
+
gem.authors = ["robsyme"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'yard'
|
46
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{assembly_pipe}
|
8
|
+
s.version = "0.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["robsyme"]
|
12
|
+
s.date = %q{2011-07-07}
|
13
|
+
s.default_executable = %q{assembly_pipe}
|
14
|
+
s.description = %q{A sketch that may not see the light of day assembly pipeline and report generation}
|
15
|
+
s.email = %q{rob.syme@gmail.com}
|
16
|
+
s.executables = ["assembly_pipe"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"assembly_pipe.gemspec",
|
30
|
+
"bin/assembly_pipe",
|
31
|
+
"lib/assembly_pipe.rb",
|
32
|
+
"lib/queue/word_analyzer.rb",
|
33
|
+
"test/data/test_logfile.txt",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_assembly_pipe.rb"
|
36
|
+
]
|
37
|
+
s.homepage = %q{http://github.com/robsyme/assembly_pipe}
|
38
|
+
s.licenses = ["MIT"]
|
39
|
+
s.require_paths = ["lib"]
|
40
|
+
s.rubygems_version = %q{1.5.0}
|
41
|
+
s.summary = %q{Generating reports from genome assemblies}
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 3
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_development_dependency(%q<minitest>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
54
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
55
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
57
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
58
|
+
end
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<minitest>, [">= 0"])
|
61
|
+
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
64
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/bin/assembly_pipe
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
module Enumerable
|
6
|
+
def drop_until
|
7
|
+
condition_met = false
|
8
|
+
Enumerator.new do |yielder|
|
9
|
+
self.each do |element|
|
10
|
+
condition_met ||= yield(element)
|
11
|
+
yielder << element if condition_met
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module AssemblyPipe; end
|
18
|
+
|
19
|
+
module AssemblyPipe::VelvetOptimiser
|
20
|
+
|
21
|
+
class Run
|
22
|
+
def initialize
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class LogFile
|
28
|
+
def initialize(filename)
|
29
|
+
@lines = File.readlines(filename).map{|line| line.strip}
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.open(filename)
|
33
|
+
self.new(filename)
|
34
|
+
end
|
35
|
+
|
36
|
+
def date
|
37
|
+
Time.parse(@lines.first)
|
38
|
+
end
|
39
|
+
|
40
|
+
def velveth_runs
|
41
|
+
Enumerator.new do |yielder|
|
42
|
+
run = {}
|
43
|
+
@lines.drop_until{|line| line.match(/Beginning velveth runs/)}.
|
44
|
+
take_while{|line| !line.match(/Beginning vanilla velvetg runs/)}.
|
45
|
+
each do |line|
|
46
|
+
key, value = line.split(":",2)
|
47
|
+
case key
|
48
|
+
when /Velveth version/,
|
49
|
+
/Readfile/,
|
50
|
+
/Velveth parameter string/,
|
51
|
+
/Assembly directory/
|
52
|
+
run[key] = value.strip
|
53
|
+
when /Velveth timestamp/
|
54
|
+
run[key] = Time.parse(value)
|
55
|
+
when /Assembly id/,
|
56
|
+
/Velvet hash value/,
|
57
|
+
/Roadmap file size/
|
58
|
+
run[key] = value.to_i
|
59
|
+
when /\*{10,}/
|
60
|
+
yielder << run unless run.keys.empty?
|
61
|
+
run = {}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def vanilla_velvetg_runs
|
68
|
+
Enumerator.new do |yielder|
|
69
|
+
run = {}
|
70
|
+
@lines.drop_until{|line| line.match(/Beginning vanilla velvetg runs/)}.
|
71
|
+
take_while{|line| !line.match(/Best assembly by assembly score/)}.
|
72
|
+
each do |line|
|
73
|
+
key,value = line.split(":",2)
|
74
|
+
case key
|
75
|
+
when /Assembly id/,
|
76
|
+
/Assembly score/,
|
77
|
+
/Velvet hash value/,
|
78
|
+
/Roadmap file size/,
|
79
|
+
/Total number of contigs/,
|
80
|
+
/n50/,
|
81
|
+
/length of longest contig/,
|
82
|
+
/Total bases in contigs/,
|
83
|
+
/Number of contigs/,
|
84
|
+
/Total bases in contigs/
|
85
|
+
run[key] = value.to_i
|
86
|
+
when /timestamp/
|
87
|
+
run[key] = Time.parse(value)
|
88
|
+
when /version/,
|
89
|
+
/Readfile/,
|
90
|
+
/parameter string/,
|
91
|
+
/Assembly directory/
|
92
|
+
run[key] = value.strip
|
93
|
+
when /\*{10,}/
|
94
|
+
yielder << run unless run.keys.empty?
|
95
|
+
run = {}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def final_assembly
|
102
|
+
run = {}
|
103
|
+
@lines.drop_until{|line| line.match(/Final optimised assembly details/)}.
|
104
|
+
take_while{|line| !line.match(/Assembly output files are in the following directory/)}.
|
105
|
+
each do |line|
|
106
|
+
key, value = line.split(":",2)
|
107
|
+
case key
|
108
|
+
when /Assembly id/,
|
109
|
+
/Assembly score/,
|
110
|
+
/Roadmap file size/,
|
111
|
+
/Total number of contigs/,
|
112
|
+
/n50/,
|
113
|
+
/length of longest contig/,
|
114
|
+
/Total bases in contigs/,
|
115
|
+
/Number of contigs/,
|
116
|
+
/Total bases in contigs/
|
117
|
+
run[key] = value.to_i
|
118
|
+
when /timestamp/
|
119
|
+
run[key] = Time.parse(value)
|
120
|
+
when /version/,
|
121
|
+
/Readfile/,
|
122
|
+
/parameter string/,
|
123
|
+
/Velvet hash value/,
|
124
|
+
/Paired Library insert stats/
|
125
|
+
run[key] = value.strip
|
126
|
+
end
|
127
|
+
end
|
128
|
+
run
|
129
|
+
end
|
130
|
+
|
131
|
+
def summary_table
|
132
|
+
vvgs = vanilla_velvetg_runs.map{|run| run["Run class"] = "vanilla"; run}
|
133
|
+
final = final_assembly
|
134
|
+
final["Run class"] = "optimised"
|
135
|
+
|
136
|
+
all_keys = vvgs.map{|run| run.keys}.flatten + final_assembly.keys
|
137
|
+
all_keys.uniq!
|
138
|
+
output = ''
|
139
|
+
output << all_keys.join("\t") + "\n"
|
140
|
+
vvgs.each do |run|
|
141
|
+
output << all_keys.map{|key| run[key] }.join("\t") + "\n"
|
142
|
+
end
|
143
|
+
output << all_keys.map{|key| final[key] }.join("\t") + "\n"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
ARGV.each do |filename|
|
150
|
+
file = AssemblyPipe::VelvetOptimiser::LogFile.open(filename)
|
151
|
+
puts file.summary_table
|
152
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require "time"
|
2
|
+
require "queue/word_analyser"
|
3
|
+
|
4
|
+
module Enumerable
|
5
|
+
def drop_until
|
6
|
+
condition_met = false
|
7
|
+
Enumerator.new do |yielder|
|
8
|
+
self.each do |element|
|
9
|
+
condition_met ||= yield(element)
|
10
|
+
yielder << element if condition_met
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module AssemblyPipe; end
|
17
|
+
|
18
|
+
module AssemblyPipe::VelvetOptimiser
|
19
|
+
|
20
|
+
class Run
|
21
|
+
def initialize
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class LogFile
|
27
|
+
def initialize(filename)
|
28
|
+
@lines = File.readlines(filename).map{|line| line.strip}
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.open(filename)
|
32
|
+
self.new(filename)
|
33
|
+
end
|
34
|
+
|
35
|
+
def date
|
36
|
+
Time.parse(@lines.first)
|
37
|
+
end
|
38
|
+
|
39
|
+
def velveth_runs
|
40
|
+
Enumerator.new do |yielder|
|
41
|
+
run = {}
|
42
|
+
@lines.drop_until{|line| line.match(/Beginning velveth runs/)}.
|
43
|
+
take_while{|line| !line.match(/Beginning vanilla velvetg runs/)}.
|
44
|
+
each do |line|
|
45
|
+
key, value = line.split(":",2)
|
46
|
+
case key
|
47
|
+
when /Velveth version/,
|
48
|
+
/Readfile/,
|
49
|
+
/Velveth parameter string/,
|
50
|
+
/Assembly directory/
|
51
|
+
run[key] = value.strip
|
52
|
+
when /Velveth timestamp/
|
53
|
+
run[key] = Time.parse(value)
|
54
|
+
when /Assembly id/,
|
55
|
+
/Velvet hash value/,
|
56
|
+
/Roadmap file size/
|
57
|
+
run[key] = value.to_i
|
58
|
+
when /\*{10,}/
|
59
|
+
yielder << run unless run.keys.empty?
|
60
|
+
run = {}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def vanilla_velvetg_runs
|
67
|
+
Enumerator.new do |yielder|
|
68
|
+
run = {}
|
69
|
+
@lines.drop_until{|line| line.match(/Beginning vanilla velvetg runs/)}.
|
70
|
+
take_while{|line| !line.match(/Best assembly by assembly score/)}.
|
71
|
+
each do |line|
|
72
|
+
key,value = line.split(":",2)
|
73
|
+
case key
|
74
|
+
when /Assembly id/,
|
75
|
+
/Assembly score/,
|
76
|
+
/Velvet hash value/,
|
77
|
+
/Roadmap file size/,
|
78
|
+
/Total number of contigs/,
|
79
|
+
/n50/,
|
80
|
+
/length of longest contig/,
|
81
|
+
/Total bases in contigs/,
|
82
|
+
/Number of contigs/,
|
83
|
+
/Total bases in contigs/
|
84
|
+
run[key] = value.to_i
|
85
|
+
when /timestamp/
|
86
|
+
run[key] = Time.parse(value)
|
87
|
+
when /version/,
|
88
|
+
/Readfile/,
|
89
|
+
/parameter string/,
|
90
|
+
/Assembly directory/
|
91
|
+
run[key] = value.strip
|
92
|
+
when /\*{10,}/
|
93
|
+
yielder << run unless run.keys.empty?
|
94
|
+
run = {}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def final_assembly
|
101
|
+
run = {}
|
102
|
+
@lines.drop_until{|line| line.match(/Final optimised assembly details/)}.
|
103
|
+
take_while{|line| !line.match(/Assembly output files are in the following directory/)}.
|
104
|
+
each do |line|
|
105
|
+
key, value = line.split(":",2)
|
106
|
+
case key
|
107
|
+
when /Assembly id/,
|
108
|
+
/Assembly score/,
|
109
|
+
/Roadmap file size/,
|
110
|
+
/Total number of contigs/,
|
111
|
+
/n50/,
|
112
|
+
/length of longest contig/,
|
113
|
+
/Total bases in contigs/,
|
114
|
+
/Number of contigs/,
|
115
|
+
/Total bases in contigs/
|
116
|
+
run[key] = value.to_i
|
117
|
+
when /timestamp/
|
118
|
+
run[key] = Time.parse(value)
|
119
|
+
when /version/,
|
120
|
+
/Readfile/,
|
121
|
+
/parameter string/,
|
122
|
+
/Velvet hash value/,
|
123
|
+
/Paired Library insert stats/
|
124
|
+
run[key] = value.strip
|
125
|
+
end
|
126
|
+
end
|
127
|
+
run
|
128
|
+
end
|
129
|
+
|
130
|
+
def summary_table
|
131
|
+
vvgs = vanilla_velvetg_runs.map{|run| run["Run class"] = "vanilla"; run}
|
132
|
+
final = final_assembly
|
133
|
+
final["Run class"] = "optimised"
|
134
|
+
|
135
|
+
all_keys = vvgs.map{|run| run.keys}.flatten + final_assembly.keys
|
136
|
+
all_keys.uniq!
|
137
|
+
output = ''
|
138
|
+
output << all_keys.join("\t") + "\n"
|
139
|
+
vvgs.each do |run|
|
140
|
+
output << all_keys.map{|key| run[key] }.join("\t") + "\n"
|
141
|
+
end
|
142
|
+
output << all_keys.map{|key| final[key] }.join("\t") + "\n"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|