Sha256: d3ce56a21ea43c00ba21473fe102a2fecf0a713658efb49365400eadfb2d9415

Contents?: true

Size: 793 Bytes

Versions: 108

Compression:

Stored size: 793 Bytes

Contents

CODONS = {'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"}


def of_codon(codon):
    if codon not in CODONS:
        raise ValueError('Invalid codon: %s' % codon)
    return CODONS[codon]


def of_rna(strand):
    proteins = []
    for codon in map(of_codon, _chunkstring(strand, 3)):
        if codon == 'STOP':
            break
        proteins.append(codon)
    return proteins


def _chunkstring(string, n):
    return (string[i:n + i] for i in range(0, len(string), n))

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
trackler-2.2.1.30 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.29 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.28 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.27 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.26 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.25 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.24 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.23 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.22 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.21 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.20 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.19 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.18 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.17 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.16 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.15 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.14 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.13 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.12 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.11 tracks/python/exercises/protein-translation/example.py