Class: BisearchEnzimHu::PrimerDesign
- Inherits:
-
Object
- Object
- BisearchEnzimHu::PrimerDesign
- Defined in:
- lib/bisearch_enzim_hu/primer_design.rb
Overview
Primer Design Form (at bisearch.enzim.hu/?m=search)
Constant Summary collapse
- URL =
"http://bisearch.enzim.hu/?m=search"
Instance Attribute Summary collapse
-
#chr ⇒ Object
readonly
Returns the value of attribute chr.
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#form ⇒ Object
readonly
Returns the value of attribute form.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#primers ⇒ Object
readonly
Returns the value of attribute primers.
-
#start_pos ⇒ Object
readonly
Returns the value of attribute start_pos.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PrimerDesign
constructor
A new instance of PrimerDesign.
- #prepare ⇒ Object
- #prune ⇒ Object
- #search(two_levels = true) ⇒ Object
- #sequence(seq, chr = nil, start_pos = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PrimerDesign
Returns a new instance of PrimerDesign.
11 12 13 14 15 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 11 def initialize(={}) @agent = Mechanize.new @options = .merge @url = @options.delete :url end |
Instance Attribute Details
#chr ⇒ Object (readonly)
Returns the value of attribute chr.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def chr @chr end |
#end_pos ⇒ Object (readonly)
Returns the value of attribute end_pos.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def end_pos @end_pos end |
#form ⇒ Object (readonly)
Returns the value of attribute form.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def form @form end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def page @page end |
#primers ⇒ Object (readonly)
Returns the value of attribute primers.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def primers @primers end |
#start_pos ⇒ Object (readonly)
Returns the value of attribute start_pos.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def start_pos @start_pos end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 9 def url @url end |
Instance Method Details
#prepare ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 29 def prepare # filling form @page = @agent.get(@url) @form = @page.form @options.each_pair do |field_name, value| case get_type(field_name) when :select # a dropdown @form.field_with(name: field_name.to_s)..find{|e| e.text.downcase=~Regexp.new(value.downcase)}.select when :checkbox @form.checkbox_with(name: field_name.to_s).send(value ? :check : :uncheck) when :radiobutton @form.(name: field_name.to_s).send(value ? :check : :uncheck) when :text @form.field_with(name: field_name.to_s).value=value when :text_area @form.field_with(name: field_name.to_s).value=value # same as text end end self end |
#prune ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 63 def prune indexes_to_remove = [] puts @primers.inspect puts @primers[:output].inspect @primers[:output].each_pair do |i, h| puts h.inspect indexes_to_remove << i if h[:fpcr][:sense][:results].size>1 indexes_to_remove << i if h[:fpcr][:antisense][:results].size>1 end indexes_to_remove.uniq! puts "results to remove: [#{indexes_to_remove.join(', ')}]" indexes_to_remove.each{|i| @primers[:output].delete(i)} end |
#search(two_levels = true) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 50 def search(two_levels=true) @primers = {} puts "---> starting search primers" t = Time.now page = @agent.submit(@form) puts "---> query completed (time: #{Time.now-t}s)" @primers[:input] = {chr: @chr, start_pos: @start_pos, end_pos: @end_pos, seq: @options[:seq]} res_page = BisearchEnzimHu::L1ResultPage.new(page.body) # @primers[:output] = BisearchEnzimHu::L1ResultPage.new(page.body) @primers[:output] = res_page.parse(two_levels) self end |
#sequence(seq, chr = nil, start_pos = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/bisearch_enzim_hu/primer_design.rb', line 18 def sequence(seq, chr=nil, start_pos=nil) @primers = {} @chr = chr @start_pos = start_pos @end_pos = start_pos + seq.size if start_pos @options[:seq] = seq prepare self end |