Class: BlastHit
- Inherits:
-
Object
- Object
- BlastHit
- Defined in:
- lib/scbi_blast/blast_hit.rb
Overview
Class for a Blast Hit (a concordance between a query and a subject)
Instance Attribute Summary collapse
-
#acc ⇒ Object
Returns the value of attribute acc.
-
#align_len ⇒ Object
Returns the value of attribute align_len.
-
#bit_score ⇒ Object
Returns the value of attribute bit_score.
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#e_val ⇒ Object
Returns the value of attribute e_val.
-
#full_subject_length ⇒ Object
Returns the value of attribute full_subject_length.
-
#gaps ⇒ Object
Returns the value of attribute gaps.
-
#ident ⇒ Object
Returns the value of attribute ident.
-
#mismatches ⇒ Object
Returns the value of attribute mismatches.
-
#q_beg ⇒ Object
readers and accessor for properties.
-
#q_end ⇒ Object
readers and accessor for properties.
-
#q_frame ⇒ Object
Returns the value of attribute q_frame.
-
#q_len ⇒ Object
Returns the value of attribute q_len.
-
#q_seq ⇒ Object
Returns the value of attribute q_seq.
-
#reversed ⇒ Object
Returns the value of attribute reversed.
-
#s_beg ⇒ Object
readers and accessor for properties.
-
#s_end ⇒ Object
readers and accessor for properties.
-
#s_frame ⇒ Object
Returns the value of attribute s_frame.
-
#s_len ⇒ Object
Returns the value of attribute s_len.
-
#s_seq ⇒ Object
Returns the value of attribute s_seq.
-
#score ⇒ Object
Returns the value of attribute score.
-
#subject_id ⇒ Object
Returns the value of attribute subject_id.
Instance Method Summary collapse
- #compare?(hit) ⇒ Boolean
- #get_subject ⇒ Object
-
#initialize(q_beg, q_end, s_beg, s_end) ⇒ BlastHit
constructor
initializes a new hit.
-
#inspect ⇒ Object
puts all hit info on a string.
- #query_overlaps?(hit, threshold = 0) ⇒ Boolean
- #set_limits(q_beg, q_end, s_beg, s_end) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(q_beg, q_end, s_beg, s_end) ⇒ BlastHit
initializes a new hit
27 28 29 |
# File 'lib/scbi_blast/blast_hit.rb', line 27 def initialize(q_beg,q_end,s_beg,s_end) set_limits(q_beg,q_end,s_beg,s_end) end |
Instance Attribute Details
#acc ⇒ Object
Returns the value of attribute acc.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def acc @acc end |
#align_len ⇒ Object
Returns the value of attribute align_len.
190 191 192 |
# File 'lib/scbi_blast/blast_hit.rb', line 190 def align_len @align_len end |
#bit_score ⇒ Object
Returns the value of attribute bit_score.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def bit_score @bit_score end |
#definition ⇒ Object
Returns the value of attribute definition.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def definition @definition end |
#e_val ⇒ Object
Returns the value of attribute e_val.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def e_val @e_val end |
#full_subject_length ⇒ Object
Returns the value of attribute full_subject_length.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def full_subject_length @full_subject_length end |
#gaps ⇒ Object
Returns the value of attribute gaps.
190 191 192 |
# File 'lib/scbi_blast/blast_hit.rb', line 190 def gaps @gaps end |
#ident ⇒ Object
Returns the value of attribute ident.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def ident @ident end |
#mismatches ⇒ Object
Returns the value of attribute mismatches.
190 191 192 |
# File 'lib/scbi_blast/blast_hit.rb', line 190 def mismatches @mismatches end |
#q_beg ⇒ Object
readers and accessor for properties
189 190 191 |
# File 'lib/scbi_blast/blast_hit.rb', line 189 def q_beg @q_beg end |
#q_end ⇒ Object
readers and accessor for properties
189 190 191 |
# File 'lib/scbi_blast/blast_hit.rb', line 189 def q_end @q_end end |
#q_frame ⇒ Object
Returns the value of attribute q_frame.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def q_frame @q_frame end |
#q_len ⇒ Object
Returns the value of attribute q_len.
193 194 195 |
# File 'lib/scbi_blast/blast_hit.rb', line 193 def q_len @q_len end |
#q_seq ⇒ Object
Returns the value of attribute q_seq.
193 194 195 |
# File 'lib/scbi_blast/blast_hit.rb', line 193 def q_seq @q_seq end |
#reversed ⇒ Object
Returns the value of attribute reversed.
191 192 193 |
# File 'lib/scbi_blast/blast_hit.rb', line 191 def reversed @reversed end |
#s_beg ⇒ Object
readers and accessor for properties
189 190 191 |
# File 'lib/scbi_blast/blast_hit.rb', line 189 def s_beg @s_beg end |
#s_end ⇒ Object
readers and accessor for properties
189 190 191 |
# File 'lib/scbi_blast/blast_hit.rb', line 189 def s_end @s_end end |
#s_frame ⇒ Object
Returns the value of attribute s_frame.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def s_frame @s_frame end |
#s_len ⇒ Object
Returns the value of attribute s_len.
193 194 195 |
# File 'lib/scbi_blast/blast_hit.rb', line 193 def s_len @s_len end |
#s_seq ⇒ Object
Returns the value of attribute s_seq.
193 194 195 |
# File 'lib/scbi_blast/blast_hit.rb', line 193 def s_seq @s_seq end |
#score ⇒ Object
Returns the value of attribute score.
192 193 194 |
# File 'lib/scbi_blast/blast_hit.rb', line 192 def score @score end |
#subject_id ⇒ Object
Returns the value of attribute subject_id.
190 191 192 |
# File 'lib/scbi_blast/blast_hit.rb', line 190 def subject_id @subject_id end |
Instance Method Details
#compare?(hit) ⇒ Boolean
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/scbi_blast/blast_hit.rb', line 147 def compare?(hit) res=true res &&=( @q_beg==hit.q_beg) res &&=( @q_end==hit.q_end) res &&=( @s_beg==hit.s_beg) res &&=( @s_end==hit.s_end) res &&=( @subject_id==hit.subject_id) res &&=( @align_len==hit.align_len) res &&=( @gaps==hit.gaps) res &&=( @mismatches==hit.mismatches) res &&=( @reversed==hit.reversed) res &&=( @score==hit.score) res &&=( @acc==hit.acc) res &&=( @definition==hit.definition) res &&=( @q_frame==hit.q_frame) res &&=( @s_frame==hit.s_frame) res &&=( @full_subject_length==hit.full_subject_length) res &&=( @ident==hit.ident) res &&=( @e_val==hit.e_val) res &&=( @bit_score==hit.bit_score) res &&=( @q_seq==hit.q_seq) res &&=( @s_seq==hit.s_seq) if !res puts "Hits not equal:" puts inspect puts "="*20 puts hit.inspect end return res end |
#get_subject ⇒ Object
135 136 137 |
# File 'lib/scbi_blast/blast_hit.rb', line 135 def get_subject return @subject_id end |
#inspect ⇒ Object
puts all hit info on a string
128 129 130 131 132 133 |
# File 'lib/scbi_blast/blast_hit.rb', line 128 def inspect res = "Hit: #{@subject_id.ljust(10)} #{@ident.to_s.rjust(4)} #{@align_len.to_s.rjust(2)} #{@mismatches.to_s.rjust(2)} #{@gaps.to_s.rjust(2)} #{@q_beg.to_s.rjust(5)} #{@q_end.to_s.rjust(5)} #{@s_beg.to_s.rjust(5)} #{@s_end.to_s.rjust(5)} #{@e_val.to_s.rjust(5)} #{@bit_score.to_s.rjust(5)} #{@reversed.to_s.rjust(5)}" res += " #{@score.to_s.rjust(5)} #{@acc.ljust(10)} #{@definition.ljust(10)} #{@q_frame.to_s.rjust(2)} #{@s_frame.to_s.rjust(2)} #{@full_subject_length.to_s.rjust(5)} #{@q_seq}.#{@s_seq}.#{@q_len}.#{@s_len}" return res end |
#query_overlaps?(hit, threshold = 0) ⇒ Boolean
139 140 141 |
# File 'lib/scbi_blast/blast_hit.rb', line 139 def query_overlaps?(hit,threshold=0) return ((@q_beg<=(hit.q_end+threshold)) and ((@q_end+threshold)>=hit.q_beg)) end |
#set_limits(q_beg, q_end, s_beg, s_end) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/scbi_blast/blast_hit.rb', line 31 def set_limits(q_beg,q_end,s_beg,s_end) # puts "Set limits #{[q_beg,q_end,s_beg,s_end].join(',')}" @q_beg = q_beg.to_i-1 #blast indexes are 1 based @q_end = q_end.to_i-1 @s_beg = s_beg.to_i-1 @s_end = s_end.to_i-1 # puts "Set limits2 #{[@q_beg,@q_end,@s_beg,@s_end].join(',')}" @s_len=0 @q_len=0 @reversed = false # TODO -Reversed should be taken from q_frame and s_frame instead of s_end. In proteins comes from q_frame. In nt from s_frames. # check if reversed if @s_beg > @s_end @s_beg = s_end.to_i-1 @s_end = s_beg.to_i-1 @reversed = true end # puts "Set limits3 #{[@q_beg,@q_end,@s_beg,@s_end].join(',')}" # puts "Set limits4 #{[q_beg,q_end,s_beg,s_end].join(',')}" end |
#size ⇒ Object
143 144 145 |
# File 'lib/scbi_blast/blast_hit.rb', line 143 def size return (@q_end-@q_beg+1) end |