Class: BlastReadingFrameValidation
- Inherits:
-
ValidationTest
- Object
- ValidationTest
- BlastReadingFrameValidation
- Defined in:
- lib/genevalidator/validation_blast_reading_frame.rb
Overview
This class contains the methods necessary for reading frame validation based on BLAST output
Instance Attribute Summary
Attributes inherited from ValidationTest
#cli_name, #description, #header, #hits, #prediction, #running_time, #short_header, #type, #validation_report
Instance Method Summary (collapse)
-
- (BlastReadingFrameValidation) initialize(type, prediction, hits = nil)
constructor
A new instance of BlastReadingFrameValidation.
-
- (Object) run(lst = @hits)
Check reading frame inconsistency Params: lst: vector of Sequence objects Output: BlastRFValidationOutput object.
Constructor Details
- (BlastReadingFrameValidation) initialize(type, prediction, hits = nil)
Returns a new instance of BlastReadingFrameValidation
53 54 55 56 57 58 59 60 61 |
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 53 def initialize(type, prediction, hits = nil) super @short_header = "Frame" @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."<< " Meaning of the output displayed: (reading frame: no hsps)" @cli_name = "frame" end |
Instance Method Details
- (Object) run(lst = @hits)
Check reading frame inconsistency Params: lst: vector of Sequence objects Output: BlastRFValidationOutput object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 69 def run(lst = @hits) begin if type.to_s != "nucleotide" @validation_report = ValidationReport.new("", :unapplicable) return @validation_report end raise NotEnoughHitsError unless hits.length >= 5 raise Exception unless prediction.is_a? Sequence and hits[0].is_a? Sequence start = Time.now rfs = lst.map{ |x| x.hsp_list.map{ |y| y.query_reading_frame}}.flatten frames_histo = Hash[rfs.group_by { |x| x }.map { |k, vs| [k, vs.length] }] # get the main reading frame main_rf = frames_histo.map{|k,v| v}.max @prediction.nucleotide_rf = frames_histo.select{|k,v| v==main_rf}.first.first @validation_report = BlastRFValidationOutput.new(frames_histo) @running_time = Time.now - start return @validation_report # Exception is raised when blast founds no hits rescue NotEnoughHitsError => error @validation_report = ValidationReport.new("Not enough evidence", :warning) return @validation_report rescue Exception => error @validation_report = ValidationReport.new("Unexpected error", :error) return @validation_report end end |