Class: ORFFinder

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

Overview

Wrapper class that processes the direct and reverse sequences

Constant Summary collapse

DEFAULT_OPTIONS =
{ start: %w(atg),
stop:  %w(tag taa tga),
reverse: true,
direct: true,
min: 6,
debug: false }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sequence, codon_table = 1, options = {}, logger = nil) ⇒ ORFFinder

Returns a new instance of ORFFinder.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/orf_finder.rb', line 17

def initialize(sequence, codon_table = 1, options = {}, logger = nil)
  #
  sequence = Bio::Sequence::NA.new(sequence) if sequence.class == String
  options = DEFAULT_OPTIONS.merge(options.nil? ? {} : options)
  #
  @output = {}
  @output[:direct] = ORF.new(sequence, options, logger) if options[:direct]
  #
  if options[:reverse]
    compl = sequence.complement
    @output[:reverse] = ORF.new(compl, options, logger)
  end
  #
  @codon_table = codon_table
end

Instance Attribute Details

#codon_tableObject (readonly)

Returns the value of attribute codon_table.



8
9
10
# File 'lib/orf_finder.rb', line 8

def codon_table
  @codon_table
end

Instance Method Details

#aaObject



42
43
44
45
46
47
48
49
# File 'lib/orf_finder.rb', line 42

def aa
  res = {}
  @output.each do |key, value|
    res[key] = value.aa(@codon_table)
    res[key][:sequence] = value.sequence.translate(@codon_table).to_s
  end
  res
end

#directObject



51
52
53
# File 'lib/orf_finder.rb', line 51

def direct
  @output[:direct]
end

#ntObject



33
34
35
36
37
38
39
40
# File 'lib/orf_finder.rb', line 33

def nt
  res = {}
  @output.each do |key, value|
    res[key] = value.nt(@codon_table)
    res[key][:sequence] = value.seq
  end
  res
end

#reverseObject



55
56
57
# File 'lib/orf_finder.rb', line 55

def reverse
  @output[:reverse]
end