genevalidatorapp 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6df67db57034d12544ba8d833539ba3b193322b307f394b4e22f1110daa1a2da
4
- data.tar.gz: cc26578078bddb08c9eec2dcfbf4bf52688a25871f6e7e02c1ba83068a23ede3
3
+ metadata.gz: 5fef79353732230b2ca0f21f183b6232a27761422b7126577a553f11278518c7
4
+ data.tar.gz: 25795b4b7865762e8dc408b030748cd9584205d9ad00958e8d51d4908e50acfb
5
5
  SHA512:
6
- metadata.gz: d51a7e34edcbd1898ecc04aea4768d6b3a7376a2c032e373010474d3e3d79a8bf90138aa6d52b1b6478e651a4b0abf6cc57ec0ba8133d983b22c4e9faeb778b2
7
- data.tar.gz: 8ac6ca88671374c76e57ab9e0b72318f1c42d45ce4bcb324b5be61dbeb5a70bc3d33a921a86eb3e8aa38b5e8d1b1182bc6937041ed6e9b91c13d75054b5702d6
6
+ metadata.gz: 207b14ef281b2cd86e24b085cbb34754b75175838df0032a8375ac4d19173f6391d075915fc1f2b3676de4f33db75b676dff1cb586f310ddeb88b37a0ef8f57b
7
+ data.tar.gz: bd172c9069bea91010bad2c0d2c611e2707678767b857a6cc68ada1353180db712b14e5695a5c7036dbfad94d193971b7faf94d5140a14db35f2444d73f921c6
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rake/testtask'
2
- GEMSPEC = Gem::Specification::load('genevalidatorapp.gemspec')
2
+ GEMSPEC = Gem::Specification.load('genevalidatorapp.gemspec')
3
3
 
4
4
  task default: [:build]
5
5
 
@@ -1,5 +1,4 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'genevalidatorapp/version'
5
4
 
@@ -61,7 +61,7 @@ module GeneValidatorApp
61
61
 
62
62
  logger.debug "Reading configuration file: #{config_file}."
63
63
  symbolise YAML.load_file(config_file)
64
- rescue => error
64
+ rescue StandardError => error
65
65
  raise CONFIG_FILE_ERROR.new(config_file, error)
66
66
  end
67
67
 
@@ -72,12 +72,13 @@ module GeneValidatorApp
72
72
  # Default configuration data.
73
73
  def defaults
74
74
  {
75
- :num_threads => 1,
76
- :mafft_threads => 1,
77
- :port => 5678,
78
- :host => '0.0.0.0',
79
- :gv_public_dir => File.join(Dir.home, '.genevalidatorapp/'),
80
- :max_characters => 'undefined'
75
+ num_threads: 1,
76
+ mafft_threads: 1,
77
+ port: 5678,
78
+ ssl: false,
79
+ host: '0.0.0.0',
80
+ gv_public_dir: File.join(Dir.home, '.genevalidatorapp/'),
81
+ max_characters: 'undefined'
81
82
  }
82
83
  end
83
84
 
@@ -103,7 +103,7 @@ MSG
103
103
  # system but not meeting SequenceServer's minimum version requirement.
104
104
  class BLAST_NOT_COMPATIBLE < StandardError
105
105
  def initialize(version)
106
- @version = version
106
+ @version = version
107
107
  end
108
108
 
109
109
  attr_reader :version
@@ -211,7 +211,7 @@ module GeneValidatorApp
211
211
 
212
212
  def parse_output_json
213
213
  json_contents = File.read(output_json_file_path)
214
- JSON.parse(json_contents,symbolize_names: true)
214
+ JSON.parse(json_contents, symbolize_names: true)
215
215
  end
216
216
 
217
217
  def output_json_file_path
@@ -10,14 +10,14 @@ module GeneValidatorApp
10
10
 
11
11
  # We change Logging format so that it is consistent with Sinatra's
12
12
  class Formatter < Formatter
