def initialize(sff_file, tmpdir)
@sff_file = sff_file
- @out1_file = File.join(tmpdir, "out1.txt")
- @out2_file = File.join(tmpdir, "out2.txt")
+ @anal_file = File.join(tmpdir, "out1.txt")
@count = 0
@min = 0
@max = 0
bp_seq_analyze
parse_analyze_vals
- parse_mean_vals
end
private
system(
"read_sff -i #{@sff_file} |
progress_meter |
- analyze_vals -k SEQ -o #{@out1_file} |
analyze_seq |
- mean_vals -k 'GC%,HARD_MASK%,SOFT_MASK%' -o #{@out2_file} -x"
+ analyze_vals -k SEQ,GC%,HARD_MASK%,SOFT_MASK% -x |
+ write_tab -o #{@anal_file} -x"
)
STDERR.puts "done.\n"
end
def parse_analyze_vals
- File.open(@out1_file, "r") do |ios|
+ File.open(@anal_file, "r") do |ios|
while not ios.eof?
- line = ios.readline.chomp
-
- case line
- when /COUNT\s+(\d+)/; then @count = $1
- when /MIN\s+(\d+)/; then @min = $1
- when /MAX\s+(\d+)/; then @max = $1
- when /MEAN\s+(\d+)/; then @mean = $1
- when /SUM\s+(\d+)/; then @bases = $1
- end
- end
- end
- end
-
- def parse_mean_vals
- File.open(@out2_file, "r") do |ios|
- while not ios.eof?
- line = ios.readline.chomp
-
- case line
- when /GC%_MEAN: (.+)/; then @gc = $1
- when /HARD_MASK%_MEAN: (.+)/; then @hard = $1
- when /SOFT_MASK%_MEAN: (.+)/; then @soft = $1
+ line = ios.readline.chomp
+ fields = line.split("\t")
+
+ case fields.first
+ when "SEQ" then @count, @min, @max, @bases, @mean = fields[2 .. 6]
+ when "GC%" then @gc = fields[6]
+ when "HARD_MASK%" then @hard = fields[6]
+ when "SOFT_MASK%" then @soft = fields[6]
end
end
end