Module: NeuroHmmerApp
- Defined in:
- lib/neurohmmerapp/config.rb,
lib/neurohmmerapp.rb,
lib/neurohmmerapp/logger.rb,
lib/neurohmmerapp/routes.rb,
lib/neurohmmerapp/server.rb,
lib/neurohmmerapp/version.rb,
lib/neurohmmerapp/exceptions.rb,
lib/neurohmmerapp/neurohmmer.rb
Overview
This file defines all possible exceptions that can be thrown by NeuroHmmerApp on startup.
Exceptions only ever inform another entity (downstream code or users) of an issue. Exceptions may or may not be recoverable.
Error classes should be seen as: the error code (class name), human readable message (to_s method), and necessary attributes to act on the error.
We define as many error classes as needed to be precise about the issue, thus making it easy for downstream code (bin/genevalidatorapp or config.ru) to act on them.
Defined Under Namespace
Modules: RunNeuroHmmer Classes: BIN_DIR_NOT_FOUND, CONFIG_FILE_ERROR, Config, ENOENT, Logger, NUM_THREADS_INCORRECT, Routes, Server
Constant Summary collapse
- MINIMUM_HMMER_VERSION =
Use a fixed minimum version of BLAST+
'3.0.0'
- VERSION =
'0.0.7'
Class Attribute Summary collapse
-
.config ⇒ Object
readonly
Returns the value of attribute config.
-
.public_dir ⇒ Object
readonly
Returns the value of attribute public_dir.
-
.temp_dir ⇒ Object
readonly
Returns the value of attribute temp_dir.
Class Method Summary collapse
-
.call(env) ⇒ Object
Rack-interface.
- .environment ⇒ Object
-
.init(config = {}) ⇒ Object
Setting up the environment before running the app…
- .logger ⇒ Object
- .on_start ⇒ Object
- .on_stop ⇒ Object
- .root ⇒ Object
-
.run ⇒ Object
Starting the app manually.
- .verbose? ⇒ Boolean
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
44 45 46 |
# File 'lib/neurohmmerapp.rb', line 44 def config @config end |
.public_dir ⇒ Object (readonly)
Returns the value of attribute public_dir.
44 45 46 |
# File 'lib/neurohmmerapp.rb', line 44 def public_dir @public_dir end |
.temp_dir ⇒ Object (readonly)
Returns the value of attribute temp_dir.
44 45 46 |
# File 'lib/neurohmmerapp.rb', line 44 def temp_dir @temp_dir end |
Class Method Details
.call(env) ⇒ Object
Rack-interface.
Inject our logger in the env and dispatch request to our controller.
80 81 82 83 |
# File 'lib/neurohmmerapp.rb', line 80 def call(env) env['rack.logger'] = logger Routes.call(env) end |
.environment ⇒ Object
17 18 19 |
# File 'lib/neurohmmerapp.rb', line 17 def environment ENV['RACK_ENV'] end |
.init(config = {}) ⇒ Object
Setting up the environment before running the app…
34 35 36 37 38 39 40 41 42 |
# File 'lib/neurohmmerapp.rb', line 34 def init(config = {}) @config = Config.new(config) init_binaries init_dirs check_num_threads check_max_characters self end |
.logger ⇒ Object
29 30 31 |
# File 'lib/neurohmmerapp.rb', line 29 def logger @logger ||= Logger.new(STDERR, verbose?) end |
.on_start ⇒ Object
62 63 64 65 66 67 |
# File 'lib/neurohmmerapp.rb', line 62 def on_start puts '** NeuroHmmer is ready.' puts " Go to #{server_url} in your browser and start analysing genes!" puts ' Press CTRL+C to quit.' open_in_browser(server_url) end |
.on_stop ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/neurohmmerapp.rb', line 69 def on_stop puts puts '** Thank you for using NeuroHmmerApp :).' puts ' Please cite: ' puts ' Moghul M.I., Elphick M & Wurm Y (in prep).' puts ' NeuroHmmer: identify Neuropeptide Precursors.' end |
.root ⇒ Object
25 26 27 |
# File 'lib/neurohmmerapp.rb', line 25 def root File.dirname(File.dirname(__FILE__)) end |
.run ⇒ Object
Starting the app manually
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/neurohmmerapp.rb', line 47 def run check_host Server.run(self) rescue Errno::EADDRINUSE puts "** Could not bind to port #{config[:port]}." puts " Is NeuroHmmer already accessible at #{server_url}?" puts ' No? Try running NeuroHmmer on another port, like so:' puts puts ' neurohmmerapp -p 4570.' rescue Errno::EACCES puts "** Need root privilege to bind to port #{config[:port]}." puts ' It is not advisable to run NeuroHmmer as root.' puts ' Please use Apache/Nginx to bind to a privileged port.' end |
.verbose? ⇒ Boolean
21 22 23 |
# File 'lib/neurohmmerapp.rb', line 21 def verbose? @verbose ||= (environment == 'development') end |