13
- Format = "[%s] %s %s\n"
13
+ Format = "[%s] %s %s\n".freeze
14
14
 
15
15
  def initialize
16
16
  self.datetime_format = '%Y-%m-%d %H:%M:%S'
17
17
  end
18
18
 
19
19
  def call(severity, time, _progname, msg)
20
- Format % [format_datetime(time), severity, msg2str(msg)]
20
+ format(Format, format_datetime(time), severity, msg2str(msg))
21
21
  end
22
22
  end
23
23
  end
@@ -36,6 +36,48 @@ module GeneValidatorApp
36
36
  set :public_folder, -> { GeneValidatorApp.public_dir }
37
37
  end
38
38
 
39
+ helpers do
40
+ # Overide default URI helper method - to hardcode a https://
41
+ # In our setup, we are running passenger on http:// (not secure) and then
42
+ # reverse proxying that onto a 443 port (i.e. https://)
43
+ # Generates the absolute URI for a given path in the app.
44
+ # Takes Rack routers and reverse proxies into account.
45
+ def uri(addr = nil, absolute = true, add_script_name = true)
46
+ return addr if addr =~ /\A[a-z][a-z0-9\+\.\-]*:/i
47
+ uri = [host = '']
48
+ if absolute
49
+ host << (GeneValidatorApp.ssl? ? 'https://' : 'http://')
50
+ host << if request.forwarded? || request.port != (request.secure? ? 443 : 80)
51
+ request.host_with_port
52
+ else
53
+ request.host
54
+ end
55
+ end
56
+ uri << request.script_name.to_s if add_script_name
57
+ uri << (addr || request.path_info).to_s
58
+ File.join uri
59
+ end
60
+
61
+ def host_with_port
62
+ forwarded = request.env['HTTP_X_FORWARDED_HOST']
63
+ if forwarded
64
+ forwarded.split(/,\s?/).last
65
+ else
66
+ request.env['HTTP_HOST'] || "#{request.env['SERVER_NAME'] ||
67
+ request.env['SERVER_ADDR']}:#{request.env['SERVER_PORT']}"
68
+ end
69
+ end
70
+
71
+ # Remove port number.
72
+ def host
73
+ host_with_port.to_s.sub(/:\d+\z/, '')
74
+ end
75
+
76
+ def base_url
77
+ @base_url ||= "#{GeneValidatorApp.ssl? ? 'https' : 'http'}://#{host}"
78
+ end
79
+ end
80
+
39
81
  # Set up global variables for the templates...
40
82
  before '/' do
41
83
  @default_db = Database.default_db
@@ -35,13 +35,13 @@ module GeneValidatorApp
35
35
  # rubocop:disable Metrics/AbcSize
36
36
  def options
37
37
  @options ||= {
38
- :BindAddress => app.config[:host],
39
- :Port => app.config[:port],
40
- :StartCallback => proc { app.on_start },
41
- :StopCallback => proc { app.on_stop },
42
- :OutputBufferSize => 5,
43
- :AccessLog => [[logdev, WEBrick::AccessLog::COMMON_LOG_FORMAT]],
44
- :Logger => WEBrick::Log.new(logdev)
38
+ BindAddress: app.config[:host],
39
+ Port: app.config[:port],
40
+ StartCallback: proc { app.on_start },
41
+ StopCallback: proc { app.on_stop },
42
+ OutputBufferSize: 5,
43
+ AccessLog: [[logdev, WEBrick::AccessLog::COMMON_LOG_FORMAT]],
44
+ Logger: WEBrick::Log.new(logdev)
45
45
  }
46
46
  end
47
47
  # rubocop:enable Metrics/AbcSize
@@ -1,3 +1,3 @@
1
1
  module GeneValidatorApp
2
- VERSION = '2.1.1'
2
+ VERSION = '2.1.2'.freeze
3
3
  end
@@ -12,7 +12,7 @@ require 'genevalidatorapp/version'
12
12
 
13
13
  module GeneValidatorApp
14
14
  # Use a fixed minimum version of BLAST+
