Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/full_lengther_next/classes/lcs.rb,
lib/full_lengther_next/classes/fl_string_utils.rb
Instance Method Summary collapse
- #complementary_dna ⇒ Object
- #generate_orf_old(a, frame) ⇒ Object
- #lcs(s2) ⇒ Object
- #orf_finder_old ⇒ Object
- #translate ⇒ Object
Instance Method Details
#complementary_dna ⇒ Object
134 135 136 137 |
# File 'lib/full_lengther_next/classes/fl_string_utils.rb', line 134 def complementary_dna c={'A'=>'T', 'a' => 't', 'T' => 'A', 't' => 'a', 'C' => 'G', 'c'=>'g' , 'G' => 'C', 'g' => 'c', 'N' => 'N', 'n' => 'N' , 'R' => 'N', 'r' => 'N', 'W' => 'N', 'w' => 'N', 'M' => 'N', 'm' => 'N', 'K' => 'N', 'k' => 'N', 'S' => 'N', 's' => 'N', 'Y' => 'N', 'y' => 'N', 'H' => 'N', 'h' => 'N', 'B' => 'N', 'b' => 'N', 'D' => 'N', 'd' => 'N', 'V' => 'N', 'v' => 'N' } return self.reverse.split('').map{|e| c[e]}.join end |
#generate_orf_old(a, frame) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 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 |
# File 'lib/full_lengther_next/classes/fl_string_utils.rb', line 45 def generate_orf_old(a,frame) all_orfs = [] each_orf = [] atg_codon = false stop_codon = false orf ='' t_start = 0 t_end = 0 a.each do |e| t_end += 3 if (atg_codon) orf += e if (e == 'TAG') or (e == 'TGA') or (e == 'TAA') if (orf.length >= 200) each_orf.push orf each_orf.push t_start each_orf.push t_end each_orf.push frame each_orf.push stop_codon all_orfs.push each_orf each_orf = [] end orf='' stop_codon = true atg_codon = false t_start = t_end end elsif (e == 'ATG') atg_codon = true orf += e t_start += 1 elsif (e == 'TAG') or (e == 'TGA') or (e == 'TAA') stop_codon = true t_start += 3 else t_start += 3 end end if (all_orfs != '') && (all_orfs != nil) return all_orfs else return nil end end |
#lcs(s2) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/full_lengther_next/classes/lcs.rb', line 5 def lcs(s2) s1=self res="" num=Array.new(s1.size){Array.new(s2.size)} len,ans=0 lastsub=0 s1.scan(/./).each_with_index do |l1,i | s2.scan(/./).each_with_index do |l2,j | unless l1==l2 num[i][j]=0 else (i==0 || j==0)? num[i][j]=1 : num[i][j]=1 + num[i-1][j-1] if num[i][j] > len len = ans = num[i][j] thissub = i thissub -= num[i-1][j-1] unless num[i-1][j-1].nil? if lastsub==thissub res+=s1[i,1] else lastsub=thissub res=s1[lastsub, (i+1)-lastsub] end end end end end res end |
#orf_finder_old ⇒ Object
95 96 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 |
# File 'lib/full_lengther_next/classes/fl_string_utils.rb', line 95 def orf_finder_old res =[] s = self.upcase f1 = s.split('').each_slice(3).map{|e| e.join} r1 = generate_orf(f1,1) res += r1 s.sub!(/^./,'') f2 = s.split('').each_slice(3).map{|e| e.join} r2 = generate_orf(f2,2) res += r2 s.sub!(/^./,'') f3 = s.split('').each_slice(3).map{|e| e.join} r3 = generate_orf(f3,3) res += r3 # vamos a por los ORFs de la cadena complementaria s = self.upcase s = s.complementary_dna f4 = s.split('').each_slice(3).map{|e| e.join} r4 = generate_orf(f4,-1) res += r4 s.sub!(/^./,'') f5 = s.split('').each_slice(3).map{|e| e.join} r5 = generate_orf(f5,-2) res += r5 s.sub!(/^./,'') f6 = s.split('').each_slice(3).map{|e| e.join} r6 = generate_orf(f6,-3) res += r6 return res end |
#translate ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/full_lengther_next/classes/fl_string_utils.rb', line 4 def translate s = self.upcase a = s.split('').each_slice(3).map{|e| e.join} c={'GCT'=>'A', 'GCC'=>'A','GCA'=>'A','GCG'=>'A', 'CGT'=>'R','CGC'=>'R','CGA'=>'R','CGG'=>'R','AGA'=>'R','AGG'=>'R', 'AAT'=>'N','AAC'=>'N', 'GAT'=>'D','GAC'=>'D', 'TGT'=>'C','TGC'=>'C', 'CAA'=>'Q','CAG'=>'Q', 'GAA'=>'E','GAG'=>'E', 'GGT'=>'G','GGC'=>'G','GGA'=>'G','GGG'=>'G', 'CAT'=>'H','CAC'=>'H', 'ATT'=>'I','ATC'=>'I','ATA'=>'I', 'TTA'=>'L','TTG'=>'L','CTT'=>'L','CTC'=>'L','CTA'=>'L','CTG'=>'L', 'ATG'=>'M', 'AAA'=>'K','AAG'=>'K', 'TTT'=>'F','TTC'=>'F', 'CCT'=>'P','CCC'=>'P','CCA'=>'P','CCG'=>'P', 'TCT'=>'S','TCC'=>'S','TCA'=>'S','TCG'=>'S','AGT'=>'S','AGC'=>'S', 'ACT'=>'T','ACC'=>'T','ACA'=>'T','ACG'=>'T', 'TGG'=>'W', 'TAT'=>'Y','TAC'=>'Y', 'GTT'=>'V','GTC'=>'V','GTA'=>'V','GTG'=>'V', 'TAG'=>'*','TGA'=>'*','TAA'=>'*'} #EN CASO DE NO ENCONTRAR EL TRIPLETE SE AÑADE UNA X res=a.map{ |e| if (e.length == 3) if (e =~ /[NnRrWwMmKkSsYyHhBbDdVv]/) 'x' else c[e]||'x' end end } return res.compact.join end |