Class: Bioroebe::DNA
- Inherits:
-
Sequence
- Object
- RawSequence
- Sequence
- Bioroebe::DNA
- Includes:
- NucleotideModule
- Defined in:
- lib/bioroebe/sequence/dna.rb
Overview
Bioroebe::DNA
Constant Summary
Constants inherited from Sequence
Sequence::REMOVE_INVALID_CHARACTERS, Sequence::SHALL_WE_UPCASE
Instance Method Summary collapse
-
#gc_percentage? ⇒ Boolean
# === gc_percentage?.
-
#initialize(this_sequence = 'ATCG') ⇒ DNA
constructor
# === initialize ========================================================================= #.
-
#name_of_gene? ⇒ Boolean
(also: #name_of_gene, #name?)
# === name_of_gene? ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#set_name_of_the_gene(i) ⇒ Object
(also: #name=, #set_name, #name_of_gene=, #set_gene_name)
# === set_name_of_the_gene.
-
#to_aminoacids(i = string?, , ignore_stop_codons = true) ⇒ Object
(also: #to_aa, #to_protein)
# === to_aminoacids.
-
#to_rna ⇒ Object
(also: #to_RNA, #to_T)
# === to_rna.
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') ⇒ DNA
#
initialize
#
35 36 37 38 39 40 41 42 43 |
# File 'lib/bioroebe/sequence/dna.rb', line 35 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
156 157 158 159 |
# File 'lib/bioroebe/sequence/dna.rb', line 156 def gc_percentage? require 'bioroebe/calculate/calculate_gc_content.rb' Bioroebe.gc_content(string?) end |
#name_of_gene? ⇒ Boolean Also known as: name_of_gene, name?
#
name_of_gene?
#
71 72 73 |
# File 'lib/bioroebe/sequence/dna.rb', line 71 def name_of_gene? @name_of_the_gene end |
#reset ⇒ Object
#
reset
#
48 49 50 51 52 53 54 |
# File 'lib/bioroebe/sequence/dna.rb', line 48 def reset super() # ======================================================================= # # === @name_of_the_gene # ======================================================================= # @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.
#
61 62 63 |
# File 'lib/bioroebe/sequence/dna.rb', line 61 def set_name_of_the_gene(i) @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.
#
97 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 |
# File 'lib/bioroebe/sequence/dna.rb', line 97 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_rna ⇒ Object Also known as: to_RNA, to_T
#
to_rna
Convert the main sequence to RNA and return that result.
#
81 82 83 |
# File 'lib/bioroebe/sequence/dna.rb', line 81 def to_rna string?.tr('T','U') end |