15
- MINIMUM_BLAST_VERSION = '2.2.30+'
15
+ MINIMUM_BLAST_VERSION = '2.2.30+'.freeze
16
16
 
17
17
  class << self
18
18
  def environment
@@ -27,6 +27,10 @@ module GeneValidatorApp
27
27
  File.dirname(File.dirname(__FILE__))
28
28
  end
29
29
 
30
+ def ssl?
31
+ @config[:ssl]
32
+ end
33
+
30
34
  def logger
31
35
  @logger ||= Logger.new(STDERR, verbose?)
32
36
  end
@@ -92,7 +96,7 @@ module GeneValidatorApp
92
96
 
93
97
  def init_dirs
94
98
  config[:gv_public_dir] = File.expand_path(config[:gv_public_dir])
95
- unique_start_id = 'GV_' + "#{Time.now.strftime('%Y%m%d-%H-%M-%S')}"
99
+ unique_start_id = 'GV_' + Time.now.strftime('%Y%m%d-%H-%M-%S').to_s
96
100
  @public_dir = File.join(config[:gv_public_dir], unique_start_id)
97
101
  init_public_dir
98
102
  end
@@ -114,12 +118,12 @@ module GeneValidatorApp
114
118
  end
115
119
 
116
120
  def init_database
117
- fail DATABASE_DIR_NOT_SET unless config[:database_dir]
121
+ raise DATABASE_DIR_NOT_SET unless config[:database_dir]
118
122
 
119
123
  config[:database_dir] = File.expand_path(config[:database_dir])
120
124
  unless File.exist?(config[:database_dir]) &&
121
125
  File.directory?(config[:database_dir])
122
- fail DATABASE_DIR_NOT_FOUND, config[:database_dir]
126
+ raise DATABASE_DIR_NOT_FOUND, config[:database_dir]
123
127
  end
124
128
 
125
129
  assert_blast_databases_present_in_database_dir
@@ -136,7 +140,7 @@ module GeneValidatorApp
136
140
  return unless config[:require]
137
141
  config[:require] = File.expand_path config[:require]
138
142
  unless File.exist?(config[:require]) && File.file?(config[:require])
139
- fail EXTENSION_FILE_NOT_FOUND, config[:require]
143
+ raise EXTENSION_FILE_NOT_FOUND, config[:require]
140
144
  end
141
145
 
142
146
  logger.debug("Loading extension: #{config[:require]}")
@@ -147,24 +151,24 @@ module GeneValidatorApp
147
151
  cmd = "blastdbcmd -recursive -list '#{config[:database_dir]}'"
148
152
  out = `#{cmd}`
149
153
  errpat = /BLAST Database error/
150
- fail NO_BLAST_DATABASE_FOUND, config[:database_dir] if out.empty?
151
- fail BLAST_DATABASE_ERROR, cmd, out if out.match(errpat) ||
152
- !$CHILD_STATUS.success?
154
+ raise NO_BLAST_DATABASE_FOUND, config[:database_dir] if out.empty?
155
+ raise BLAST_DATABASE_ERROR, cmd, out if out.match(errpat) ||
156
+ !$CHILD_STATUS.success?
153
157
  type = []
154
158
  out.lines.each { |l| type << l.split[1] }
155
159
  return if type.include? 'Protein'
156
- fail NO_PROTEIN_BLAST_DATABASE_FOUND, config[:database_dir]
160
+ raise NO_PROTEIN_BLAST_DATABASE_FOUND, config[:database_dir]
157
161
  end
158
162
 
159
163
  def check_num_threads
160
164
  num_threads = Integer(config[:num_threads])
161
- fail NUM_THREADS_INCORRECT unless num_threads > 0
165
+ raise NUM_THREADS_INCORRECT unless num_threads > 0
162
166
 
163
167
  logger.debug "Will use #{num_threads} threads to run BLAST."
164
168
  if num_threads > 256
165
169
  logger.warn "Number of threads set at #{num_threads} is unusually high."
