Class: SequenceServer::Routes

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/sequenceserver/routes.rb

Overview

Controller.

Instance Method Summary collapse

Instance Method Details

#update_searchdata_from_job(searchdata) ⇒ Object

Get the query sequences, selected databases, and advanced params used.



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/sequenceserver/routes.rb', line 291

def update_searchdata_from_job(searchdata)
  job = fetch_job(params[:job_id])
  return { error: 'Job not found' }.to_json if job.nil?
  return if job.imported_xml_file

  # Only read job.qfile if we are not going to use Database.retrieve.
  searchdata[:query] = File.read(job.qfile) unless params[:query]

  # Which databases to pre-select.
  searchdata[:preSelectedDbs] = job.databases

  # job.advanced may be nil in case of old jobs. In this case, we do not
  # override searchdata so that default advanced parameters can be applied.
  # Note that, job.advanced will be an empty string if a user deletes the
  # default advanced parameters from the advanced params input field. In
  # this case, we do want the advanced params input field to be empty when
  # the user hits the back button. Thus we do not test for empty string.
  method = job.method.to_sym
  if job.advanced && job.advanced !=
                     searchdata[:options][method][:default].join(' ')
    searchdata[:options] = searchdata[:options].deep_copy
    searchdata[:options][method]['last search'] = [job.advanced]
  end
end