-
- class FreqTable
- def initialize(sff_file, tmpdir)
- @sff_file = sff_file
- @tab_file = File.join(tmpdir, "freq.tab")
-
- bp_frequency_table
- end
-
- def each
- File.open(@tab_file, "r") do |ios|
- while not ios.eof? do
- fields = ios.readline.chomp.split("\t")
- yield FreqRow.new(fields[0], fields[1], fields[2], fields[3], fields[4])
- end
- end
- end
-
- private
-
- def bp_frequency_table
- STDERR.puts "Creating residue frequency table ... "
- system(
- "read_sff -i #{@sff_file} |
- progress_meter |
- extract_seq -l 50 |
- uppercase_seq |
- create_weight_matrix -p |
- flip_tab |
- write_tab -o #{@tab_file} -x"
- )
- STDERR.puts "done.\n"
- end
-
- class FreqRow
- attr_reader :res_A, :res_C, :res_G, :res_N, :res_T
-
- def initialize(res_A, res_C, res_G, res_N, res_T)
- @res_A = res_A
- @res_C = res_C
- @res_G = res_G
- @res_N = res_N
- @res_T = res_T
- end
- end
- end