166
170
  end
167
- rescue
171
+ rescue StandardError
168
172
  raise NUM_THREADS_INCORRECT
169
173
  end
170
174
 
@@ -172,7 +176,7 @@ module GeneValidatorApp
172
176
  if config[:max_characters] != 'undefined'
173
177
  config[:max_characters] = Integer(config[:max_characters])
174
178
  end
175
- rescue
179
+ rescue StandardError
176
180
  raise MAX_CHARACTERS_INCORRECT
177
181
  end
178
182
 
@@ -181,7 +185,7 @@ module GeneValidatorApp
181
185
  Array(config[:bin]).each do |bin|
182
186
  bins << File.expand_path(bin)
183
187
  unless File.exist?(bin) && File.directory?(bin)
184
- fail BIN_DIR_NOT_FOUND, config[:bin]
188
+ raise BIN_DIR_NOT_FOUND, config[:bin]
185
189
  end
186
190
  export_bin_dir(bin)
187
191
  end
@@ -196,13 +200,13 @@ module GeneValidatorApp
196
200
  end
197
201
 
198
202
  def assert_blast_installed_and_compatible
199
- fail BLAST_NOT_INSTALLED unless command? 'blastdbcmd'
203
+ raise BLAST_NOT_INSTALLED unless command? 'blastdbcmd'
200
204
  version = `blastdbcmd -version`.split[1]
201
- fail BLAST_NOT_COMPATIBLE, version unless version >= MINIMUM_BLAST_VERSION
205
+ raise BLAST_NOT_COMPATIBLE, version unless version >= MINIMUM_BLAST_VERSION
202
206
  end
203
207
 
204
208
  def assert_mafft_installed
205
- fail MAFFT_NOT_INSTALLED unless command? 'mafft'
209
+ raise MAFFT_NOT_INSTALLED unless command? 'mafft'
206
210
  end
207
211
 
208
212
  # Check and warn user if host is 0.0.0.0 (default).
@@ -66,14 +66,14 @@ module GeneValidatorApp
66
66
 
67
67
  # W3C_Validator Gem is broken - https://github.com/alexdunae/w3c_validators/issues/16
68
68
  # it 'validate the html' do
69
- # get '/'
70
- # html = last_response.body
69
+ # get '/'
70
+ # html = last_response.body
71
71
 
72
- # validator = MarkupValidator.new
73
- # results = validator.validate_text(html.to_s)
74
- # results.errors.each { |err| puts err.to_s } if results.errors.length > 0
75
- # puts results.errors
76
- # results.errors.length.should == 0
72
+ # validator = MarkupValidator.new
73
+ # results = validator.validate_text(html.to_s)
74
+ # results.errors.each { |err| puts err.to_s } if results.errors.length > 0
75
+ # puts results.errors
76
+ # results.errors.length.should == 0
77
77
  # end
78
78
  end
79
79
  end
data/views/layout.slim CHANGED
@@ -54,7 +54,7 @@ html lang="en"
54
54
  footer#footer
55
55
  p.text-muted.text-center
56
56
  | Please cite:
57
- <a href="http://doi.org/10.1093/bioinformatics/btw015">Dragan M<sup>&Dagger;</sup>, Moghul MI<sup>&Dagger;</sup>, Priyam A, Bustos C &amp; Wurm Y. 2016. GeneValidator: identify problematic gene predictions.
57
+ <a href="https://academic.oup.com/bioinformatics/article/32/10/1559/1742817">Dragan M<sup>&Dagger;</sup>, Moghul I<sup>&Dagger;</sup>, Priyam A, Bustos C &amp; Wurm Y. 2016. GeneValidator: identify problematic gene predictions.
58
58
  <em>Bioinformatics</em>, doi: 10.1093/bioinformatics/btw015</a>.
59
59
  br
60
60
  | Developed at
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genevalidatorapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Monica Dragan
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-08-14 00:00:00.000000000 Z
14
+ date: 2018-08-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: capybara