Class: AssemblyPipe::VelvetOptimiser::LogFile
- Inherits:
-
Object
- Object
- AssemblyPipe::VelvetOptimiser::LogFile
- Defined in:
- lib/assembly_pipe.rb,
bin/assembly_pipe
Class Method Summary collapse
Instance Method Summary collapse
- #date ⇒ Object
- #final_assembly ⇒ Object
-
#initialize(filename) ⇒ LogFile
constructor
A new instance of LogFile.
- #summary_table ⇒ Object
- #vanilla_velvetg_runs ⇒ Object
- #velveth_runs ⇒ Object
Constructor Details
#initialize(filename) ⇒ LogFile
Returns a new instance of LogFile.
27 28 29 |
# File 'lib/assembly_pipe.rb', line 27 def initialize(filename) @lines = File.readlines(filename).map{|line| line.strip} end |
Class Method Details
.open(filename) ⇒ Object
31 32 33 |
# File 'lib/assembly_pipe.rb', line 31 def self.open(filename) self.new(filename) end |
Instance Method Details
#date ⇒ Object
35 36 37 |
# File 'lib/assembly_pipe.rb', line 35 def date Time.parse(@lines.first) end |
#final_assembly ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/assembly_pipe.rb', line 100 def final_assembly run = {} @lines.drop_until{|line| line.match(/Final optimised assembly details/)}. take_while{|line| !line.match(/Assembly output files are in the following directory/)}. each do |line| key, value = line.split(":",2) case key when /Assembly id/, /Assembly score/, /Roadmap file size/, /Total number of contigs/, /n50/, /length of longest contig/, /Total bases in contigs/, /Number of contigs/, /Total bases in contigs/ run[key] = value.to_i when /timestamp/ run[key] = Time.parse(value) when /version/, /Readfile/, /parameter string/, /Velvet hash value/, /Paired Library insert stats/ run[key] = value.strip end end run end |
#summary_table ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/assembly_pipe.rb', line 130 def summary_table vvgs = vanilla_velvetg_runs.map{|run| run["Run class"] = "vanilla"; run} final = final_assembly final["Run class"] = "optimised" all_keys = vvgs.map{|run| run.keys}.flatten + final_assembly.keys all_keys.uniq! output = '' output << all_keys.join("\t") + "\n" vvgs.each do |run| output << all_keys.map{|key| run[key] }.join("\t") + "\n" end output << all_keys.map{|key| final[key] }.join("\t") + "\n" end |
#vanilla_velvetg_runs ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/assembly_pipe.rb', line 66 def vanilla_velvetg_runs Enumerator.new do |yielder| run = {} @lines.drop_until{|line| line.match(/Beginning vanilla velvetg runs/)}. take_while{|line| !line.match(/Best assembly by assembly score/)}. each do |line| key,value = line.split(":",2) case key when /Assembly id/, /Assembly score/, /Velvet hash value/, /Roadmap file size/, /Total number of contigs/, /n50/, /length of longest contig/, /Total bases in contigs/, /Number of contigs/, /Total bases in contigs/ run[key] = value.to_i when /timestamp/ run[key] = Time.parse(value) when /version/, /Readfile/, /parameter string/, /Assembly directory/ run[key] = value.strip when /\*{10,}/ yielder << run unless run.keys.empty? run = {} end end end end |
#velveth_runs ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/assembly_pipe.rb', line 39 def velveth_runs Enumerator.new do |yielder| run = {} @lines.drop_until{|line| line.match(/Beginning velveth runs/)}. take_while{|line| !line.match(/Beginning vanilla velvetg runs/)}. each do |line| key, value = line.split(":",2) case key when /Velveth version/, /Readfile/, /Velveth parameter string/, /Assembly directory/ run[key] = value.strip when /Velveth timestamp/ run[key] = Time.parse(value) when /Assembly id/, /Velvet hash value/, /Roadmap file size/ run[key] = value.to_i when /\*{10,}/ yielder << run unless run.keys.empty? run = {} end end end end |