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, 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.2.30+'
VERSION =
'2.0.1'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



49
50
51
# File 'lib/genevalidatorapp.rb', line 49

def config
  @config
end

.public_dirObject (readonly)

Returns the value of attribute public_dir.



49
50
51
# File 'lib/genevalidatorapp.rb', line 49

def public_dir
  @public_dir
end

.temp_dirObject (readonly)

Returns the value of attribute temp_dir.



49
50
51
# File 'lib/genevalidatorapp.rb', line 49

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.



86
87
88
89
# File 'lib/genevalidatorapp.rb', line 86

def call(env)
  env['rack.logger'] = logger
  Routes.call(env)
end

.environmentObject



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…



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/genevalidatorapp.rb', line 35

def init(config = {})
  @config = Config.new(config)

  init_binaries
  init_database

  init_dirs

  load_extension
  check_num_threads
  check_max_characters
  self
end

.loggerObject



30
31
32
# File 'lib/genevalidatorapp.rb', line 30

def logger
  @logger ||= Logger.new(STDERR, verbose?)
end

.on_startObject



67
68
69
70
71
72
# File 'lib/genevalidatorapp.rb', line 67

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_stopObject



74
75
76
77
78
79
80
81
# File 'lib/genevalidatorapp.rb', line 74

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

.rootObject



26
27
28
# File 'lib/genevalidatorapp.rb', line 26

def root
  File.dirname(File.dirname(__FILE__))
end

.runObject

Starting the app manually



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/genevalidatorapp.rb', line 52

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

.verbose?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/genevalidatorapp.rb', line 22

def verbose?
  @verbose ||= (environment == 'development')
end