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.
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 |
# File 'lib/bio/db/primer3.rb', line 595 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
637 638 639 640 641 |
# File 'lib/bio/db/primer3.rb', line 637 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.
578 579 580 |
# File 'lib/bio/db/primer3.rb', line 578 def left @left end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
577 578 579 |
# File 'lib/bio/db/primer3.rb', line 577 def record @record end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
578 579 580 |
# File 'lib/bio/db/primer3.rb', line 578 def right @right end |
Instance Method Details
#<=>(anOther) ⇒ Object
591 592 593 |
# File 'lib/bio/db/primer3.rb', line 591 def <=>(anOther) penalty.to_f <=> anOther.penalty.to_f end |
#parse_coordinates(str) ⇒ Object
580 581 582 583 584 585 |
# File 'lib/bio/db/primer3.rb', line 580 def parse_coordinates(str) coords = str.split(',') coords[0] = coords[0].to_i coords[1] = coords[1].to_i coords end |
#size ⇒ Object
587 588 589 |
# File 'lib/bio/db/primer3.rb', line 587 def size return product_size.to_i end |