Class: Genfrag::App::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/genfrag/app/command.rb

Direct Known Subclasses

IndexCommand, SearchCommand

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out = STDOUT, err = STDERR) ⇒ Command

Returns a new instance of Command.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/genfrag/app/command.rb', line 10

def initialize( out = STDOUT, err = STDERR )
  @out = out
  @err = err
  @options = {
  #  :skeleton_dir => File.join(mrbones_dir, 'data'),
  #  :with_tasks => false,
  #  :verbose => false,
  #  :name => nil,
  #  :output_dir => nil
  }
  @ops = OpenStruct.new
  #@options[:skeleton_dir] = ::Bones.path('data') unless test(?d, skeleton_dir)
end

Instance Attribute Details

#opsObject

an OpenStruct of the options



8
9
10
# File 'lib/genfrag/app/command.rb', line 8

def ops
  @ops
end

#optionsObject

a Hash used by optparse



7
8
9
# File 'lib/genfrag/app/command.rb', line 7

def options
  @options
end

Instance Method Details

#cli_p(cli = true, str = '') ⇒ Object

Print running output when used in command-line mode



34
35
36
37
# File 'lib/genfrag/app/command.rb', line 34

def cli_p(cli=true, str='')
  return false if !cli or @ops.quiet
  @out.puts str
end

#cli_run(args) ⇒ Object

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/genfrag/app/command.rb', line 24

def cli_run( args )
  raise NotImplementedError
end

#clierr_p(str) ⇒ Object

Print an error from the command-line options



41
42
43
44
45
46
# File 'lib/genfrag/app/command.rb', line 41

def clierr_p(str)
  @out.puts
  @err.puts "Error: #{str}"
  @out.puts
  @out.puts opt_parser
end

#run(args) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/genfrag/app/command.rb', line 28

def run( args )
  raise NotImplementedError
end

#standard_optionsObject

Define the command-line option available



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/genfrag/app/command.rb', line 50

def standard_options
  {
    :verbose => ['-v', '--verbose', 'enable verbose output',
        lambda { |ruby19bug|
          options[:verbose] = true
        }],
    :tracktime => ['-m', '--tracktime', 'track execution time',
        lambda { |ruby19bug|
          options[:tracktime] = true
        }],
    :quiet => ['-q', '--quiet', 'silence output',
        lambda { |ruby19bug|
          options[:quiet] = true
        }],
    :indir => ['-i', '--in DIR', String, 'input directory', "(default #{Dir.pwd})",
        lambda{ |value|
          options[:indir] = value
        }],
    :outdir => ['-o', '--out DIR', String, 'output directory', "(default #{Dir.pwd})",
        lambda{ |value|
          options[:outdir] = value
        }],
    :re5 => ['-5', '--re5 ENZYME', String, "5' restriction enzyme",
        lambda { |value|
          options[:re5] = value
        }],
    :re3 => ['-3', '--re3 ENZYME', String, "3' restriction enzyme",
        lambda { |value|
          options[:re3] = value
        }],
    :sqlite => ['-t', '--sqlite', 'use sqlite', '(default is tab-delimited)',
        lambda { |ruby19bug|
          options[:sqlite] = true
        }],
    :filelookup => ['-l', '--lookup FILE', String, "name of the frequency lookup file generated by 'index'",
        lambda { |value|
          options[:filelookup] = value
        }],
    :filefasta => ['-f', '--fasta FILE', String, 'name of the Fasta sequences file',
        lambda { |value|
          options[:filefasta] = value
        }],
    :seqsize => ['-s', '--seqsize SIZE', Array, '',
        lambda { |value|
          options[:seqsize] = value
        }],
        
    :adapter5 => ['-y', '--adapter5 ADAPTER', String, '',
        lambda { |value|
          options[:adapter5] = value
        }],
    :adapter3 => ['-z', '--adapter3 ADAPTER', String, '',
        lambda { |value|
          options[:adapter3] = value
        }],
        
    :named_adapter5 => ['-b', '--named-adapter5 NAME', String, '',
        lambda { |value|
          options[:named_adapter5] = value
        }],
    :named_adapter3 => ['-c', '--named-adapter3 NAME', String, '',
        lambda { |value|
          options[:named_adapter3] = value
        }],
        
    :adapter5_size => ['-d', '--adapter5-size SIZE', Integer, '',
        lambda { |value|
          options[:adapter5_size] = value
        }],
    :adapter3_size => ['-e', '--adapter3-size SIZE', Integer, '',
        lambda { |value|
          options[:adapter3_size] = value
        }],
        
    :adapter5_sequence => ['-w', '--adapter5-sequence SEQUENCE', String, '',
        lambda { |value|
          options[:adapter5_sequence] = value
        }],
    :adapter3_sequence => ['-x', '--adapter3-sequence SEQUENCE', String, '',
        lambda { |value|
          options[:adapter3_sequence] = value
        }],
        
    :fileadapters => ['-a', '--adapters FILE', String, '',
        lambda { |value|
          options[:fileadapters] = value
        }]

  }
end