Sha256: 1787b20cd02ad1ef77a52b197559319e5955e57ac146d34ca251989fd7189b6e

Contents?: true

Size: 405 Bytes

Versions: 124

Compression:

Stored size: 405 Bytes

Contents

import sys

if sys.version_info[0] == 2:
    from string import maketrans
else:
    maketrans = str.maketrans


DNA_CHARS = 'AGCT'
DNA_TO_RNA = maketrans(DNA_CHARS, 'UCGA')


def to_rna(dna_strand):
    valid_chars = set(DNA_CHARS)
    if any(char not in valid_chars for char in dna_strand):
        raise ValueError("Input DNA strand contains invalid bases")

    return dna_strand.translate(DNA_TO_RNA)

Version data entries

124 entries across 124 versions & 1 rubygems

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