spec/dummy/quorum/lib/search_tools/blast.rb in quorum-0.3.1 vs spec/dummy/quorum/lib/search_tools/blast.rb in quorum-0.3.2
- old
+ new
@@ -11,13 +11,13 @@
class Blast
class QuorumJob < ActiveRecord::Base
self.table_name = "quorum_jobs"
- has_one :quorum_blastn_job,
+ has_one :quorum_blastn_job,
:foreign_key => "job_id"
- has_many :quorum_blastn_job_reports,
+ has_many :quorum_blastn_job_reports,
:foreign_key => "blastn_job_id"
has_one :quorum_blastx_job,
:foreign_key => "job_id"
has_many :quorum_blastx_job_reports,
@@ -215,11 +215,11 @@
@na_fasta = File.join(@tmp, @hash + ".na.fa")
@aa_fasta = File.join(@tmp, @hash + ".aa.fa")
File.open(@na_fasta, "w") { |f| f << @na_sequence }
File.open(@aa_fasta, "w") { |f| f << @aa_sequence }
- @out = File.join(@tmp, @hash + ".out.xml")
+ @out = File.join(@tmp, @hash + ".out.xml")
File.new(@out, "w")
case @algorithm
when "blastn"
@cmd << generate_blastn_cmd
@@ -231,22 +231,10 @@
@cmd << generate_blastp_cmd
end
end
#
- # Make the E-value look pretty.
- #
- def format_evalue(evalue)
- evalue = evalue.to_s
- e = evalue.slice!(/e.*/)
- unless e.nil?
- e = " x 10<sup>" << e.sub(/e/, '') << "</sup>"
- end
- evalue.to_f.round(1).to_s << e.to_s
- end
-
- #
# Format Blast report hit_display_id and hit_def.
#
# For added flexibility, Quorum doesn't parse seqids or deflines.
# Instead, format_hit splits the hit_def on whitespace and
# reports hit_display_id as the first element and hit_def as the second.
@@ -267,11 +255,11 @@
return hit_display_id, hit_def
end
#
# Parse and save Blast results using bio-blastxmlparser.
- # Only save Blast results if results.bit_score > @min_score.
+ # Only save Blast results if results.bit_score > @min_score.
#
def parse_and_save_results
# Helper to avoid having to perform a query.
saved = false
@@ -293,11 +281,11 @@
hit.each do |hsp|
@data[:hsp_num] = hsp.hsp_num
@data[:bit_score] = hsp.bit_score
@data[:score] = hsp.score
- @data[:evalue] = format_evalue(hsp.evalue)
+ @data[:evalue] = hsp.evalue
@data[:query_from] = hsp.query_from
@data[:query_to] = hsp.query_to
@data[:hit_from] = hsp.hit_from
@data[:hit_to] = hsp.hit_to
@data[:query_frame] = hsp.query_frame
@@ -309,11 +297,11 @@
@data[:hseq] = hsp.hseq
@data[:midline] = hsp.midline
# Hsps are only reported if a query hit against the Blast db.
# Only save the @data if bit_score exists.
- if @data[:bit_score] &&
+ if @data[:bit_score] &&
(@data[:bit_score].to_i > @min_score.to_i)
@data[:results] = true
@data["#{@algorithm}_job_id".to_sym] = @job.method(@job_association).call.job_id
saved = true
# Build a new report for each Hsp.
@@ -408,10 +396,10 @@
#
# Execute Blast on a given dataset.
#
def execute_blast
- generate_blast_cmd
+ generate_blast_cmd
@logger.log("NCBI Blast", @cmd)
system(@cmd)
parse_and_save_results
add_hps_groups_to_reports
remove_tmp_files