#!/usr/bin/env ruby $LOAD_PATH.unshift(File.expand_path("../../lib", __FILE__)) require 'trollop' require 'fetch_tools/blast_db' FETCH_TOOLS = { "blastdbcmd" => ["blastdbcmd"] } module Quorum # # Parse Options for Quorum Fetch # class Fetch def initialize opts = Trollop::options do text <<-HEAD Quorum A flexible bioinformatics search tool. Options: HEAD # Fetch tool opt :fetch_tool, "Fetch tool to execute. Available tools: " << "#{FETCH_TOOLS.keys.join(', ')}", :type => :string, :required => true, :short => "-f" # General settings opt :log_directory, "Path to log directory", :type => :string, :required => true, :short => "-l" opt :tmp_directory, "Path to tmp directory", :type => :string, :required => true, :short => "-m" # Global settings opt :fetch_database, "Path to fetch tool database", :type => :string, :short => "-d" opt :fetch_database_names, "Semicolon delimited database names", :type => :string, :short => "-n" # Algorithm specific opts opt :blast_hit_id, "Blast hit id", :type => :string, :short => "-b" opt :blast_hit_display_id, "Blast hit display id", :type => :string, :short => "-s" opt :blast_algo, "Blast algorithm", :type => :string, :short => "-a" end @args = {} # Contains valid opts. ## Additional opt validation. ## unless FETCH_TOOLS.keys.include?(opts[:fetch_tool].downcase) Trollop::die :fetch_tool, "fetch_tool not found\n" << "Available tools: " + FETCH_TOOLS.keys.join(", ") end @args[:fetch_tool] = opts[:fetch_tool].downcase unless opts[:fetch_database] && Dir.exists?(opts[:fetch_database]) Trollop::die :fetch_database, "fetch tool database not found\n" << "Supplied directory: " + opts[:fetch_database] end @args[:fetch_database] = opts[:fetch_database] @args[:fetch_database_names] = opts[:fetch_database_names] unless Dir.exists?(opts[:log_directory]) Trollop::die :log_directory, "log directory not found\n" << "Supplied directory: " + opts[:log_directory] end @args[:log_directory] = opts[:log_directory] @args[:tmp_directory] = opts[:tmp_directory] @args[:blast_hit_id] = opts[:blast_hit_id] @args[:blast_hit_display_id] = opts[:blast_hit_display_id] @args[:blast_algo] = opts[:blast_algo] ## Check System Dependancies ## check_dependencies ## Execute fetch tool ## if @args[:fetch_tool].include? "blastdbcmd" blast = Quorum::FetchTools::BlastDb.new(@args) blast.execute_blast_db_cmd end end # # Check system dependencies. # def check_dependencies FETCH_TOOLS[@args[:fetch_tool]].each do |f| system("which #{f} > /dev/null 2>&1") if $?.exitstatus > 0 Trollop::die "Quorum dependency not found for tool " << "#{@args[:fetch_tool].to_s}. Please add `#{f}` to your PATH." end end end end end if __FILE__ == $0 Quorum::Fetch.new end