Class: Bio::Blat::StreamedReport

Inherits:
Report
  • Object
show all
Defined in:
lib/bio-blat-tools/blat-tools.rb

Class Method Summary collapse

Class Method Details

.each_best_hit(text = '') ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bio-blat-tools/blat-tools.rb', line 31

def self.each_best_hit(text = '')

  best_aln = Hash.new
  self.each_hit(text) do |hit|
    current_matches = hit.match 
    current_name = hit.query_id
    current_identity = hit.percent_identity
    current_score = hit.score
    best_aln[current_name] = hit if best_aln[current_name] == nil or current_score > best_aln[current_name] .score
  end
  best_aln.each_value { |val| yield  val }
end

.each_hit(text = '') ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bio-blat-tools/blat-tools.rb', line 7

def self.each_hit(text = '')
        flag = false
        head = []

        text.each_line do |line|
          if flag then
            yield Hit.new(line)
          else

      if /^\d/ =~ line then # for headerless data
        flag = true
        redo
      end
      line = line.chomp
      if /\A\-+\s*\z/ =~ line
        flag = true
      else
        head << line
      end
    end
  end
end