File: pull_header.rb

package info (click to toggle)
pullseq 1.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,460 kB
  • sloc: ansic: 2,581; sh: 148; ruby: 21; makefile: 17
file content (22 lines) | stat: -rw-r--r-- 381 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require 'nubio'
file = ARGV[0]
n = ARGV[1].to_i
range = ARGV[2].to_i
hits = Hash.new
$stderr.puts "file: #{file}; n: #{n}; range: #{range}"
while (n > 0)
  r = rand(range)
  unless hits.has_key?(r)
    n -= 1
    hits[r] = 1
  end
end

count = 0
NuBio::Parser::Fastq.new(file).each do |f|
  count += 1
  if hits.has_key?(count)
    temp = f.header.split
    puts temp[0]
  end
end