Class: GeneValidator::Hsp
- Inherits:
-
Object
- Object
- GeneValidator::Hsp
- Extended by:
- Forwardable
- Defined in:
- lib/genevalidator/hsp.rb
Overview
A class that initialises the BLAST tabular attributes
Instance Attribute Summary collapse
-
#align_len ⇒ Object
Returns the value of attribute align_len.
-
#bit_score ⇒ Object
positive (mis)matches with +, mismatches and gaps are with space.
-
#gaps ⇒ Object
Returns the value of attribute gaps.
-
#hit_alignment ⇒ Object
Returns the value of attribute hit_alignment.
-
#hit_from ⇒ Object
ref.
-
#hit_to ⇒ Object
Returns the value of attribute hit_to.
-
#hsp_evalue ⇒ Object
Returns the value of attribute hsp_evalue.
-
#hsp_score ⇒ Object
Returns the value of attribute hsp_score.
-
#identity ⇒ Object
number of conserved residues.
-
#match_query_from ⇒ Object
ref.
-
#match_query_to ⇒ Object
Returns the value of attribute match_query_to.
-
#middles ⇒ Object
conserved residues are with letters,.
-
#pidentity ⇒ Object
percentage of identical matches.
-
#positive ⇒ Object
positive score for the (mis)match.
-
#query_alignment ⇒ Object
Returns the value of attribute query_alignment.
-
#query_reading_frame ⇒ Object
Returns the value of attribute query_reading_frame.
Instance Method Summary collapse
- #assert_seq_type(query) ⇒ Object
-
#init_tabular_attribute(hash) ⇒ Object
Initializes the corresponding attribute of the hsp with respect to the column name of the tabular blast output Params:
column
: String with column name. - #init_xml_attributes(hsp) ⇒ Object
-
#initialize(input = {}) ⇒ Hsp
constructor
A new instance of Hsp.
Constructor Details
#initialize(input = {}) ⇒ Hsp
Returns a new instance of Hsp.
31 32 33 34 35 36 |
# File 'lib/genevalidator/hsp.rb', line 31 def initialize(input = {}) @query_alignment = nil @hit_alignment = nil init_xml_attributes(input[:xml_input]) if input[:xml_input] init_tabular_attribute(input[:tabular_input]) if input[:tabular_input] end |
Instance Attribute Details
#align_len ⇒ Object
Returns the value of attribute align_len.
29 30 31 |
# File 'lib/genevalidator/hsp.rb', line 29 def align_len @align_len end |
#bit_score ⇒ Object
positive (mis)matches with +, mismatches and gaps are with space
22 23 24 |
# File 'lib/genevalidator/hsp.rb', line 22 def bit_score @bit_score end |
#gaps ⇒ Object
Returns the value of attribute gaps.
28 29 30 |
# File 'lib/genevalidator/hsp.rb', line 28 def gaps @gaps end |
#hit_alignment ⇒ Object
Returns the value of attribute hit_alignment.
17 18 19 |
# File 'lib/genevalidator/hsp.rb', line 17 def hit_alignment @hit_alignment end |
#hit_from ⇒ Object
ref. from the unaligned hit sequence
12 13 14 |
# File 'lib/genevalidator/hsp.rb', line 12 def hit_from @hit_from end |
#hit_to ⇒ Object
Returns the value of attribute hit_to.
13 14 15 |
# File 'lib/genevalidator/hsp.rb', line 13 def hit_to @hit_to end |
#hsp_evalue ⇒ Object
Returns the value of attribute hsp_evalue.
24 25 26 |
# File 'lib/genevalidator/hsp.rb', line 24 def hsp_evalue @hsp_evalue end |
#hsp_score ⇒ Object
Returns the value of attribute hsp_score.
23 24 25 |
# File 'lib/genevalidator/hsp.rb', line 23 def hsp_score @hsp_score end |
#identity ⇒ Object
number of conserved residues
25 26 27 |
# File 'lib/genevalidator/hsp.rb', line 25 def identity @identity end |
#match_query_from ⇒ Object
ref. from the unaligned query sequence
14 15 16 |
# File 'lib/genevalidator/hsp.rb', line 14 def match_query_from @match_query_from end |
#match_query_to ⇒ Object
Returns the value of attribute match_query_to.
15 16 17 |
# File 'lib/genevalidator/hsp.rb', line 15 def match_query_to @match_query_to end |
#middles ⇒ Object
conserved residues are with letters,
19 20 21 |
# File 'lib/genevalidator/hsp.rb', line 19 def middles @middles end |
#pidentity ⇒ Object
percentage of identical matches
26 27 28 |
# File 'lib/genevalidator/hsp.rb', line 26 def pidentity @pidentity end |
#positive ⇒ Object
positive score for the (mis)match
27 28 29 |
# File 'lib/genevalidator/hsp.rb', line 27 def positive @positive end |
#query_alignment ⇒ Object
Returns the value of attribute query_alignment.
18 19 20 |
# File 'lib/genevalidator/hsp.rb', line 18 def query_alignment @query_alignment end |
#query_reading_frame ⇒ Object
Returns the value of attribute query_reading_frame.
16 17 18 |
# File 'lib/genevalidator/hsp.rb', line 16 def query_reading_frame @query_reading_frame end |
Instance Method Details
#assert_seq_type(query) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/genevalidator/hsp.rb', line 79 def assert_seq_type(query) seq_type = BlastUtils.guess_sequence_type(query) raise SequenceTypeError if seq_type != :protein rescue SequenceTypeError => e warn e exit 1 end |
#init_tabular_attribute(hash) ⇒ Object
Initializes the corresponding attribute of the hsp with respect to the column name of the tabular blast output Params: column
: String with column name. value
: Value of the column
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/genevalidator/hsp.rb', line 63 def init_tabular_attribute(hash) @match_query_from = hash['qstart'].to_i if hash['qstart'] @match_query_to = hash['qend'].to_i if hash['qend'] @query_reading_frame = hash['qframe'].to_i if hash['qframe'] @hit_from = hash['sstart'].to_i if hash['sstart'] @hit_to = hash['send'].to_i if hash['send'] @query_alignment = hash['qseq'] if hash['qseq'] @hit_alignment = hash['sseq'] if hash['sseq'] @align_len = hash['length'].to_i if hash['length'] @pidentity = hash['pident'].to_f if hash['pident'] @identity = hash['nident'].to_f if hash['nident'] @hsp_evalue = hash['evalue'].to_f if hash['evalue'] assert_seq_type(@query_alignment) if hash['sseq'] assert_seq_type(@hit_alignment) if hash['sseq'] end |
#init_xml_attributes(hsp) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/genevalidator/hsp.rb', line 38 def init_xml_attributes(hsp) @match_query_from = hsp.query_from.to_i @match_query_to = hsp.query_to.to_i @query_reading_frame = hsp.query_frame.to_i @hit_from = hsp.hit_from.to_i @hit_to = hsp.hit_to.to_i @query_alignment = hsp.qseq.to_s @hit_alignment = hsp.hseq.to_s @align_len = hsp.align_len.to_i @pidentity = (100 * hsp.identity / hsp.align_len.to_f).round(2) @identity = hsp.identity.to_i @hsp_evalue = format('%.0e', hsp.evalue) assert_seq_type(@hit_alignment) if @hit_alignment assert_seq_type(@query_alignment) if @query_alignment return unless config[:type] == :nucleotide @match_query_from = (@match_query_from / 3) + 1 @match_query_to = (@match_query_to / 3) + 1 end |