Module: GeneValidatorApp
- Defined in:
- lib/genevalidatorapp/config.rb,
lib/genevalidatorapp.rb,
lib/genevalidatorapp/logger.rb,
lib/genevalidatorapp/routes.rb,
lib/genevalidatorapp/server.rb,
lib/genevalidatorapp/version.rb,
lib/genevalidatorapp/database.rb,
lib/genevalidatorapp/exceptions.rb,
lib/genevalidatorapp/genevalidator.rb
Overview
This file defines all possible exceptions that can be thrown by GeneValidatorApp 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: RunGeneValidator Classes: BIN_DIR_NOT_FOUND, BLAST_DATABASE_ERROR, BLAST_NOT_COMPATIBLE, BLAST_NOT_EXECUTABLE, BLAST_NOT_INSTALLED, CONFIG_FILE_ERROR, Config, DATABASE_DIR_NOT_FOUND, DATABASE_DIR_NOT_SET, Database, ENOENT, EXTENSION_FILE_NOT_FOUND, Logger, MAFFT_NOT_INSTALLED, NO_BLAST_DATABASE_FOUND, NO_PROTEIN_BLAST_DATABASE_FOUND, NUM_THREADS_INCORRECT, Routes, Server
Constant Summary collapse
- MINIMUM_BLAST_VERSION =
Use a fixed minimum version of BLAST+
'2.11.0+'.freeze
- VERSION =
'2.1.8'.freeze
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.
- .ssl? ⇒ Boolean
- .verbose? ⇒ Boolean
Class Attribute Details
.config ⇒ Object (readonly)
Returns the value of attribute config.
53 54 55 |
# File 'lib/genevalidatorapp.rb', line 53 def config @config end |
.public_dir ⇒ Object (readonly)
Returns the value of attribute public_dir.
53 54 55 |
# File 'lib/genevalidatorapp.rb', line 53 def public_dir @public_dir end |
.temp_dir ⇒ Object (readonly)
Returns the value of attribute temp_dir.
53 54 55 |
# File 'lib/genevalidatorapp.rb', line 53 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.
90 91 92 93 |
# File 'lib/genevalidatorapp.rb', line 90 def call(env) env['rack.logger'] = logger Routes.call(env) end |
.environment ⇒ Object
18 19 20 |
# File 'lib/genevalidatorapp.rb', line 18 def environment ENV['RACK_ENV'] end |
.init(config = {}) ⇒ Object
Setting up the environment before running the app…
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/genevalidatorapp.rb', line 39 def init(config = {}) @config = Config.new(config) init_binaries init_database init_dirs load_extension check_num_threads check_max_characters self end |
.logger ⇒ Object
34 35 36 |
# File 'lib/genevalidatorapp.rb', line 34 def logger @logger ||= Logger.new(STDERR, verbose?) end |
.on_start ⇒ Object
71 72 73 74 75 76 |
# File 'lib/genevalidatorapp.rb', line 71 def on_start puts '** GeneValidator 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
78 79 80 81 82 83 84 85 |
# File 'lib/genevalidatorapp.rb', line 78 def on_stop puts puts '** Thank you for using GeneValidator :).' puts ' Please cite: ' puts ' Dragan M, Moghul MI, Priyam A, Bustos C, Wurm Y. 2016.' puts ' GeneValidator: identify problems with protein-coding gene' puts ' predictions. Bioinformatics, doi: 10.1093/bioinformatics/btw015.' end |
.root ⇒ Object
26 27 28 |
# File 'lib/genevalidatorapp.rb', line 26 def root File.dirname(File.dirname(__FILE__)) end |
.run ⇒ Object
Starting the app manually
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/genevalidatorapp.rb', line 56 def run check_host Server.run(self) rescue Errno::EADDRINUSE puts "** Could not bind to port #{config[:port]}." puts " Is GeneValidator already accessible at #{server_url}?" puts ' No? Try running GeneValidator on another port, like so:' puts puts ' genevalidator app -p 4570.' rescue Errno::EACCES puts "** Need root privilege to bind to port #{config[:port]}." puts ' It is not advisable to run GeneValidator as root.' puts ' Please use Apache/Nginx to bind to a privileged port.' end |
.ssl? ⇒ Boolean
30 31 32 |
# File 'lib/genevalidatorapp.rb', line 30 def ssl? @config[:ssl] end |
.verbose? ⇒ Boolean
22 23 24 |
# File 'lib/genevalidatorapp.rb', line 22 def verbose? @verbose ||= (environment == 'development') end |