$: << File.expand_path(File.join(File.dirname(__FILE__))) require 'scbi_mapreduce' require 'scbi_blast' require 'json' require 'sequence' require 'fl_string_utils' require "lcs" # like the class simliar of seqtrim, return the longest common sequence require "test_code" require 'fl_analysis' include FlAnalysis class MyWorker < ScbiMapreduce::Worker def starting_worker # $WORKER_LOG.info "Loading actions" rescue Exception => e puts (e.message+ e.backtrace.join("\n")) end def receive_initial_config(obj) # Reads the parameters # $WORKER_LOG.info "Params received: #{obj.to_json}" @options = obj end def process_object(obj) full_lenghter2(obj) return obj end def closing_worker end # ejecuta blastx utilizando los parametros fichero de entrada, base de datos y fichero de salida def run_blastx(input, database, user_db_name) # puts "\n#{user_db_name} ..... executing BLASTx" blast=BatchBlast.new("-db #{database}",'blastx',"-evalue 1e-6 -num_alignments 1 -num_descriptions 1") blast_result = blast.do_blast_seqs(input, :xml) # puts "#{user_db_name} ..... BLASTx finished" return blast_result end def full_lenghter2(seqs) # -------------------------------------------- User database # if the user has included his own database in the parameters entry, # the location of the database is tested, and blast and the results analysis is done if (@options[:user_db]) if (@options[:user_db] =~ /\//) user_db_name = @options[:user_db].sub(/.+\//,'') end if !File.exists?("#{@options[:user_db]}.psq") puts "user database: #{@options[:user_db]} was not found" exit end # do blast my_blast = run_blastx(seqs, "#{@options[:user_db]}", user_db_name) # split and parse blast seqs.each_with_index do |seq,i| analiza_orf_y_fl(seq, my_blast.querys[i], @options, user_db_name) end new_seqs=seqs.select{|s| s.get_annotations(:complete).empty?} else new_seqs = seqs end # -------------------------------------------- UniProt (sp) # blast my_blast = run_blastx(new_seqs, "sp_#{@options[:tax_group]}/sp_#{@options[:tax_group]}.fasta", "sp_#{@options[:tax_group]}") # split and parse blast new_seqs.each_with_index do |seq,i| analiza_orf_y_fl(seq, my_blast.querys[i], @options, "sp_#{@options[:tax_group]}") end new_seqs=seqs.select{|s| s.get_annotations(:complete).empty?} # -------------------------------------------- UniProt (tr) # blast my_blast = run_blastx(new_seqs, "tr_#{@options[:tax_group]}/tr_#{@options[:tax_group]}.fasta", "tr_#{@options[:tax_group]}") # split and parse blast new_seqs.each_with_index do |seq,i| analiza_orf_y_fl(seq, my_blast.querys[i], @options, "tr_#{@options[:tax_group]}") end # -------------------------------------------- Test Code # the sequences without a reliable similarity with an orthologue are processed with Test Code testcode_input=seqs.select{|s| !s.get_annotations(:tcode).empty?} # active this line to test tcode. hay que comentar todas las lineas de arriba de este metodo # testcode_input=seqs testcode_input.each do |seq| TestCode.new(seq) end end end