Class: Sequence
- Inherits:
-
Object
- Object
- Sequence
- Defined in:
- lib/rocker/sequence.rb
Overview
Instance Attribute Summary collapse
-
#aln ⇒ Object
readonly
Returns the value of attribute aln.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
Instance Method Summary collapse
- #col2pos(col) ⇒ Object
- #cols ⇒ Object
-
#initialize(id, aln) ⇒ Sequence
constructor
A new instance of Sequence.
- #length ⇒ Object
- #pos2col(pos) ⇒ Object
- #to_s ⇒ Object
- #to_seq_s ⇒ Object
Constructor Details
#initialize(id, aln) ⇒ Sequence
Returns a new instance of Sequence.
10 11 12 13 14 |
# File 'lib/rocker/sequence.rb', line 10 def initialize(id, aln) @id = id @aln = aln.gsub(/[-\.]/,'-').gsub(/[^A-Za-z-]/, '').upcase @seq = aln.gsub(/[^A-Za-z]/, '').upcase end |
Instance Attribute Details
#aln ⇒ Object (readonly)
Returns the value of attribute aln.
9 10 11 |
# File 'lib/rocker/sequence.rb', line 9 def aln @aln end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/rocker/sequence.rb', line 9 def id @id end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
9 10 11 |
# File 'lib/rocker/sequence.rb', line 9 def seq @seq end |
Instance Method Details
#col2pos(col) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rocker/sequence.rb', line 24 def col2pos(col) pos = 1 self.aln.split(//).each do |c| col-=1 pos+=1 unless c=='-' return pos if col==0 end pos end |
#cols ⇒ Object
33 |
# File 'lib/rocker/sequence.rb', line 33 def cols() self.aln.length end |
#length ⇒ Object
34 |
# File 'lib/rocker/sequence.rb', line 34 def length() self.seq.length end |
#pos2col(pos) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rocker/sequence.rb', line 15 def pos2col(pos) col = 0 self.aln.split(//).each do |c| col+=1 pos-=1 unless c=='-' return col if pos==0 end col end |
#to_s ⇒ Object
36 |
# File 'lib/rocker/sequence.rb', line 36 def to_s() "#:>#{self.id}\n#:#{self.aln}\n" end |
#to_seq_s ⇒ Object
35 |
# File 'lib/rocker/sequence.rb', line 35 def to_seq_s() ">#{self.id}\n#{self.seq}\n" end |