Sha256: e6dd356979d62610f127c0bf9ebaded6b3016395b59d1c4fd2f62fc41b01506d

Contents?: true

Size: 801 Bytes

Versions: 105

Compression:

Stored size: 801 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: {}'.format(codon))
    return CODONS[codon]


def proteins(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

105 entries across 105 versions & 1 rubygems

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