Sha256: c69d4d5237f739cbb187234f38508ef7fc19f4e94add2f651fe15c21a15f034b
Contents?: true
Size: 868 Bytes
Versions: 123
Compression:
Stored size: 868 Bytes
Contents
const ACID_PROTEIN_MAP = { AUG: 'Methionine', UUU: 'Phenylalanine', UUC: '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', }; const getProtein = codon => ACID_PROTEIN_MAP[codon] || 'INVALID'; export default function translate(rnaStrand) { const proteins = []; if (rnaStrand) { for (let i = 0; i < rnaStrand.length; i += 3) { const protein = getProtein(rnaStrand.substring(i, i + 3)); if (protein) { if (protein === 'STOP') { break; } if (protein === 'INVALID') { throw new Error('Invalid codon'); } proteins.push(protein); } } } return proteins; }
Version data entries
123 entries across 123 versions & 1 rubygems