Class: Bio::DB::Primer3::PrimerPair
- Inherits:
-
Object
- Object
- Bio::DB::Primer3::PrimerPair
- Includes:
- Comparable
- Defined in:
- lib/bio/db/primer3.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Instance Method Summary collapse
- #<=>(anOther) ⇒ Object
-
#initialize(record, index) ⇒ PrimerPair
constructor
A new instance of PrimerPair.
- #method_missing(m, *args, &block) ⇒ Object
- #parse_coordinates(str) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(record, index) ⇒ PrimerPair
Returns a new instance of PrimerPair.
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/bio/db/primer3.rb', line 694 def initialize(record, index) raise Primer3Exception.new(), "Index #{index} is greater than the number of records" unless index < record.size @record = record @left = Primer.new @right = Primer.new @values = Hash.new @left.set_value("added", false) @right.set_value("added", false) @left.pair = self @right.pair = self index_s = index.to_s record.properties.each do |key, value| tokens = key.to_s.split("_") if tokens.size > 2 and tokens[2] == index_s primer = nil primer = @right if tokens[1] == "right" primer = @left if tokens[1] == "left" if primer != nil primer.set_value("added", true) if tokens.size == 3 primer.set_value("coordinates", parse_coordinates(value) ) else to_add = value to_add = value.to_f unless tokens[3]=="sequence" n_key = tokens[3..6].join("_") primer.set_value(n_key, to_add) end else n_key = tokens[3..6].join("_") @values[n_key] = value end end end raise Primer3Exception.new(), "The pair is not complete (l:#{left.added}, r:#{right.added})" if @left.added == false or @right.added == false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
736 737 738 739 740 |
# File 'lib/bio/db/primer3.rb', line 736 def method_missing(m, *args, &block) return @values[m.to_s] if @values[m.to_s] raise NoMethodError.new(), "There's no method called #{m}. Available methods: #{@values.keys.to_s}" end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
677 678 679 |
# File 'lib/bio/db/primer3.rb', line 677 def left @left end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
676 677 678 |
# File 'lib/bio/db/primer3.rb', line 676 def record @record end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
677 678 679 |
# File 'lib/bio/db/primer3.rb', line 677 def right @right end |
Instance Method Details
#<=>(anOther) ⇒ Object
690 691 692 |
# File 'lib/bio/db/primer3.rb', line 690 def <=>(anOther) penalty.to_f <=> anOther.penalty.to_f end |
#parse_coordinates(str) ⇒ Object
679 680 681 682 683 684 |
# File 'lib/bio/db/primer3.rb', line 679 def parse_coordinates(str) coords = str.split(',') coords[0] = coords[0].to_i coords[1] = coords[1].to_i coords end |
#size ⇒ Object
686 687 688 |
# File 'lib/bio/db/primer3.rb', line 686 def size return product_size.to_i end |