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.
92 93 94 95 |
# File 'lib/hts/bam/base_mod.rb', line 92 def initialize(position, modifications) @position = position @modifications = modifications end |
Instance Attribute Details
#modifications ⇒ Object (readonly)
Returns the value of attribute modifications.
88 89 90 |
# File 'lib/hts/bam/base_mod.rb', line 88 def modifications @modifications end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
88 89 90 |
# File 'lib/hts/bam/base_mod.rb', line 88 def position @position end |
Instance Method Details
#hydroxymethylated? ⇒ Boolean
Check if this position has hydroxymethylation
105 106 107 |
# File 'lib/hts/bam/base_mod.rb', line 105 def hydroxymethylated? @modifications.any? { |m| m.code == "h" } end |
#inspect ⇒ String
Inspect string
127 128 129 |
# File 'lib/hts/bam/base_mod.rb', line 127 def inspect "#<HTS::Bam::BaseMod::Position #{self}>" end |
#methylated? ⇒ Boolean
Check if this position has methylation
99 100 101 |
# File 'lib/hts/bam/base_mod.rb', line 99 def methylated? @modifications.any? { |m| m.code == "m" } end |
#to_h ⇒ Hash
Convert to hash representation
111 112 113 114 115 116 |
# File 'lib/hts/bam/base_mod.rb', line 111 def to_h { position: @position, modifications: @modifications.map(&:to_h) } end |
#to_s ⇒ String
String representation
120 121 122 123 |
# File 'lib/hts/bam/base_mod.rb', line 120 def to_s mods_str = @modifications.map(&:to_s).join(", ") "pos=#{@position} [#{mods_str}]" end |