Class: Bix::Blast::QueryHits

Inherits:
Object
  • Object
show all
Defined in:
lib/bix/blast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hits, pref_min_aln_len = 0) ⇒ QueryHits

Suppose we want the best_hit to point to the best e-value of all hits over a certain aln len If there are no hits over that length, then we want the best e-value



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/bix/blast.rb', line 45

def initialize(hits, pref_min_aln_len=0)
  @pref_min_aln_len = pref_min_aln_len
  @hits = hits

  raise "QueryHits error: must have > 0 hits"  unless hits.size > 0

  @query = hits.first.query
  @best_hit = hits.first

  for h in hits
    raise "QueryHits error: not all hits have same query!" if h.query != query

    if @best_hit.align_len < pref_min_aln_len && h.align_len >= pref_min_aln_len
      @best_hit = h
    elsif h.e_value < @best_hit.e_value
      @best_hit = h
    end
  end
end

Instance Attribute Details

#best_hitObject

Returns the value of attribute best_hit.



41
42
43
# File 'lib/bix/blast.rb', line 41

def best_hit
  @best_hit
end

#hitsObject

Returns the value of attribute hits.



41
42
43
# File 'lib/bix/blast.rb', line 41

def hits
  @hits
end

#pref_min_aln_lenObject

Returns the value of attribute pref_min_aln_len.



41
42
43
# File 'lib/bix/blast.rb', line 41

def pref_min_aln_len
  @pref_min_aln_len
end

#queryObject

Returns the value of attribute query.



41
42
43
# File 'lib/bix/blast.rb', line 41

def query
  @query
end