Skip to content

Instantly share code, notes, and snippets.

@drio drio/parse_fastq

Created Aug 18, 2011
Embed
What would you like to do?
parse fastq files and filter out base on name
#!/usr/bin/env ruby
# http://biostar.stackexchange.com/questions/10376/how-to-efficiently-parse-a-huge-fastq-file
# Usage: cat my.fastq | parse_fastq.rb list.txt
h = {} # hash with reads I am looking for
File.open(ARGV[0].to_s).each_line {|l| h["@" + l] = 1}
ln, f = [0, 0] # line number, flag
$stdin.each_line do |l|
f = h[l] ? 1 : 0 if ln % 4 == 0
puts l if f == 1
ln = ln + 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.