Sha256: 5027fbdd09f76c6d898c9bd9eb1956f9cacd7764875698fa26827d4eb6d31bff

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require "ecf_classify/version"
require "ecf_classify/runner"
require "ecf_classify/hmmer"
require "ecf_classify/utils"
require "ecf_classify/zenodo"
require "tempfile"
require 'thor'

module EcfClassify
  class CLI < Thor
    package_name "#{EcfClassify::NAME}"
    class_option :help, aliases: "-h", type: :boolean
    map %w[--version] => :__print_version

    desc "--version", "print the version"
    def __print_version
      puts "#{EcfClassify::NAME}: #{EcfClassify::VERSION}"
      exit
    end

    desc "groups [FILE]", "Classifies protein sequences into ECF groups"
    method_option :probabilities, type: :string, aliases: "-p", default: nil
    def groups(file)
      handle_help_option(__method__)

      conserved = Tempfile.new("conserved")
      begin
        STDERR.puts EcfClassify::Runner.general(file,conserved.path)
        conserved.rewind
        STDOUT.puts EcfClassify::Runner.specific(conserved.path, __method__, options.probabilities)
      ensure
        conserved.close
        conserved.unlink
      end
    end

    desc "subgroups [FILE]", "Classifies protein sequences into ECF subgroups"
    method_option :probabilities, type: :string, aliases: "-p", default: nil
    def subgroups(file)
      handle_help_option(__method__)

      conserved = Tempfile.new("conserved")
      begin
        STDERR.puts EcfClassify::Runner.general(file,conserved.path)
        conserved.rewind
        STDOUT.puts EcfClassify::Runner.specific(conserved.path, __method__, options.probabilities)
      ensure
        conserved.close
        conserved.unlink
      end
    end

    desc "download", "Downloads HMM models from Zenodo"
    def download
      EcfClassify::Zenodo.download
    end

    no_commands do
      def handle_help_option(method_name)
        if options[:help]
          help(method_name)
          exit
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ecf_classify-1.0.2 lib/ecf_classify.rb