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.
6 7 8 9 10 11 |
# File 'lib/hts/faidx/sequence.rb', line 6 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.
4 5 6 |
# File 'lib/hts/faidx/sequence.rb', line 4 def faidx @faidx end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/hts/faidx/sequence.rb', line 4 def name @name end |
Instance Method Details
#[](arg) ⇒ Object
26 27 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 |
# File 'lib/hts/faidx/sequence.rb', line 26 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
13 14 15 |
# File 'lib/hts/faidx/sequence.rb', line 13 def length faidx.seq_len(name) end |
#qual(start = nil, stop = nil) ⇒ Object
22 23 24 |
# File 'lib/hts/faidx/sequence.rb', line 22 def qual(start = nil, stop = nil) faidx.qual(name, start, stop) end |
#seq(start = nil, stop = nil) ⇒ Object
18 19 20 |
# File 'lib/hts/faidx/sequence.rb', line 18 def seq(start = nil, stop = nil) faidx.seq(name, start, stop) end |