bin/fasta_util in fasta_util-0.3.1 vs bin/fasta_util in fasta_util-0.4.0
- old
+ new
@@ -3,22 +3,24 @@
require 'bio'
require 'set'
class FastaUtility < Thor
include Thor::Actions
- Struct.new("Stats", :sum, :l50, :n50, :count, :mean, :median)
+ Struct.new("Stats", :sum, :l50, :n50, :max, :mean, :median, :min, :count)
no_tasks do
def stats(lengths)
lengths = lengths.sort{|a, b| b <=> a}
stats = Struct::Stats.new
temp_sum = 0
stats[:sum] = lengths.inject(:+)
stats[:l50] = lengths.find{|length| (temp_sum += length) > stats[:sum]/2.0}
stats[:n50] = lengths.count{|length| length >= stats[:l50]}
+ stats[:max] = lengths.max
stats[:mean] = stats[:sum].to_f/lengths.length
stats[:median] = (lengths.length % 2 == 0) ? (lengths[lengths.length/2-1] + lengths[lengths.length/2])/2.0 : lengths[lengths.length/2]
+ stats[:min] = lengths.min
stats[:count] = lengths.count
return stats
end
def format(stats)