Sha256: f418c059bfe9a95686e5dfb38a6868e7c2b787fcd03689be3d69b6a2d1eb8da0
Contents?: true
Size: 1.92 KB
Versions: 68
Compression:
Stored size: 1.92 KB
Contents
class ProteinTranslation { static translations = [ {codon: 'AUG', protein: 'Methionine'}, {codon: 'UUU', protein: 'Phenylalanine'}, {codon: 'UUC', protein: 'Phenylalanine'}, {codon: 'UUA', protein: 'Leucine'}, {codon: 'UUG', protein: 'Leucine'}, {codon: 'UCU', protein: 'Serine'}, {codon: 'UCC', protein: 'Serine'}, {codon: 'UCA', protein: 'Serine'}, {codon: 'UCG', protein: 'Serine'}, {codon: 'UAU', protein: 'Tyrosine'}, {codon: 'UAC', protein: 'Tyrosine'}, {codon: 'UGU', protein: 'Cysteine'}, {codon: 'UGC', protein: 'Cysteine'}, {codon: 'UGG', protein: 'Tryptophan'}, {codon: 'UAA', protein: 'STOP'}, {codon: 'UAG', protein: 'STOP'}, {codon: 'UGA', protein: 'STOP'} ] static proteins(strand: string) { const codons = this.breakStrandIntoCodons(strand) return this.getProteinsFromCodons(codons) } private static breakStrandIntoCodons(strand: string): string[] { const result: string[] = [] for (let i = 0; i <= strand.length - 1; i++) { result.push(strand.slice(0, 3)) strand = strand.slice(3) } return result } private static getProteinsFromCodons(codons: string[]) { const result: string[] = [] for (const codon of codons) { const protein = this.getProteinFromCodon(codon) if (protein !== 'STOP') { result.push(protein) } else { break } } return result } private static getProteinFromCodon(codon: string): string { let result = '' for (const translation of this.translations) { if (translation.codon === codon) { result = translation.protein break } } return result } } export default ProteinTranslation
Version data entries
68 entries across 68 versions & 1 rubygems