class Bio::BioAlignment::Sequence

A Sequence is a simple and efficient container for String sequences. To add state to elements unpack it into an Elements object with to_elements.

Attributes

id[R]
seq[R]

Public Class Methods

new(id, seq) click to toggle source
# File lib/bio-alignment/sequence.rb, line 12
def initialize id, seq
  @id = id
  @id.freeze
  @seq = seq
end

Public Instance Methods

<<(element) click to toggle source
# File lib/bio-alignment/sequence.rb, line 40
def << element
  @seq += element.to_s
end
[](index) click to toggle source
# File lib/bio-alignment/sequence.rb, line 18
def [] index
  @seq[index]
end
clone() click to toggle source
# File lib/bio-alignment/sequence.rb, line 48
def clone
  Sequence.new(@id,@seq.clone)
end
each() { |element| ... } click to toggle source

Return each element in the Sequence as an Element opbject, so it can be queried for gap? and undefined?

# File lib/bio-alignment/sequence.rb, line 32
def each
  @seq.each_char { | c | yield Element.new(c) }
end
empty_copy() click to toggle source
# File lib/bio-alignment/sequence.rb, line 44
def empty_copy
  Sequence.new(@id,"")
end
length() click to toggle source

def []= index, value — we should not implement this for reasons of purity

@seq[index] = value

end

# File lib/bio-alignment/sequence.rb, line 26
def length
  @seq.length
end
to_elements() click to toggle source

Return Sequence (string) as an Elements object

# File lib/bio-alignment/sequence.rb, line 53
def to_elements
  Elements.new(@id,@seq)
end
to_s() click to toggle source
# File lib/bio-alignment/sequence.rb, line 36
def to_s
  @seq.to_s
end