#!/usr/bin/env ruby require 'rbbt/util/simpleopt' require 'rbbt/workflow' require 'rbbt/workflow/usage' require 'rbbt/entity/study' require 'rbbt/entity/study/genotypes' require 'rbbt/entity/study/cnv' require 'rbbt/entity/study/expression' def usage(workflow = nil, task = nil) puts SOPT.doc puts "## WORKFLOW" puts if workflow.nil? puts "No workflow specified" exit -1 end if task.nil? workflow.load_tasks if workflow.respond_to? :load_tasks workflow.doc else puts workflow.to_s puts "=" * workflow.to_s.length puts puts workflow.workflow_description puts workflow.doc(task) end exit 0 end def SOPT_options(workflow, task) sopt_options = [] workflow.rec_inputs(task.name).each do |name| short = name.to_s.chars.first boolean = workflow.rec_input_types(task.name)[name].to_sym == :boolean sopt_options << "-#{short}--#{name}#{boolean ? '' : '*'}" end sopt_options * ":" end def fix_options(workflow, task, job_options) option_types = workflow.rec_input_types(task.name) job_options_cleaned = {} job_options.each do |name, value| value = case option_types[name].to_sym when :float value.to_f when :integer value.to_i when :string, :text case when value == '-' STDIN.read when (String === value and File.exists?(value) and not File.directory?(value)) Open.read(value) else value end when :array if Array === value value else str = case when value == '-' STDIN.read when (String === value and File.exists?(value)) Open.read(value) else value end if $array_separator str.split(/#{$array_separator}/) else str.split(/[,|\s]/) end end when :tsv case value when TSV value when '-' TSV.open(STDIN) else TSV.open(value) end else value end job_options_cleaned[name] = value end job_options_cleaned end options = SOPT.get <