Class: TriNuc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(seq, pos, strand, ind = nil) ⇒ TriNuc

Returns a new instance of TriNuc.

Raises:

  • (ArgumentError)


132
133
134
135
136
137
138
139
140
# File 'lib/genetic_code.rb', line 132

def initialize seq, pos, strand, ind=nil
  raise ArgumentError, "Sequence is malformed" unless seq && seq =~ /^[ATGC]{3}$/
  raise ArgumentError, "Three genomic coordinates are required" unless pos.is_a?(Array) && pos.length == 3
  @seq = seq.to_sym
  @pos = pos
  @strand = strand
  @index = ind
  @codon = Codon[@seq]
end

Instance Attribute Details

#codonObject (readonly)

Returns the value of attribute codon.



131
132
133
# File 'lib/genetic_code.rb', line 131

def codon
  @codon
end

#indexObject (readonly)

Returns the value of attribute index.



131
132
133
# File 'lib/genetic_code.rb', line 131

def index
  @index
end

#posObject (readonly)

Returns the value of attribute pos.



131
132
133
# File 'lib/genetic_code.rb', line 131

def pos
  @pos
end

#seqObject (readonly)

Returns the value of attribute seq.



131
132
133
# File 'lib/genetic_code.rb', line 131

def seq
  @seq
end

#strandObject (readonly)

Returns the value of attribute strand.



131
132
133
# File 'lib/genetic_code.rb', line 131

def strand
  @strand
end