Skip to content

Instantly share code, notes, and snippets.

@audy
Forked from cvonkleist/big_shuffle.rb
Created August 24, 2012 20:54
Show Gist options
  • Save audy/3455503 to your computer and use it in GitHub Desktop.
Save audy/3455503 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
sequence_starts = Array.new
filename = ARGV[0]
# preprocess
File.open(filename, "r") do |input|
input.each do |line|
if line =~ /^>/
sequence_starts << input.pos
end
end
end
# random sort, retrieve from file
line_starts.shuffle!
File.open(filename, "r") do |input|
until line_starts.empty?
input.seek(line_starts.shift)
puts input.readline
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment