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.
28 29 30 31 32 33 |
# File 'lib/hts/bam/base_mod.rb', line 28 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.
22 23 24 |
# File 'lib/hts/bam/base_mod.rb', line 22 def canonical_base @canonical_base end |
#modified_base ⇒ Object (readonly)
Returns the value of attribute modified_base.
22 23 24 |
# File 'lib/hts/bam/base_mod.rb', line 22 def modified_base @modified_base end |
#qual ⇒ Object (readonly)
Returns the value of attribute qual.
22 23 24 |
# File 'lib/hts/bam/base_mod.rb', line 22 def qual @qual end |
#strand ⇒ Object (readonly)
Returns the value of attribute strand.
22 23 24 |
# File 'lib/hts/bam/base_mod.rb', line 22 def strand @strand end |
Instance Method Details
#canonical ⇒ String
Get canonical base as character
43 44 45 |
# File 'lib/hts/bam/base_mod.rb', line 43 def canonical @canonical_base.chr end |
#code ⇒ String
Get modification code as character or ChEBI number as string
37 38 39 |
# File 'lib/hts/bam/base_mod.rb', line 37 def code @modified_base > 0 ? @modified_base.chr : @modified_base.to_s end |
#inspect ⇒ String
Inspect string
81 82 83 |
# File 'lib/hts/bam/base_mod.rb', line 81 def inspect "#<HTS::Bam::BaseMod::Modification #{self}>" end |
#probability ⇒ Float?
Get likelihood as a probability (0.0-1.0)
49 50 51 52 53 |
# File 'lib/hts/bam/base_mod.rb', line 49 def probability return nil if @qual == -1 @qual / 256.0 end |
#to_h ⇒ Hash
Convert to hash representation
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/hts/bam/base_mod.rb', line 57 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
71 72 73 74 75 76 77 |
# File 'lib/hts/bam/base_mod.rb', line 71 def to_s if @qual >= 0 "#{canonical}->#{code}(#{probability.round(3)})" else "#{canonical}->#{code}" end end |