#$: << File.expand_path('~/fln/full_lengther_next/lib') $: << File.expand_path(File.join(File.dirname(__FILE__))) require 'types' require 'my_worker' class MyWorkerEst < MyWorker ##################################################################################### # WORKER FUNCTIONS ##################################################################################### def receive_initial_config(params) # Reads the parameters @options = params.first @blast_path = params.last @match = [] # Any sequence matching with a EST @unmatch = [] # Sequences with :test_code annotation that it hasn't match with a EST end def process_object (array_seqs) $WORKER_LOG.info "Worker LIST #{array_seqs.length}" array_seqs.sort!{|s1, s2| s2.t_code <=> s1.t_code} #Order by testcode blastEST(array_seqs) return [@match, @unmatch] end ##################################################################################### # CUSTOM FUNCTIONS ##################################################################################### def blastEST(array_seqs) blast = run_blast(array_seqs, @blast_path, 'blastn', 1e-6, nil, FALSE) if blast.nil? $LOG.info 'BLAST FAILED' Process.exit(-1) else blast_analysis(blast, array_seqs) end end def blast_analysis(blast, array_seqs) blast.querys.each_with_index do |query, i| if query.hits.first.nil? if !array_seqs[i].type == CODING #Keep if is coding @unmatch << array_seqs[i] end else seq = array_seqs[i] seq.hit = query.hits.first @match << seq end end end end