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.50 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.49 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.48 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.47 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.46 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.45 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.44 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.43 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.42 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.41 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.40 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.39 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.38 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.37 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.36 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.35 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.34 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.33 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.32 tracks/python/exercises/protein-translation/example.py
trackler-2.2.1.31 tracks/python/exercises/protein-translation/example.py