Class: ScbiDblastManager
- Inherits:
-
ScbiMapreduce::WorkManager
- Object
- ScbiMapreduce::WorkManager
- ScbiDblastManager
- Defined in:
- lib/scbi_distributed_blast/scbi_dblast_manager.rb
Overview
MyWorkerManager class is used to implement the methods to send and receive the data to or from workers
Class Method Summary collapse
-
.end_work_manager ⇒ Object
end_work_manager is executed at the end, when all the process is done.
-
.init_work_manager(input_file, blast_cmd, output_file) ⇒ Object
init_work_manager is executed at the start, prior to any processing.
Instance Method Summary collapse
-
#next_work ⇒ Object
next_work method is called every time a worker needs a new work Here you can read data from disk This method must return the work data or nil if no more data is available.
-
#work_received(results) ⇒ Object
work_received is executed each time a worker has finished a job.
-
#worker_initial_config ⇒ Object
worker_initial_config is used to send initial parameters to workers.
Class Method Details
.end_work_manager ⇒ Object
end_work_manager is executed at the end, when all the process is done. You can use it to close files opened in init_work_manager
32 33 34 35 36 |
# File 'lib/scbi_distributed_blast/scbi_dblast_manager.rb', line 32 def self.end_work_manager # close opened files @@fqr.close @@output_file.close if @@output_file!=STDOUT end |
.init_work_manager(input_file, blast_cmd, output_file) ⇒ Object
init_work_manager is executed at the start, prior to any processing. You can use init_work_manager to initialize global variables, open files, etc… Note that an instance of MyWorkerManager will be created for each worker connection, and thus, all global variables here should be class variables (starting with @@)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/scbi_distributed_blast/scbi_dblast_manager.rb', line 14 def self.init_work_manager(input_file, blast_cmd, output_file) # save blast_cmd @@blast_cmd=blast_cmd # define output file if output_file.nil? @@output_file=STDOUT else @@output_file=File.open(output_file,'w') end # open input file in fasta @@fqr = FastaQualFile.new(input_file) end |
Instance Method Details
#next_work ⇒ Object
next_work method is called every time a worker needs a new work Here you can read data from disk This method must return the work data or nil if no more data is available
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/scbi_distributed_blast/scbi_dblast_manager.rb', line 48 def next_work # read next sequence from inputfile n,f = @@fqr.next_seq if n.nil? return nil else return [n,f] end end |
#work_received(results) ⇒ Object
work_received is executed each time a worker has finished a job. Here you can write results down to disk, perform some aggregated statistics, etc…
64 65 66 67 |
# File 'lib/scbi_distributed_blast/scbi_dblast_manager.rb', line 64 def work_received(results) # write results to disk @@output_file.puts results end |
#worker_initial_config ⇒ Object
worker_initial_config is used to send initial parameters to workers. The method is executed once per each worker
40 41 42 43 |
# File 'lib/scbi_distributed_blast/scbi_dblast_manager.rb', line 40 def worker_initial_config # send blast_cmd to workers {:blast_cmd=>@@blast_cmd} end |