Class: Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/rocker/sequence.rb

Overview

Author:

  • Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>

  • Luis (Coto) Orellana

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#alnObject (readonly)

Returns the value of attribute aln.



9
10
11
# File 'lib/rocker/sequence.rb', line 9

def aln
  @aln
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/rocker/sequence.rb', line 9

def id
  @id
end

#seqObject (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

#colsObject



33
# File 'lib/rocker/sequence.rb', line 33

def cols() self.aln.length end

#lengthObject



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_sObject



36
# File 'lib/rocker/sequence.rb', line 36

def to_s() "#:>#{self.id}\n#:#{self.aln}\n" end

#to_seq_sObject



35
# File 'lib/rocker/sequence.rb', line 35

def to_seq_s() ">#{self.id}\n#{self.seq}\n" end