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.1.0.53 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.52 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.51 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.50 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.49 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.48 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.47 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.46 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.45 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.44 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.43 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.42 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.41 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.40 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.39 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.38 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.37 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.36 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.34 tracks/python/exercises/protein-translation/example.py
trackler-2.1.0.33 tracks/python/exercises/protein-translation/example.py