Class: GeneValidator::BlastReadingFrameValidation
- Inherits:
-
ValidationTest
- Object
- ValidationTest
- GeneValidator::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, #run_time, #short_header, #type, #validation_report
Instance Method Summary collapse
-
#initialize(type, prediction, hits = nil) ⇒ BlastReadingFrameValidation
constructor
A new instance of BlastReadingFrameValidation.
-
#run(lst = @hits) ⇒ Object
Check reading frame inconsistency Params:
lst: vector ofSequenceobjects Output:BlastRFValidationOutputobject.
Constructor Details
#initialize(type, prediction, hits = nil) ⇒ BlastReadingFrameValidation
81 82 83 84 85 86 87 88 89 |
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 81 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 |
Instance Method Details
#run(lst = @hits) ⇒ Object
Check reading frame inconsistency Params: lst: vector of Sequence objects Output: BlastRFValidationOutput object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/genevalidator/validation_blast_reading_frame.rb', line 97 def run(lst = @hits) if type.to_s != 'nucleotide' @validation_report = ValidationReport.new('', :unapplicable) return @validation_report end fail NotEnoughHitsError unless hits.length >= 5 fail Exception unless prediction.is_a?(Sequence) && hits[0].is_a?(Sequence) 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.select { |_k, v| v == main_rf }.first.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 Exception @validation_report = ValidationReport.new('Unexpected error', :error, @short_header, @header, @description) @validation_report.errors.push 'Unexpected Error' end |