Class: Bioroebe::RNA

Inherits:
Sequence show all
Includes:
InternalHashModule, NucleotideModule
Defined in:
lib/bioroebe/sequence/rna.rb

Overview

Bioroebe::RNA

Constant Summary

Constants inherited from Sequence

Sequence::REMOVE_INVALID_CHARACTERS, Sequence::SHALL_WE_UPCASE

Instance Method Summary collapse

Methods included from InternalHashModule

#internal_hash?, #reset_the_internal_hash

Methods included from NucleotideModule

#allow_only_valid_dna, #at_percentage, #back_from_rna, #codon_to_aminoacid, #complementary_strand, complementary_strand, #cut_with_enzyme, #gc_percentage, #has_stop_codon?, #n_random_dna, #random, #remove_invalid_entries_from_the_dna_sequence, #to_aminoacid_sequence, #to_dna

Methods inherited from Sequence

[], #automatic_support_for_nucleotides, #description?, #index, #infer_type, #is_DNA?, #is_RNA?, #is_a_protein?, #is_a_protein_now, #map, #n_uracil?, #randomize, #remove_invalid_entries_from_the_dna_sequence, #remove_invalid_entries_from_the_dna_sequence!, #return_string_nucleotides_or_aminoacids, #sanitize_dataset, #sanitize_rna, #save_sequence_to_this_file, sequence_from_file, #set_description, #set_dna, #set_protein, #set_rna, #set_save_file, #set_sequence, #set_type, #shall_we_upcase?, #size?, #to_genbank, #to_regexp, #type?

Methods inherited from RawSequence

#+, #<<, #[]=, #calculate_levensthein_distance, #chars?, #complement, #composition?, #count, #delete, #delete!, #downcase, #each_char, #empty?, #find_substring_indices, #first_position=, #freeze, #gsub, #gsub!, #include?, #insert_at_this_position, #prepend, #remove_n_characters_from_the_left_side, #reverse, #reverse!, #reverse_complement, #scan, #set_raw_sequence, #shuffle, #size?, #split, #start_with?, #strip, #subseq, #to_s, #to_str, #tr!, #upcase!

Constructor Details

#initialize(this_sequence = 'ATCG') ⇒ RNA

#

initialize

#


29
30
31
32
33
34
35
36
37
# File 'lib/bioroebe/sequence/rna.rb', line 29

def initialize(
    this_sequence  = 'ATCG'
  )
  reset
  super(
    this_sequence
  )
  set_dna_type # Make sure we have a DNA only.
end

Instance Method Details

#gc_percentage?Boolean

#

gc_percentage?

Usage example:

x = Bioroebe::DNA.new('TTATTAAGTATTACG'); x.gc_percentage? # => "20.000"
#

Returns:

  • (Boolean)


164
165
166
167
# File 'lib/bioroebe/sequence/rna.rb', line 164

def gc_percentage?
  require 'bioroebe/calculate/calculate_gc_content.rb'
  Bioroebe.gc_content(string?)
end

#is_a_ribozyme?Boolean

#

is_a_ribozyme?

#

Returns:

  • (Boolean)


152
153
154
# File 'lib/bioroebe/sequence/rna.rb', line 152

def is_a_ribozyme?
  @internal_hash[:is_a_ribozyme]
end

#name_of_gene?Boolean Also known as: name_of_gene, name?

#

name_of_gene?

#

Returns:

  • (Boolean)


73
74
75
# File 'lib/bioroebe/sequence/rna.rb', line 73

def name_of_gene?
  @internal_hash[:name_of_the_gene]
end

#resetObject

#

reset

#


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bioroebe/sequence/rna.rb', line 42

def reset
  super()
  reset_the_internal_hash # This should come early on here.
  # ======================================================================= #
  # === :is_a_ribozyme
  #
  # By default RNAs that are created via RNA.new are NOT considered to
  # be a ribozyme.
  # ======================================================================= #
  @internal_hash[:is_a_ribozyme] = false
  # ======================================================================= #
  # === @internal_hash[:name_of_the_gene]
  # ======================================================================= #
  @internal_hash[:name_of_the_gene] = nil # No name is assigned by default.
end

#set_name_of_the_gene(i) ⇒ Object Also known as: name=, set_name, name_of_gene=, set_gene_name

#

set_name_of_the_gene

Use this method if you want to give the gene a specific name.

#


63
64
65
# File 'lib/bioroebe/sequence/rna.rb', line 63

def set_name_of_the_gene(i)
  @internal_hash[:name_of_the_gene] = i
end

#to_aminoacids(i = string?, , ignore_stop_codons = true) ⇒ Object Also known as: to_aa, to_protein

#

to_aminoacids

This will convert the given DNA input into the corresponding aminoacid “output” - aka a translational output, following the regular conversion of DNA→mRNA→protein.

If the second argument to this method is true, then we will filter away all “STOP” elements.

#


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/bioroebe/sequence/rna.rb', line 98

def to_aminoacids(
    i                  = string?,
    ignore_stop_codons = true
  )
  i = [i].flatten
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # We don't have to handle :frame1 since this is the default anyway.
    # ===================================================================== #
    case yielded
    when :frame2
      i.map! {|entry| entry[1..-1] }
    when :frame3
      i.map! {|entry| entry[2..-1] }
    end
  end
  i.map {|entry|
    if entry and (entry.size > 2) # Must check for at the least 3 nucleotides there.
      # =================================================================== #
      # Get a chunk of 3 nucleotides next. This will yield an array of
      # codons such as this one here:
      #
      #   ["GCC", "CAC", "AGG", "CAC", "AAC"]
      #
      # =================================================================== #
      codons = entry.scan(/.../)
      # =================================================================== #
      # Next, find the corresponding aminoacid for this codon.
      # =================================================================== #
      aminoacids = codons.map {|codon|
        result = ::Bioroebe.codon_to_aminoacid(codon)
        result
      }
      if ignore_stop_codons
        aminoacids.reject! {|inner_entry|
          inner_entry == 'STOP'
        }
      end
      result = aminoacids.join
      result # Return the result here.
    else
      entry
    end
  }
end

#to_rnaObject Also known as: to_RNA, to_T

#

to_rna

Convert the main sequence to RNA and return that result.

#


83
84
85
# File 'lib/bioroebe/sequence/rna.rb', line 83

def to_rna
  string?.tr('T','U')
end