Class: BisearchEnzimHu::FpcrSubmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/bisearch_enzim_hu/fpcr_submitter.rb

Instance Method Summary collapse

Constructor Details

#initialize(url = URL) ⇒ FpcrSubmitter

Returns a new instance of FpcrSubmitter.



8
9
10
# File 'lib/bisearch_enzim_hu/fpcr_submitter.rb', line 8

def initialize(url=URL)
  @url = url
end

Instance Method Details

#run(hash, index) ⇒ Object



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
# File 'lib/bisearch_enzim_hu/fpcr_submitter.rb', line 13

def run(hash, index)
  fp   = hash[:fp] || hash[:line_a][:seq] # forward primer
  rp   = hash[:rp] || hash[:line_b][:seq] # reverse primer
  fpcr = "#{fp}!#{rp}"
  db   = "Homo sapiens"

  params = {
    "bis" => "on", # bisulfite
    "db" => db, # database
    "fp" => fp, # forward primer
    "fpcr" => fpcr, # 
    "fpcr_but.x" => "35",
    "fpcr_but.y" => "6",
    "mm" => "0000000011111111", # mismatches
    "npcrres" => "100", # PCR product to show
    "nprimerres" => "100", # Primer matches to show
    "prg" => "cgi/fpcr.cgi", 
    "rp" => rp # reverse primer
  }

  uri = URI(@url)
  puts "---> starting FPCR"
  t = Time.now
  page = Net::HTTP.post_form(uri, params)
  puts "---> FPCR completed (time: #{Time.now-t}s)"

  # puts "--- save result to file: fpcr_result_#{index}.html"
  # File.open("fpcr_result_#{index}.html", 'w') {|f| f.write page.body }
  
  result_page = BisearchEnzimHu::L2ResultPage.new(page.body)
  result_page.parse # return an hash
end