Class: Quorum::JobsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/quorum/jobs_controller.rb

Instance Method Summary collapse

Methods included from Sequence::SendSequence

#has_error?, #render_empty, #render_error, #sequence

Methods included from Helpers

#set_flash_message

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/quorum/jobs_controller.rb', line 15

def create
  read_sequence_file
  @job = Job.new(params[:job])
  set_sequence

  unless @job.save
    build_blast_jobs
    render :action => "new"
    return
  end
  redirect_to job_path(@job.id)
end

#get_blast_hit_sequenceObject

Find hit sequence and return worker meta_id for lookup. If the method returns [], try again.



64
65
66
67
68
# File 'app/controllers/quorum/jobs_controller.rb', line 64

def get_blast_hit_sequence
  fetch_data = Job.set_blast_hit_sequence_lookup_values(params)
  data       = Quorum::JobQueueService.queue_fetch_worker(fetch_data)
  respond_with data || []
end

#indexObject



7
8
9
# File 'app/controllers/quorum/jobs_controller.rb', line 7

def index
  redirect_to :action => "new"
end

#newObject



11
12
13
# File 'app/controllers/quorum/jobs_controller.rb', line 11

def new
  build_blast_jobs
end

#searchObject

Returns Quorum’s search results.

This method should be used to gather Resque worker results, or user supplied query params.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/quorum/jobs_controller.rb', line 43

def search
  data = Job.search(params)

  # Respond with :json, :txt (tab delimited Blast results), or GFF3.
  respond_with data.flatten!(1) do |format|
    format.json {
      render :json => Quorum::JobSerializer.as_json(data)
    }
    format.gff {
      render :text => Quorum::JobSerializer.as_gff(data)
    }
    format.txt {
      render :text => Quorum::JobSerializer.as_txt(data)
    }
  end
end

#send_blast_hit_sequenceObject

Send Blast hit sequence as attached file or render error message as text.

See lib/generators/templates/blast_db.rb for more info.



76
77
78
79
# File 'app/controllers/quorum/jobs_controller.rb', line 76

def send_blast_hit_sequence
  data = Workers::System.get_meta(params[:meta_id])
  sequence(data)
end

#showObject



28
29
30
31
32
33
34
35
# File 'app/controllers/quorum/jobs_controller.rb', line 28

def show
  begin
    @jobs = Job.find(params[:id])
  rescue ActiveRecord::RecordNotFound => e
    set_flash_message(:notice, :data_not_found)
    redirect_to :action => "new"
  end
end