Skip to content

Instantly share code, notes, and snippets.

@drio
Created May 22, 2010 18:11
Show Gist options
  • Save drio/410252 to your computer and use it in GitHub Desktop.
Save drio/410252 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby19
#
# Total time loading the reference genome: 0 hour, 3 minutes and 2 seconds.
# Total time loading and deleting indexes: 6 hour, 28 minutes and 36 seconds.
# Total time searching indexes: 1 hour, 30 minutes and 2 seconds.
# Total time merging and writing output: 0 hour, 12 minutes and 25 seconds.
# Total time elapsed: 8 hours, 20 minutes and 12 seconds.
#
require 'find'
csv = "/stornext/snfs1/next-gen/solid/csv_dump/csv.dump.latest.csv"
@in_order = [:load_ref, :load_indexes, :searching, :merging, :elapsed]
@res = {
:load_ref => %r{Total time loading the reference genome: (\d+) hour, (\d+) minutes and (\d+) seconds.},
:load_indexes => %r{Total time loading and deleting indexes: (\d+) hour, (\d+) minutes and (\d+) seconds.},
:searching => %r{Total time searching indexes: (\d+) hour, (\d+) minutes and (\d+) seconds.},
:merging => %r{Total time merging and writing output: (\d+) hour, (\d+) minutes and (\d+) seconds.},
:elapsed => %r{Total time elapsed: (\d+) hours, (\d+) minutes and (\d+) seconds.}
}
# Total time searching indexes: 1 hour, 14 minutes and 51 seconds.
def hours_searching_indexes(f)
return nil unless File.exists?(f) and File.readable?(f)
text = File.open(f).read
line = ""
@in_order.each do |s|
if ma = text.match(@res[s])
h, m, s = ma[1..3]
line << "#{h.to_f + m.to_f/60 + s.to_f/3600}, "
else
line << "0, "
end
end
line
end
# Main
#
i=0
File.open(csv).each_line do |l|
next if l =~ /^name/
log_dir = l.split(",")[1].split('/')[0..9].join("/") + "/lsf_logs"
Find.find(log_dir) do |path|
if path =~ %r{.*match.split\d+.\w+.err$}
time = File.stat(path).mtime.strftime("%Y-%m-%d %H:%M")
wtime = hours_searching_indexes(path)
puts time + ", " + wtime if time
end
$stderr.printf "# of files processed: #{i}\r"
i = i + 1
end
end
$stderr.puts "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment