Class: Macroape::PWMCompare
- Inherits:
-
Object
- Object
- Macroape::PWMCompare
- Includes:
- Enumerable
- Defined in:
- lib/macroape/pwm_compare.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#max_pair_hash_size ⇒ Object
sets or gets limit of summary size of calculation hash.
-
#second ⇒ Object
readonly
Returns the value of attribute second.
Instance Method Summary collapse
- #each_alignment ⇒ Object (also: #each)
-
#initialize(first, second) ⇒ PWMCompare
constructor
A new instance of PWMCompare.
- #jaccard(threshold_first, threshold_second) ⇒ Object
- #jaccard_by_pvalue(pvalue) ⇒ Object
- #jaccard_by_weak_pvalue(pvalue) ⇒ Object
Constructor Details
#initialize(first, second) ⇒ PWMCompare
Returns a new instance of PWMCompare.
6 7 8 9 |
# File 'lib/macroape/pwm_compare.rb', line 6 def initialize(first, second) @first = first @second = second end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
5 6 7 |
# File 'lib/macroape/pwm_compare.rb', line 5 def first @first end |
#max_pair_hash_size ⇒ Object
sets or gets limit of summary size of calculation hash. It’s a defence against overuse CPU resources by non-appropriate data
4 5 6 |
# File 'lib/macroape/pwm_compare.rb', line 4 def max_pair_hash_size @max_pair_hash_size end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
5 6 7 |
# File 'lib/macroape/pwm_compare.rb', line 5 def second @second end |
Instance Method Details
#each_alignment ⇒ Object Also known as: each
29 30 31 32 33 |
# File 'lib/macroape/pwm_compare.rb', line 29 def each_alignment (-second.length..first.length).to_a.product([:direct,:revcomp]) do |shift, orientation| yield PWMCompareAligned.new(first, second, shift, orientation).tap{|x| x.max_pair_hash_size = max_pair_hash_size } end end |
#jaccard(threshold_first, threshold_second) ⇒ Object
11 12 13 14 15 |
# File 'lib/macroape/pwm_compare.rb', line 11 def jaccard(threshold_first, threshold_second) self.map_each_alignment do |alignment| alignment.alignment_infos.merge( alignment.jaccard(threshold_first, threshold_second) ) end.max_by {|alignment_infos| alignment_infos[:similarity] } end |
#jaccard_by_pvalue(pvalue) ⇒ Object
17 18 19 20 21 |
# File 'lib/macroape/pwm_compare.rb', line 17 def jaccard_by_pvalue(pvalue) threshold_first = first.threshold(pvalue) threshold_second = second.threshold(pvalue) jaccard(threshold_first, threshold_second) end |
#jaccard_by_weak_pvalue(pvalue) ⇒ Object
23 24 25 26 27 |
# File 'lib/macroape/pwm_compare.rb', line 23 def jaccard_by_weak_pvalue(pvalue) threshold_first = first.weak_threshold(pvalue) threshold_second = second.weak_threshold(pvalue) jaccard(threshold_first, threshold_second) end |