Class: HTS::Bam::BaseMod::Modification
- Inherits:
-
Object
- Object
- HTS::Bam::BaseMod::Modification
- Defined in:
- lib/hts/bam/base_mod.rb
Overview
Individual base modification information
Instance Attribute Summary collapse
-
#canonical_base ⇒ Object
readonly
Returns the value of attribute canonical_base.
-
#modified_base ⇒ Object
readonly
Returns the value of attribute modified_base.
-
#qual ⇒ Object
readonly
Returns the value of attribute qual.
-
#strand ⇒ Object
readonly
Returns the value of attribute strand.
Instance Method Summary collapse
-
#canonical ⇒ String
Get canonical base as character.
-
#code ⇒ String
Get modification code as character or ChEBI number as string.
-
#initialize(modified_base:, canonical_base:, strand:, qual:) ⇒ Modification
constructor
A new instance of Modification.
-
#inspect ⇒ String
Inspect string.
-
#probability ⇒ Float?
Get likelihood as a probability (0.0-1.0).
-
#to_h ⇒ Hash
Convert to hash representation.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(modified_base:, canonical_base:, strand:, qual:) ⇒ Modification
Returns a new instance of Modification.
27 28 29 30 31 32 |
# File 'lib/hts/bam/base_mod.rb', line 27 def initialize(modified_base:, canonical_base:, strand:, qual:) @modified_base = modified_base @canonical_base = canonical_base @strand = strand @qual = qual end |
Instance Attribute Details
#canonical_base ⇒ Object (readonly)
Returns the value of attribute canonical_base.
21 22 23 |
# File 'lib/hts/bam/base_mod.rb', line 21 def canonical_base @canonical_base end |
#modified_base ⇒ Object (readonly)
Returns the value of attribute modified_base.
21 22 23 |
# File 'lib/hts/bam/base_mod.rb', line 21 def modified_base @modified_base end |
#qual ⇒ Object (readonly)
Returns the value of attribute qual.
21 22 23 |
# File 'lib/hts/bam/base_mod.rb', line 21 def qual @qual end |
#strand ⇒ Object (readonly)
Returns the value of attribute strand.
21 22 23 |
# File 'lib/hts/bam/base_mod.rb', line 21 def strand @strand end |
Instance Method Details
#canonical ⇒ String
Get canonical base as character
42 43 44 |
# File 'lib/hts/bam/base_mod.rb', line 42 def canonical @canonical_base.chr end |
#code ⇒ String
Get modification code as character or ChEBI number as string
36 37 38 |
# File 'lib/hts/bam/base_mod.rb', line 36 def code @modified_base > 0 ? @modified_base.chr : @modified_base.to_s end |
#inspect ⇒ String
Inspect string
80 81 82 |
# File 'lib/hts/bam/base_mod.rb', line 80 def inspect "#<HTS::Bam::BaseMod::Modification #{self}>" end |
#probability ⇒ Float?
Get likelihood as a probability (0.0-1.0)
48 49 50 51 52 |
# File 'lib/hts/bam/base_mod.rb', line 48 def probability return nil if @qual == -1 @qual / 256.0 end |
#to_h ⇒ Hash
Convert to hash representation
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hts/bam/base_mod.rb', line 56 def to_h { modified_base: @modified_base, code: code, canonical_base: @canonical_base, canonical: canonical, strand: @strand, qual: @qual, probability: probability } end |
#to_s ⇒ String
String representation
70 71 72 73 74 75 76 |
# File 'lib/hts/bam/base_mod.rb', line 70 def to_s if @qual >= 0 "#{canonical}->#{code}(#{probability.round(3)})" else "#{canonical}->#{code}" end end |