Class: Quorum::Job

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Sequence
Defined in:
app/models/quorum/job.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sequence

#create_hash, #discover_input_sequence_type, #write_input_sequence_to_file

Class Method Details

.delete_jobs(time = 1.week) ⇒ Object

Delete submitted jobs.



69
70
71
72
73
74
75
# File 'app/models/quorum/job.rb', line 69

def self.delete_jobs(time = 1.week)
  if time.is_a?(String)
    time = time.split.inject { |count, unit| count.to_i.send(unit) }
  end

  self.where("created_at < '#{time.ago.to_s(:db)}'").destroy_all
end

Instance Method Details

#fetch_quorum_blast_sequence(algo, algo_id) ⇒ Object

Fetch Blast hit_id, hit_display_id, queue Resque worker and return worker’s meta_id.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/models/quorum/job.rb', line 40

def fetch_quorum_blast_sequence(algo, algo_id)
  job         = "#{algo}_job".to_sym
  job_reports = "#{algo}_job_reports".to_sym

  blast_dbs = self.method(job).call.blast_dbs

  job_report = self.method(job_reports).call.where(
    "quorum_#{algo}_job_reports.id = ?", algo_id
  ).first

  hit_id          = job_report.hit_id
  hit_display_id  = job_report.hit_display_id

  cmd = Workers::System.create_blast_fetch_command(
    blast_dbs, hit_id, hit_display_id, algo
  )

  data = Workers::System.enqueue(
    cmd, Quorum.blast_remote,
    Quorum.blast_ssh_host, Quorum.blast_ssh_user,
    Quorum.blast_ssh_options, true
  )

  Workers::System.get_meta(data.meta_id)
end