Class: Genfrag::App

Inherits:
Object
  • Object
show all
Defined in:
lib/genfrag/app.rb,
lib/genfrag/app/command.rb,
lib/genfrag/app/index_command.rb,
lib/genfrag/app/search_command.rb,
lib/genfrag/app/index_command/db.rb,
lib/genfrag/app/search_command/trim.rb,
lib/genfrag/app/search_command/match.rb,
lib/genfrag/app/search_command/process_file.rb

Defined Under Namespace

Classes: Command, IndexCommand, SearchCommand

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Create a new main instance using io for standard output and err for error messages.



30
31
32
33
# File 'lib/genfrag/app.rb', line 30

def initialize( out = STDOUT, err = STDERR )
  @out = out
  @err = err
end

Class Method Details

.cli_run(args) ⇒ Object

Create a new instance of App, and run the genfrag application given the command line args.



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

def self.cli_run( args )
  self.new.cli_run args
end

Instance Method Details

#cli_run(args) ⇒ Object

Parse the desired user command and run that command object.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/genfrag/app.rb', line 37

def cli_run( args )
  cmd_str = args.shift
  cmd = case cmd_str
    when 'index';     IndexCommand.new(@out, @err)
    when 'search';    SearchCommand.new(@out, @err)
    when 'info';      InfoCommand.new(@out, @err)
    when nil, '-h', '--help'
      help
    when '-V', '--version'
      @out.puts "Genfrag #{::Genfrag::VERSION}"
      nil
    else
      @err.puts "Unknown command #{cmd_str.inspect}"
      help
      nil
    end

  cmd.cli_run args if cmd

rescue StandardError => err
  @err.puts "ERROR:  While executing genfrag ... (#{err.class})"
  @err.puts "    #{err.to_s}"
  @err.puts %Q(    #{err.backtrace.join("\n\t")})
  exit 1
end

#helpObject

Show the toplevel help message.



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
# File 'lib/genfrag/app.rb', line 65

def help
  @out.puts "\nGenFrag allows for rapid in-silico searching of fragments cut by\ndifferent restriction enzymes in large nucleotide acid databases,\nfollowed by matching specificity adapters which allow a further data\nreduction when looking for differential expression of genes and\nmarkers.\n  \nUsage:\n  genfrag -h/--help\n  genfrag -V/--version\n  genfrag command [options] [arguments]\n\nExamples:\n  genfrag index -f example.fasta --RE5 BstYI --RE3 MseI\n  genfrag search -f example.fasta --RE5 BstYI --RE3 MseI --adapter5 ct\n\nCommands:\n  genfrag index           initialize the index\n  genfrag search          search FIXME\n  genfrag info            show information about FIXME\n\nFurther Help:\n  Each command has a '--help' option that will provide detailed\n  information for that command.\n\n  http://genfrag.rubyforge.org/\n\n  MSG\n  nil\nend\n"