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.139 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.138 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.137 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.136 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.135 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.134 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.133 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.132 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.131 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.130 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.129 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.128 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.127 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.126 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.125 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.124 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.123 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.122 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.121 tracks/python/exercises/rna-transcription/example.py
trackler-2.2.1.120 tracks/python/exercises/rna-transcription/example.py