app/models/quorum/blastx_job.rb in quorum-0.5.2 vs app/models/quorum/blastx_job.rb in quorum-0.6.0
- old
+ new
@@ -1,26 +1,28 @@
module Quorum
class BlastxJob < ActiveRecord::Base
+ before_validation :check_blast_dbs, :if => :queue
+
before_save :set_optional_params, :set_blast_dbs
belongs_to :job
has_many :blastx_job_reports,
:dependent => :destroy,
:foreign_key => :blastx_job_id,
:primary_key => :job_id
- attr_accessible :expectation, :max_score, :min_bit_score,
+ attr_accessible :expectation, :max_target_seqs, :min_bit_score,
:filter, :gapped_alignments, :gap_opening_penalty,
:gap_extension_penalty, :gap_opening_extension, :queue,
:blast_dbs
validates_format_of :expectation,
:with => /^[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
:message => " - Valid formats (12, 32.05, 43e-123)",
:allow_blank => true
- validates_numericality_of :max_score,
+ validates_numericality_of :max_target_seqs,
:only_integer => true,
:allow_blank => true
validates_numericality_of :min_bit_score,
:only_integer => true,
:allow_blank => true
@@ -29,11 +31,10 @@
:allow_blank => true
validates_numericality_of :gap_extension_penalty,
:only_integer => true,
:allow_blank => true
validates_presence_of :blast_dbs, :if => :queue
- validate :gap_opening_extension_exists
#
# Gapped alignment helper.
#
def gapped_alignment?
@@ -77,35 +78,27 @@
self.gap_extension_penalty = v.last
end
private
- def set_blast_dbs
+ def check_blast_dbs
if self.blast_dbs.present?
- self.blast_dbs = self.blast_dbs.delete_if { |b| b.empty? }.join(';')
+ self.blast_dbs = self.blast_dbs.delete_if { |b| b.empty? }
end
end
- def set_optional_params
- self.expectation = "5e-20" if self.expectation.blank?
- self.max_score ||= 25
- self.min_bit_score ||= 0
- unless self.gapped_alignments
- self.gap_opening_penalty = 0
- self.gap_extension_penalty = 0
+ def set_blast_dbs
+ if self.blast_dbs.present?
+ self.blast_dbs = self.blast_dbs.join(';')
end
end
- #
- # Add error if gapped_alignment? without gap_opening_extension.
- #
- def gap_opening_extension_exists
- if gap_opening_extension.split(',').blank? && gapped_alignment?
- errors.add(
- :gap_opening_extension,
- " - Please select a value."
- )
- end
+ def set_optional_params
+ self.expectation = "5e-20" if self.expectation.blank?
+ self.max_target_seqs ||= 25
+ self.min_bit_score ||= 0
+ self.gap_opening_penalty ||= nil
+ self.gap_extension_penalty ||= nil
end
end
end