Class: ORF
Defined Under Namespace
Modules: ORFCommon
Constant Summary collapse
- DEFAULT_CODON_TABLE =
1
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
Returns the value of attribute options.
-
#seq ⇒ Object
readonly
Returns the value of attribute seq.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
Class Method Summary collapse
-
.find(sequence, options = {}) ⇒ Object
For a given sequence, find longest ORF.
Instance Method Summary collapse
-
#aa(codon_table = DEFAULT_CODON_TABLE) ⇒ Object
return aminoacid sequence.
-
#find ⇒ Object
finds all possible orfs in sequence.
-
#initialize(sequence, options = {}, logger_file = nil) ⇒ ORF
constructor
class initializer that normalizes sequence to Bio::Sequence, merges given options and creates logger.
-
#nt(codon_table = DEFAULT_CODON_TABLE) ⇒ Object
return nucletotide sequence.
Methods included from ORFCommon
Constructor Details
#initialize(sequence, options = {}, logger_file = nil) ⇒ ORF
class initializer that normalizes sequence to Bio::Sequence,
merges given and creates logger
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/orf.rb', line 18 def initialize(sequence, = {}, logger_file = nil) # logger for instance if logger_file.nil? @logger = Logger.new(STDOUT) else @logger = logger_file.clone end logger.progname = 'ORFCommon' logger.level = ([:debug] ? Logger::INFO : Logger::ERROR) # sequence = Bio::Sequence::NA.new(sequence) if sequence.class == String @sequence = sequence @seq = @sequence.to_s # self. = ORFFinder::DEFAULT_OPTIONS.merge(.nil? ? {} : ) logger.info 'ORF has been initialized' find end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/orf.rb', line 13 def logger @logger end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/orf.rb', line 13 def end |
#seq ⇒ Object (readonly)
Returns the value of attribute seq.
13 14 15 |
# File 'lib/orf.rb', line 13 def seq @seq end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
13 14 15 |
# File 'lib/orf.rb', line 13 def sequence @sequence end |
Class Method Details
.find(sequence, options = {}) ⇒ Object
For a given sequence, find longest ORF
40 41 42 43 44 45 |
# File 'lib/orf.rb', line 40 def self.find(sequence, = {}) # merge options with default orf = ORF.new(sequence, ) @result = orf.find # end |
Instance Method Details
#aa(codon_table = DEFAULT_CODON_TABLE) ⇒ Object
return aminoacid sequence
49 50 51 52 53 54 55 56 |
# File 'lib/orf.rb', line 49 def aa(codon_table = DEFAULT_CODON_TABLE) # return already generated aa sequence return @res_aa unless @res_aa.nil? # save result l = longest(codon_table) return l if @res_aa.nil? @res_aa end |
#find ⇒ Object
finds all possible orfs in sequence
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/orf.rb', line 68 def find # if sequence is nil or empty there is no point # in trying to run the find algorithm return sequence if sequence.nil? || sequence.size == 0 # orf = { frame1: {}, frame2: {}, frame3: {} } # start_idx = all_codons_indices(:start) stop_idx = all_codons_indices(:stop) res = all_sequences(start_idx, stop_idx, seq.size, [0, 1, 2]) # logger.info "start codons idx: #{start_idx}" logger.info "stop codons idx: #{stop_idx}" logger.info res # iterate over each frame and range to return the # longest above the minimum sequence length # these are the preferences: # 1: range that has start and stop codons # 2: range that only has start/stop # 3: full sequence res.each_with_index do |frame, index| find_longest(frame, index, orf) end # print ranges if debug is activated orf.each { |k, f| f[:orfs].each { |r| print_range(k, r) } } \ if [:debug] # @orf = orf end |
#nt(codon_table = DEFAULT_CODON_TABLE) ⇒ Object
return nucletotide sequence
60 61 62 63 |
# File 'lib/orf.rb', line 60 def nt(codon_table = DEFAULT_CODON_TABLE) return @res_nt unless @res_nt.nil? longest(codon_table) end |