Class: Bioinform::MotifModel::DiPM
- Inherits:
-
Object
- Object
- Bioinform::MotifModel::DiPM
- Defined in:
- lib/sequence_logo/di_pm.rb
Overview
Doesn’t work with alphabet
Instance Attribute Summary collapse
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each_position ⇒ Object
-
#initialize(matrix) ⇒ DiPM
constructor
A new instance of DiPM.
- #length ⇒ Object
- #named(name) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(matrix) ⇒ DiPM
Returns a new instance of DiPM.
17 18 19 20 |
# File 'lib/sequence_logo/di_pm.rb', line 17 def initialize(matrix) @matrix = matrix raise ValidationError.new('invalid matrix', validation_errors: validation_errors) unless valid? end |
Instance Attribute Details
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
16 17 18 |
# File 'lib/sequence_logo/di_pm.rb', line 16 def matrix @matrix end |
Class Method Details
.from_file(filename) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/sequence_logo/di_pm.rb', line 9 def self.from_file(filename) parser = Bioinform::MatrixParser.new(fix_nucleotides_number: 16) infos = parser.parse(File.read(filename)) name = infos[:name] || File.basename(filename, File.extname(filename)) pcm = self.new(infos[:matrix]).named(name) end |
Instance Method Details
#==(other) ⇒ Object
53 54 55 |
# File 'lib/sequence_logo/di_pm.rb', line 53 def ==(other) self.class == other.class && matrix == other.matrix # alphabet should be considered (when alphabet implemented) end |
#each_position ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/sequence_logo/di_pm.rb', line 57 def each_position if block_given? matrix.each{|pos| yield pos} else self.to_enum(:each_position) end end |
#length ⇒ Object
49 50 51 |
# File 'lib/sequence_logo/di_pm.rb', line 49 def length matrix.size + 1 end |
#named(name) ⇒ Object
45 46 47 |
# File 'lib/sequence_logo/di_pm.rb', line 45 def named(name) NamedModel.new(self, name) end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/sequence_logo/di_pm.rb', line 41 def to_s MotifFormatter.new.format(self) end |