Class: SequenceServer::BLAST::Job
- Defined in:
- lib/sequenceserver/blast/job.rb
Overview
Extends SequenceServer::Job to describe a BLAST job.
Instance Attribute Summary collapse
-
#advanced ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#advanced_params ⇒ Object
readonly
:nodoc: Deprecated; see Report#extract_params.
-
#databases ⇒ Object
readonly
Returns the value of attribute databases.
-
#databases_ncharacters_total ⇒ Object
readonly
Returns the value of attribute databases_ncharacters_total.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#num_threads ⇒ Object
readonly
Returns the value of attribute num_threads.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#qfile ⇒ Object
readonly
Returns the value of attribute qfile.
-
#query_length ⇒ Object
readonly
Returns the value of attribute query_length.
Attributes inherited from Job
#completed_at, #exitstatus, #id, #submitted_at
Instance Method Summary collapse
-
#as_archived_file(&block) ⇒ Object
Use it with a block to get a self-cleaning temporary archive file of the contents of the job directory.
-
#command ⇒ Object
Returns the command that will be executed.
-
#imported_xml_file ⇒ Object
:nodoc: Returns path to the imported xml file if the job was created using the –import switch.
-
#initialize(params) ⇒ Job
constructor
A new instance of Job.
- #raise! ⇒ Object
Methods inherited from Job
all, create, delete, #dir, #done?, enqueue, fetch, #run, serializable_classes, #stderr, #stdout
Constructor Details
#initialize(params) ⇒ Job
Returns a new instance of Job.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sequenceserver/blast/job.rb', line 10 def initialize(params) if params.key?(:xml) super do @imported_xml_file = File.basename params[:xml] # Copy over the XML file to job directory so that a job dir in # itself is self-contained. This will help with tests among # other things. FileUtils.cp(params[:xml], dir) @databases = [] done! end else validate params super do @method = params[:method] @qfile = store('query.fa', params[:sequence]) @databases = Database[params[:databases]] @advanced = params[:advanced].to_s.strip @options = @advanced + defaults # The following params are for analytics only @num_threads = config[:num_threads] @query_length = calculate_query_size @databases_ncharacters_total = calculate_databases_ncharacters_total end end end |
Instance Attribute Details
#advanced ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
39 40 41 |
# File 'lib/sequenceserver/blast/job.rb', line 39 def advanced @advanced end |
#advanced_params ⇒ Object (readonly)
:nodoc: Deprecated; see Report#extract_params
44 45 46 |
# File 'lib/sequenceserver/blast/job.rb', line 44 def advanced_params @advanced_params end |
#databases ⇒ Object (readonly)
Returns the value of attribute databases.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def databases @databases end |
#databases_ncharacters_total ⇒ Object (readonly)
Returns the value of attribute databases_ncharacters_total.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def databases_ncharacters_total @databases_ncharacters_total end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def method @method end |
#num_threads ⇒ Object (readonly)
Returns the value of attribute num_threads.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def num_threads @num_threads end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def @options end |
#qfile ⇒ Object (readonly)
Returns the value of attribute qfile.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def qfile @qfile end |
#query_length ⇒ Object (readonly)
Returns the value of attribute query_length.
40 41 42 |
# File 'lib/sequenceserver/blast/job.rb', line 40 def query_length @query_length end |
Instance Method Details
#as_archived_file(&block) ⇒ Object
Use it with a block to get a self-cleaning temporary archive file of the contents of the job directory. job.as_archived_file do |tmp_file|
# do things with tmp_file
end
69 70 71 72 73 74 75 76 77 |
# File 'lib/sequenceserver/blast/job.rb', line 69 def as_archived_file(&block) Dir.mktmpdir(id.to_s) do |tmp_dir| file_path = "#{tmp_dir}/#{id}.zip" ZipFileGenerator.new(dir, file_path).write File.open(file_path, 'r') do |file| block.call(file) end end end |
#command ⇒ Object
Returns the command that will be executed. Job super class takes care of actual execution.
55 56 57 58 |
# File 'lib/sequenceserver/blast/job.rb', line 55 def command @command ||= "#{method} -db '#{databases.map(&:name).join(' ')}'" \ " -query '#{qfile}' #{}" end |
#imported_xml_file ⇒ Object
:nodoc: Returns path to the imported xml file if the job was created using the –import switch. Returns nil otherwise.
49 50 51 |
# File 'lib/sequenceserver/blast/job.rb', line 49 def imported_xml_file File.join(dir, @imported_xml_file) if @imported_xml_file end |
#raise! ⇒ Object
60 61 62 |
# File 'lib/sequenceserver/blast/job.rb', line 60 def raise! SequenceServer::BLAST::Error.new(exitstatus: exitstatus, stdout: stdout, stderr: stderr).raise! end |