Class: BisearchEnzimHu::L1ResultPage
- Inherits:
-
Object
- Object
- BisearchEnzimHu::L1ResultPage
- Defined in:
- lib/bisearch_enzim_hu/l1_result_page.rb
Instance Method Summary collapse
-
#initialize(f) ⇒ L1ResultPage
constructor
A new instance of L1ResultPage.
- #parse(deep = false) ⇒ Object
Constructor Details
#initialize(f) ⇒ L1ResultPage
Returns a new instance of L1ResultPage.
7 8 9 10 |
# File 'lib/bisearch_enzim_hu/l1_result_page.rb', line 7 def initialize(f) @doc = Nokogiri::HTML(f) @table_hash = nil end |
Instance Method Details
#parse(deep = false) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 56 57 |
# File 'lib/bisearch_enzim_hu/l1_result_page.rb', line 12 def parse(deep=false) # select the table after the sequence: h2,h3,input table = @doc.css("h2+h3+input+table").first rows = table.css("tr") header = rows.shift @table_hash = {} while !rows.empty? # line_a, line_b = rows.shift(2) line_a = rows.shift.css("td") line_bb = rows.shift line_b = line_bb.css("td") hh = { :line_a => line_a, :line_b => line_b } h = {} # index = line_a[0].content.to_i # h[:index] = index h[:score] = line_a[1].content.to_f h[:pa] = line_a[11].content.to_i h[:pea] = line_a[12].content.to_i h[:len] = line_a[13].content.to_i h[:fp] = line_bb.css("input").select{|el| el["name"]=="fp"}.first h[:fp] = h[:fp]["value"] if !h[:fp].nil? h[:rp] = line_bb.css("input").select{|el| el["name"]=="rp"}.first h[:rp] = h[:rp]["value"] if !h[:rp].nil? hh.each_pair do |i, line| h[i] = {} h[i][:seq] = line[2].content h[i][:pos] = line[3].content.to_i h[i][:plen] = line[4].content.to_i h[i][:gc] = line[5].content.to_f h[i][:tm] = line[6].content.to_f h[i][:otm] = line[7].content.to_f h[i][:cpg] = line[8].content h[i][:sa] = line[9].content.to_i h[i][:sea] = line[10].content.to_i end @table_hash[index] = h end proceed if deep @table_hash end |