class GeneValidator::BlastReadingFrameValidation
This class contains the methods necessary for reading frame validation based on BLAST output
Public Class Methods
new(type, prediction, hits = nil)
click to toggle source
Calls superclass method
# File lib/genevalidator/validation_blast_reading_frame.rb, line 86 def initialize(type, prediction, hits = nil) super @short_header = 'ReadingFrame' @header = 'Reading Frame' @description = 'Check whether there is a single reading frame among' \ ' BLAST hits. Otherwise there might be a reading frame' \ ' shift in the query sequence.' @cli_name = 'frame' end
Public Instance Methods
run(lst = @hits)
click to toggle source
Check reading frame inconsistency Params: lst
: vector of Sequence
objects Output: BlastRFValidationOutput
object
# File lib/genevalidator/validation_blast_reading_frame.rb, line 102 def run(lst = @hits) if type.to_s != 'nucleotide' @validation_report = ValidationReport.new('', :unapplicable) return @validation_report end raise NotEnoughHitsError if hits.length < opt[:min_blast_hits] raise unless prediction.is_a?(Query) && hits[0].is_a?(Query) start = Time.now rfs = lst.map { |x| x.hsp_list.map(&:query_reading_frame) }.flatten frames = Hash[rfs.group_by { |x| x }.map { |k, vs| [k, vs.length] }] # get the main reading frame main_rf = frames.map { |_k, v| v }.max @prediction.nucleotide_rf = frames.find { |_k, v| v == main_rf }.first @validation_report = BlastRFValidationOutput.new(@short_header, @header, @description, frames) @validation_report.run_time = Time.now - start @validation_report rescue NotEnoughHitsError @validation_report = ValidationReport.new('Not enough evidence', :warning, @short_header, @header, @description) rescue StandardError @validation_report = ValidationReport.new('Unexpected error', :error, @short_header, @header, @description) @validation_report.errors.push 'Unexpected Error' end