require 'scbi_fasta' require 'sequence' class MyWorkerManagerEst < ScbiMapreduce::WorkManager ############################################################################################# # MANAGER INITIALIZATION ############################################################################################# # open files and prepare global data def self.init_work_manager(putative_seqs, options, blast_path) @@blast_path = blast_path @@options = options @@putative_seqs = putative_seqs @@match = [] @@unmatch = [] @@num_seqs = 0 end ############################################################################################# # MANAGER TERMINATION ############################################################################################# # close files def self.end_work_manager #VOID end ############################################################################################# # MANAGER NATIVE FUNCTIONS ############################################################################################# # this method is called every time a worker needs new data to work. This method is executed many times like the chunk size says. # Return the work data or nil if no more data is available def next_work #Manage INput's worker if @@num_seqs == @@putative_seqs.length-1 return nil else seq = @@putative_seqs[@@num_seqs] @@num_seqs += 1 return seq end end # this method is ejecuted each time an obj is finished def work_received(match_and_unmatch_array) #Manage OUTput's worker @@match.concat(match_and_unmatch_array.first) @@unmatch.concat(match_and_unmatch_array.last) end def error_received(worker_error, obj) puts "Error while processing object #{obj.inspect}\n" + worker_error.original_exception.message + ":\n" +worker_error.original_exception.backtrace.join("\n") end def too_many_errors_received $LOG.error "Too many errors: #{@@error_count} errors on #{@@count} executed sequences, exiting before finishing" end # send initial config def worker_initial_config return [@@options, @@blast_path] end ############################################################################################# # CUSTOM FUNCTIONS ############################################################################################# def self.get_array_seqs return @@match, @@unmatch end end