Class: Bio::Big::FrameCodonHelpers::FrameCodonSequence

Inherits:
Object
  • Object
show all
Includes:
TrackSequenceTrait, Enumerable
Defined in:
lib/bigbio/db/emitters/orf_emitter.rb

Instance Attribute Summary collapse

Attributes included from TrackSequenceTrait

#track_ntseq_pos

Instance Method Summary collapse

Methods included from TrackSequenceTrait

update_reversed_sequence_pos, update_sequence_pos

Constructor Details

#initialize(seq, pos = 0) ⇒ FrameCodonSequence

Returns a new instance of FrameCodonSequence.



76
77
78
79
80
81
82
83
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 76

def initialize seq, pos=0
  if seq.kind_of?(String)
    @codons = seq.upcase.scan(/(\w\w\w)/).flatten
  else
    @codons = seq
  end
  @pos = pos
end

Instance Attribute Details

#codonsObject (readonly)

Returns the value of attribute codons.



75
76
77
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 75

def codons
  @codons
end

#posObject (readonly)

codon position in short parent sequence



74
75
76
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 74

def pos
  @pos
end

Instance Method Details

#[](index) ⇒ Object



90
91
92
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 90

def [] index
  @codons[index]
end

#eachObject



101
102
103
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 101

def each
  @codons.each { | c| yield c }
end

#rposObject



87
88
89
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 87

def rpos
  pos + size
end

#shiftObject



93
94
95
96
97
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 93

def shift
  list = @codons
  list.shift
  FrameCodonSequence.new(list,@pos+1)
end

#sizeObject



84
85
86
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 84

def size
  @codons.size
end

#to_seqObject



98
99
100
# File 'lib/bigbio/db/emitters/orf_emitter.rb', line 98

def to_seq
  @codons.join
end