Class: Macroape::PWMCompare
- Inherits:
-
Object
- Object
- Macroape::PWMCompare
- Includes:
- Bioinform::Parameters, Enumerable
- Defined in:
- lib/macroape/pwm_compare.rb
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#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.
10 11 12 13 14 |
# File 'lib/macroape/pwm_compare.rb', line 10 def initialize(first, second) @parameters = OpenStruct.new @first = first @second = second end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
9 10 11 |
# File 'lib/macroape/pwm_compare.rb', line 9 def first @first end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
9 10 11 |
# File 'lib/macroape/pwm_compare.rb', line 9 def parameters @parameters end |
#second ⇒ Object (readonly)
Returns the value of attribute second.
9 10 11 |
# File 'lib/macroape/pwm_compare.rb', line 9 def second @second end |
Instance Method Details
#each_alignment ⇒ Object Also known as: each
34 35 36 37 38 |
# File 'lib/macroape/pwm_compare.rb', line 34 def each_alignment (-second.length..first.length).to_a.product([:direct,:revcomp]) do |shift, orientation| yield PWMCompareAligned.new(first, second, shift, orientation).set_parameters(max_pair_hash_size: max_pair_hash_size) end end |
#jaccard(threshold_first, threshold_second) ⇒ Object
16 17 18 19 20 |
# File 'lib/macroape/pwm_compare.rb', line 16 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
22 23 24 25 26 |
# File 'lib/macroape/pwm_compare.rb', line 22 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
28 29 30 31 32 |
# File 'lib/macroape/pwm_compare.rb', line 28 def jaccard_by_weak_pvalue(pvalue) threshold_first = first.weak_threshold(pvalue) threshold_second = second.weak_threshold(pvalue) jaccard(threshold_first, threshold_second) end |