Class: SequenceLogo::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/sequence_logo/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CLI

Returns a new instance of CLI.



8
9
10
# File 'lib/sequence_logo/cli.rb', line 8

def initialize(options = {})
  @options = options.dup
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/sequence_logo/cli.rb', line 7

def options
  @options
end

Instance Method Details

#parse_options!(argv) ⇒ Object



11
12
13
14
# File 'lib/sequence_logo/cli.rb', line 11

def parse_options!(argv)
  parser.parse!(argv)
  options
end

#parserObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sequence_logo/cli.rb', line 15

def parser
  @parser ||= OptionParser.new do |opts|
    opts.version = ::SequenceLogo::VERSION
    opts.on('-x', '--x-unit X_UNIT', 'Single letter width') do |v|
      options[:x_unit] = v.to_i
    end
    opts.on('-y', '--y-unit Y_UNIT', 'Base letter height') do |v|
      options[:y_unit] = v.to_i
    end
    opts.on('--icd-mode MODE', 'Calculation mode: discrete or weblogo', 'Weblogo is assumed if word count not given') do |v|
      options[:icd_mode] = v.to_sym
      raise ArgumentError, 'icd-mode can be either discrete or weblogo'  unless [:discrete, :weblogo].include?(options[:icd_mode])
    end
    opts.on('--[no-]threshold-lines', 'Draw threshold lines') do |v|
      options[:threshold_lines] = v
    end
    opts.on('--scheme SCHEME', 'Specify folder with nucleotide images') do |v|
      options[:scheme] = v
    end
  end
end