Class: Bioinform::MotifModel::DiPCM
- Inherits:
-
DiPM
- Object
- DiPM
- Bioinform::MotifModel::DiPCM
show all
- Defined in:
- lib/sequence_logo/di_pm.rb
Instance Attribute Summary
Attributes inherited from DiPM
#matrix
Instance Method Summary
collapse
Methods inherited from DiPM
#==, #each_position, from_file, #initialize, #length, #named, #to_s
Instance Method Details
#sum_dependent_on_first_letter(pos) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/sequence_logo/di_pm.rb', line 69
def sum_dependent_on_first_letter(pos)
mono_pos = Array.new(4, 0.0)
pos.each.with_index{|count, diletter|
first_letter = diletter / 4
mono_pos[first_letter] += count
}
mono_pos
end
|
#sum_dependent_on_second_letter(pos) ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/sequence_logo/di_pm.rb', line 78
def sum_dependent_on_second_letter(pos)
mono_pos = Array.new(4, 0.0)
pos.each.with_index{|count, diletter|
second_letter = diletter % 4
mono_pos[second_letter] += count
}
mono_pos
end
|
#to_mono ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/sequence_logo/di_pm.rb', line 87
def to_mono
mono_matrix = each_position.map{|pos|
sum_dependent_on_first_letter(pos)
} + [ sum_dependent_on_second_letter(matrix.last) ]
PCM.new(mono_matrix, validator: Bioinform::MotifModel::PCM::DIFFERENT_COUNTS_VALIDATOR)
end
|