Module: SequenceServer

Defined in:
lib/sequenceserver.rb,
lib/sequenceserver/links.rb,
lib/sequenceserver/blast.rb,
lib/sequenceserver/logger.rb,
lib/sequenceserver/config.rb,
lib/sequenceserver/search.rb,
lib/sequenceserver/routes.rb,
lib/sequenceserver/database.rb,
lib/sequenceserver/sequence.rb,
lib/sequenceserver/blast/hit.rb,
lib/sequenceserver/blast/hsp.rb,
lib/sequenceserver/exceptions.rb,
lib/sequenceserver/blast/query.rb,
lib/sequenceserver/blast/report.rb,
lib/sequenceserver/blast/constants.rb,
lib/sequenceserver/blast/formatter.rb,
lib/sequenceserver/blast/exceptions.rb

Overview

This file defines all possible exceptions that can be thrown by SequenceServer 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/sequenceserver or config.ru) to act on them.

Defined Under Namespace

Modules: BLAST, Links, Search Classes: BIN_DIR_NOT_FOUND, BLAST_DATABASE_ERROR, BLAST_NOT_COMPATIBLE, 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, NUM_THREADS_INCORRECT, Routes, Sequence

Constant Summary

MINIMUM_BLAST_VERSION =

Use a fixed minimum version of BLAST+

'2.2.30+'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config



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

def config
  @config
end

Class Method Details

.call(env) ⇒ Object

Rack-interface.

Inject our logger in the env and dispatch request to our controller.



89
90
91
92
# File 'lib/sequenceserver.rb', line 89

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

.environmentObject



19
20
21
# File 'lib/sequenceserver.rb', line 19

def environment
  ENV['RACK_ENV']
end

.init(config = {}) ⇒ Object



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

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

  init_binaries
  init_database
  load_extension
  check_num_threads
  self

  # We don't validate port and host settings. If SequenceServer is run
  # self-hosted, bind will fail on incorrect values. If SequenceServer
  # is run via Apache+Passenger, we don't need to worry.
end

.irbObject

Run SequenceServer interactively.



95
96
97
98
99
100
101
102
# File 'lib/sequenceserver.rb', line 95

def irb
  ARGV.clear
  require 'irb'
  IRB.setup nil
  IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
  require 'irb/ext/multi-irb'
  IRB.irb nil, self
end

.loggerObject



31
32
33
# File 'lib/sequenceserver.rb', line 31

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

.rootObject



27
28
29
# File 'lib/sequenceserver.rb', line 27

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

.runObject

Run SequenceServer as a self-hosted server using Thin webserver.



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
# File 'lib/sequenceserver.rb', line 52

def run
  check_host
  url = "http://#{config[:host]}:#{config[:port]}"
  server = Thin::Server.new(config[:host],
                            config[:port],
                            :signals => false) do
    use Rack::CommonLogger
    run SequenceServer
  end
  server.silent = true
  server.backend.start do
    puts '** SequenceServer is ready.'
    puts "   Go to #{url} in your browser and start BLASTing!"
    puts '   Press CTRL+C to quit.'
    [:INT, :TERM].each do |sig|
      trap sig do
        server.stop!
        puts
        puts '** Thank you for using SequenceServer :).'
        puts '   Please cite: '
        puts '             Priyam, Woodcroft, Rai & Wurm,'
        puts '             SequenceServer (in prep).'
      end
    end
  end
rescue
  puts '** Oops! There was an error.'
  puts "   Is SequenceServer already accessible at #{url}?"
  puts '   Try running SequenceServer on another port, like so:'
  puts
  puts '       sequenceserver -p 4570.'
end

.verbose?Boolean

Returns:

  • (Boolean)


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

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