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.70 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.69 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.68 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.67 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.66 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.65 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.64 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.63 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.62 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.61 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.60 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.59 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.58 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.57 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.56 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.55 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.54 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.53 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.52 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.51 tracks/python/exercises/protein-translation/example.py