Advertisement
cd62131

Rebuild FASTA

Feb 16th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.34 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. fasta = ARGF.gets.split.drop(1).map do |in_file|
  3.   open(in_file).slice_before(/\A>/).map do |lines|
  4.     [lines.first.match(/\A>(\S+)/)[1], lines]
  5.   end
  6. end.flatten(1).to_h
  7. ARGF.each do |line|
  8.   out_file, *ids = line.split
  9.   open(out_file, 'w') do |f|
  10.     ids.each do |id|
  11.       f.puts fasta[id].join
  12.     end
  13.   end
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement