Class: HTS::Bam::BaseMod::Position
- Inherits:
-
Object
- Object
- HTS::Bam::BaseMod::Position
- Defined in:
- lib/hts/bam/base_mod.rb
Overview
Position-specific modification information
Instance Attribute Summary collapse
-
#modifications ⇒ Object
readonly
Returns the value of attribute modifications.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
Instance Method Summary collapse
-
#hydroxymethylated? ⇒ Boolean
Check if this position has hydroxymethylation.
-
#initialize(position, modifications) ⇒ Position
constructor
A new instance of Position.
-
#inspect ⇒ String
Inspect string.
-
#methylated? ⇒ Boolean
Check if this position has methylation.
-
#to_h ⇒ Hash
Convert to hash representation.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(position, modifications) ⇒ Position
Returns a new instance of Position.
91 92 93 94 |
# File 'lib/hts/bam/base_mod.rb', line 91 def initialize(position, modifications) @position = position @modifications = modifications end |
Instance Attribute Details
#modifications ⇒ Object (readonly)
Returns the value of attribute modifications.
87 88 89 |
# File 'lib/hts/bam/base_mod.rb', line 87 def modifications @modifications end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
87 88 89 |
# File 'lib/hts/bam/base_mod.rb', line 87 def position @position end |
Instance Method Details
#hydroxymethylated? ⇒ Boolean
Check if this position has hydroxymethylation
104 105 106 |
# File 'lib/hts/bam/base_mod.rb', line 104 def hydroxymethylated? @modifications.any? { |m| m.code == "h" } end |
#inspect ⇒ String
Inspect string
126 127 128 |
# File 'lib/hts/bam/base_mod.rb', line 126 def inspect "#<HTS::Bam::BaseMod::Position #{self}>" end |
#methylated? ⇒ Boolean
Check if this position has methylation
98 99 100 |
# File 'lib/hts/bam/base_mod.rb', line 98 def methylated? @modifications.any? { |m| m.code == "m" } end |
#to_h ⇒ Hash
Convert to hash representation
110 111 112 113 114 115 |
# File 'lib/hts/bam/base_mod.rb', line 110 def to_h { position: @position, modifications: @modifications.map(&:to_h) } end |
#to_s ⇒ String
String representation
119 120 121 122 |
# File 'lib/hts/bam/base_mod.rb', line 119 def to_s mods_str = @modifications.map(&:to_s).join(", ") "pos=#{@position} [#{mods_str}]" end |