Last active
September 4, 2019 01:52
-
-
Save inutano/3df675a0489ca670e9e4311dc86bcd6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'json' | |
require 'pp' | |
module CWL | |
class Workflow | |
def initialize(fpath) | |
@workflow = YAML.load(open(fpath)) | |
end | |
def stats_json | |
JSON.dump(stats) | |
end | |
def stats | |
{ | |
total_number_of_steps: number_of_steps, | |
total_number_of_inputs: total_number_of_inputs, | |
number_of_inputs_per_step: number_of_inputs_per_step, | |
} | |
end | |
def steps | |
@workflow['steps'] | |
end | |
def number_of_steps | |
steps.keys.size | |
end | |
def total_number_of_inputs | |
number_of_inputs_per_step.each_value.sum | |
end | |
def number_of_inputs_per_step | |
Hash[steps.each_pair.map{|k,v| [k.intern, v['in'].keys.size] }] | |
end | |
end | |
end | |
if __FILE__ == $0 | |
if ARGV[1] == "--json" | |
puts CWL::Workflow.new(ARGV.first).stats_json | |
else | |
pp CWL::Workflow.new(ARGV.first).stats | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment