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
:nodoc: Attributes used by us - should be considered private.
-
#databases_ncharacters_total ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#method ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#num_threads ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#number_of_query_sequences ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#options ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#qfile ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
-
#query_length ⇒ Object
readonly
:nodoc: Attributes used by us - should be considered private.
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 36 37 |
# 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] @query = params[:sequence] @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 @number_of_query_sequences = calculate_number_of_sequences @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.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def advanced @advanced end |
#advanced_params ⇒ Object (readonly)
:nodoc: Deprecated; see Report#extract_params
53 54 55 |
# File 'lib/sequenceserver/blast/job.rb', line 53 def advanced_params @advanced_params end |
#databases ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def databases @databases end |
#databases_ncharacters_total ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def databases_ncharacters_total @databases_ncharacters_total end |
#method ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def method @method end |
#num_threads ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def num_threads @num_threads end |
#number_of_query_sequences ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def number_of_query_sequences @number_of_query_sequences end |
#options ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def @options end |
#qfile ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 def qfile @qfile end |
#query_length ⇒ Object (readonly)
:nodoc: Attributes used by us - should be considered private.
41 42 43 |
# File 'lib/sequenceserver/blast/job.rb', line 41 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
78 79 80 81 82 83 84 85 86 |
# File 'lib/sequenceserver/blast/job.rb', line 78 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.
64 65 66 67 |
# File 'lib/sequenceserver/blast/job.rb', line 64 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.
58 59 60 |
# File 'lib/sequenceserver/blast/job.rb', line 58 def imported_xml_file File.join(dir, @imported_xml_file) if @imported_xml_file end |
#raise! ⇒ Object
69 70 71 |
# File 'lib/sequenceserver/blast/job.rb', line 69 def raise! SequenceServer::BLAST::Error.new(exitstatus: exitstatus, stdout: stdout, stderr: stderr).raise! end |