Class: HTS::Faidx::Sequence
- Inherits:
-
Object
- Object
- HTS::Faidx::Sequence
- Defined in:
- lib/hts/faidx/sequence.rb
Instance Attribute Summary collapse
-
#faidx ⇒ Object
readonly
Returns the value of attribute faidx.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #[](arg) ⇒ Object
-
#initialize(faidx, name) ⇒ Sequence
constructor
A new instance of Sequence.
- #length ⇒ Object (also: #size)
- #qual(start = nil, stop = nil) ⇒ Object
- #seq(start = nil, stop = nil) ⇒ Object
Constructor Details
#initialize(faidx, name) ⇒ Sequence
Returns a new instance of Sequence.
8 9 10 11 12 13 |
# File 'lib/hts/faidx/sequence.rb', line 8 def initialize(faidx, name) raise unless faidx.has_key?(name) @faidx = faidx @name = name end |
Instance Attribute Details
#faidx ⇒ Object (readonly)
Returns the value of attribute faidx.
6 7 8 |
# File 'lib/hts/faidx/sequence.rb', line 6 def faidx @faidx end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/hts/faidx/sequence.rb', line 6 def name @name end |
Instance Method Details
#[](arg) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hts/faidx/sequence.rb', line 28 def [](arg) case arg when Integer if arg >= 0 start = arg stop = arg else start = length + arg stop = length + arg end when Range arg = Range.new(arg.begin, arg.end + length, arg.exclude_end?) if arg.end&.<(0) arg = Range.new(arg.begin + length, arg.end, arg.exclude_end?) if arg.begin&.<(0) if arg.begin.nil? if arg.end.nil? start = nil stop = nil else start = 0 stop = arg.exclude_end? ? arg.end - 1 : arg.end end elsif arg.end.nil? # always include the first base start = arg.begin stop = length - 1 else start = arg.begin stop = arg.exclude_end? ? arg.end - 1 : arg.end end else raise ArgumentError end seq(start, stop) end |
#length ⇒ Object Also known as: size
15 16 17 |
# File 'lib/hts/faidx/sequence.rb', line 15 def length faidx.seq_len(name) end |
#qual(start = nil, stop = nil) ⇒ Object
24 25 26 |
# File 'lib/hts/faidx/sequence.rb', line 24 def qual(start = nil, stop = nil) faidx.qual(name, start, stop) end |
#seq(start = nil, stop = nil) ⇒ Object
20 21 22 |
# File 'lib/hts/faidx/sequence.rb', line 20 def seq(start = nil, stop = nil) faidx.seq(name, start, stop) end |