class String 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 else 'x' end } return res.compact.join end 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 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 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 end