Sha256: 5b68b7ea5cb6dc581334457e1d9b59779ba0af91134eecd938d92e2a861b0308

Contents?: true

Size: 1.12 KB

Versions: 28

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby

require 'yajl'
require 'json'

unless file = ARGV.shift
  puts "\nUsage: $0 results.json action1 [action] [action] [action] ...\n\n"
  exit(0)
end


actions = ARGV
if actions.empty?
  puts "\nUsage: $0 results.json action1 [action] [action] [action] ...\n\n"
  exit(0)
end
  
json = File.new(file, 'r')

puts "Counting sequences with these actions: #{actions.join(",")}"
puts ""

total = 0
count = 0
separate_count={}

actions.each do |a|
  separate_count[a]=0
end

all_actions =[]

Yajl::Parser.parse(json) { |seq|

  total += 1
  action_names=seq['actions'].map {|a| a['type']}
  
  if (action_names & actions).count == actions.count
    count +=1
  end
  
  action_names.each do |a|
    if actions.include?(a)
        separate_count[a] += 1
    end
  end
  
  all_actions = (all_actions + action_names).uniq

}

puts "="*20 + "Separate count" + "="*20
separate_count.each do |k,v|
  puts "#{k} = #{v}"
  
end
puts "="*20 + "Summarized" + "="*20

puts "Number of sequences with all actions: #{count}"
puts "Total sequences: #{total}"

puts "\n"
puts "="*20 + "Other used actions" + "="*20
puts (all_actions-actions).join(',')


Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
seqtrimnext-2.0.38 bin/parse_json_results.rb
seqtrimnext-2.0.36 bin/parse_json_results.rb
seqtrimnext-2.0.35 bin/parse_json_results.rb
seqtrimnext-2.0.33 bin/parse_json_results.rb
seqtrimnext-2.0.32 bin/parse_json_results.rb
seqtrimnext-2.0.31 bin/parse_json_results.rb
seqtrimnext-2.0.30 bin/parse_json_results.rb
seqtrimnext-2.0.29 bin/parse_json_results.rb