Class: Align::PairwiseAlgorithm
- Inherits:
-
Object
- Object
- Align::PairwiseAlgorithm
- Defined in:
- lib/align/pairwise_algorithm.rb
Overview
Provides a base for algorithms that align two sequences.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#scoring ⇒ Object
readonly
Returns the value of attribute scoring.
-
#seq1 ⇒ Object
readonly
Returns the value of attribute seq1.
-
#seq2 ⇒ Object
readonly
Returns the value of attribute seq2.
Instance Method Summary collapse
-
#align ⇒ Object
Returns the sequences in aligned arrays.
-
#initialize(seq1, seq2, scoring) ⇒ PairwiseAlgorithm
constructor
A new instance of PairwiseAlgorithm.
-
#max2(a, b) ⇒ Object
Max of 2.
-
#max3(a, b, c) ⇒ Object
Determines the maximum value of three variables.
-
#max4(a, b, c, d) ⇒ Object
Returns the max of 4 integers.
Constructor Details
#initialize(seq1, seq2, scoring) ⇒ PairwiseAlgorithm
Returns a new instance of PairwiseAlgorithm.
6 7 8 9 10 |
# File 'lib/align/pairwise_algorithm.rb', line 6 def initialize(seq1, seq2, scoring) @seq1 = seq1 @seq2 = seq2 @scoring = scoring end |
Instance Attribute Details
#scoring ⇒ Object (readonly)
Returns the value of attribute scoring.
4 5 6 |
# File 'lib/align/pairwise_algorithm.rb', line 4 def scoring @scoring end |
#seq1 ⇒ Object (readonly)
Returns the value of attribute seq1.
4 5 6 |
# File 'lib/align/pairwise_algorithm.rb', line 4 def seq1 @seq1 end |
#seq2 ⇒ Object (readonly)
Returns the value of attribute seq2.
4 5 6 |
# File 'lib/align/pairwise_algorithm.rb', line 4 def seq2 @seq2 end |
Instance Method Details
#align ⇒ Object
Returns the sequences in aligned arrays. Gaps are filled with :skip_obj
34 35 36 |
# File 'lib/align/pairwise_algorithm.rb', line 34 def align raise NotImplementedError.new("#{self.class}#align") end |
#max2(a, b) ⇒ Object
Max of 2
13 14 15 |
# File 'lib/align/pairwise_algorithm.rb', line 13 def max2(a,b) a >= b ? a : b end |
#max3(a, b, c) ⇒ Object
Determines the maximum value of three variables. 3-4 times faster than [a,b,c].max.
19 20 21 |
# File 'lib/align/pairwise_algorithm.rb', line 19 def max3(a,b,c) (a >= b) ? ((a >= c)? a : c) : ((b >= c)? b : c) end |
#max4(a, b, c, d) ⇒ Object
Returns the max of 4 integers
24 25 26 27 28 |
# File 'lib/align/pairwise_algorithm.rb', line 24 def max4(a,b,c,d) x = a >= b ? a : b y = c >= d ? c : d (x >= y) ? x : y end |