#!/usr/bin/env ruby $:<< File.expand_path(File.join(File.dirname(File.dirname __FILE__),"lib")) require 'bio-pipengine' banner_text = "\nLauncher for Complex Biological Pipelines . Copyright(C) 2013 Francesco Strozzi, Raoul Jean Pierre Bonnal\n\n" version_text = File.read File.expand_path(File.join(File.dirname(File.dirname __FILE__),"VERSION")) SUB_COMMANDS = %w(run jobs) #Bio::Pipengine.check_config options = {} cmd = ARGV.first # get the subcommand opts = case cmd when "run" options[:run] = true ARGV.shift Trollop::options do opt :pipeline, "YAML file with pipeline and sample details", :short => "p", :type => :string, :default => "pipeline.yml" opt :samples_file, "YAML file with samples name and directory paths", :short => "f", :type => :string, :default => "samples.yml" opt :samples, "List of sample names to run the pipeline", :type => :strings, :short => "l" opt :steps, "List of steps to be executed", :type => :strings, :short => "s" opt :dry,"Dry run. Just create the job script without submitting it to the batch system", :short => "d" opt :tmp, "Temporary output folder", :type => :string, :short => "t" opt :create_samples, "Create samples.yml file from a Sample directory (only for CASAVA projects)", :short => "c", :type => :strings opt :multi, "List of samples to be processed by a given step (the order matters)", :short => "m", :type => :strings opt :group, "Specify the group of samples to run the pipeline steps on (do not specify --multi)", :short => "g", :type => :string opt :allgroups, "Apply the step(s) to all the groups defined into the samples file", :short => "a" opt :name, "Analysis name", :short => "n", :type => :string opt :output_dir, "Output directory (override standard output directory names)", :short => "o", :type => :string opt :pbs_opts, "PBS options", :type => :strings, :short => "b" opt :pbs_queue, "PBS queue", :type => :string, :short => "q" opt :inspect_pipeline, "Show steps", :short => "i", :type => :string opt :log, "Log script activities, by default stdin. Options are fluentd", :type => :string, :default => "stdin" opt :log_adapter, "(stdin|syslog|fluentd) In case of fluentd use http://destination.hostname:port/yourtag", :type => :string end #when "jobs" # ARGV.shift # options[:jobs] = true # Trollop::options do # opt :job_id, "Search submitted jobs by Job ID", :type => :strings, :short => "i" # opt :job_name, "Search submitted jobs by Job Name", :type => :strings, :short => "n" # opt :delete, "Delete submitted jobs ('all' to erase everything or type one or more job IDs)", :short => "d", :type => :strings # end when "-h" puts banner_text puts "List of available commands:\n\trun\tSubmit pipelines to the job scheduler\n\tjobs\tShow statistics and interact with running jobs\n" exit else global_opts = Trollop::options do banner banner_text version "PipEngine v#{version_text}" end end options = options.merge opts Trollop::die :multi, "Specifing both --group and --multi is not allowed" if options[:multi] and options[:group] if options[:create_samples] Bio::Pipengine.create_samples options[:create_samples] #elsif options[:jobs] # if options[:job_id] # Bio::Pipengine.show_stats(options[:job_id]) # elsif options[:job_name] # warn "Not yet implemented" # exit # elsif options[:delete] # if options[:delete].empty? # warn "Provide one or more Job IDs or write 'all' to delete all your running jobs".red # exit # end # puts "Warning: this will delete the following running jobs: ".light_blue + "#{options[:delete].join(",")}".green # print "Are you sure? (y|n):" # answer = gets.chomp # if answer == "y" # Bio::Pipengine.delete_jobs(options[:delete]) # else # puts "Aborting..." # exit # end # else # Bio::Pipengine.show_stats(["all"]) # end elsif options[:pipeline] && options[:samples_file] if options[:inspect_pipeline] Bio::Pipengine.inspect_steps(options[:inspect_pipeline]) exit else abort("File not found: #{options[:pipeline]}".red) unless File.exists? options[:pipeline] abort("File not found: #{options[:samples_file]}".red) unless File.exists? options[:samples_file] abort("Please provide a valid step name with the --step parameter".red) unless options[:steps] if options[:allgroups] Bio::Pipengine.load_samples_file(options[:samples_file])["samples"].keys.each do |group| options[:group] = group Bio::Pipengine.run(options) end else Bio::Pipengine.run(options) end end end