Sha256: dd1a50d2559433ff8bdb8288ae6db407aadabd1b41c68eff64bc89dbe922b16b

Contents?: true

Size: 840 Bytes

Versions: 396

Compression:

Stored size: 840 Bytes

Contents

local codon_to_protein = {
  AUG = 'Methionine',
  UUC = 'Phenylalanine',
  UUU = 'Phenylalanine',
  UUA = 'Leucine',
  UUG = 'Leucine',
  UCU = 'Serine',
  UCC = 'Serine',
  UCA = 'Serine',
  UCG = 'Serine',
  UAU = 'Tyrosine',
  UAC = 'Tyrosine',
  UGU = 'Cysteine',
  UGC = 'Cysteine',
  UGG = 'Tryptophan',
  UAA = 'STOP',
  UAG = 'STOP',
  UGA = 'STOP'
}

local function translate_codon(codon)
  local protein = codon_to_protein[codon]
  assert(protein ~= nil, 'Unknown codon')
  return protein
end

local function translate_rna_strand(rna_strand)
  local proteins = {}
  for codon in rna_strand:gmatch('...') do
    local protein = translate_codon(codon)
    if protein == 'STOP' then break end
    table.insert(proteins, protein)
  end
  return proteins
end

return {
  codon = translate_codon,
  rna_strand = translate_rna_strand
}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.179 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.178 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.177 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.176 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.175 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.174 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.173 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.172 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.171 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.170 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.169 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.167 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.166 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.165 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.164 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.163 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.162 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.161 tracks/lua/exercises/protein-translation/example.lua
trackler-2.2.1.160 tracks/lua/exercises/protein-translation/example.lua