16 May 2023 · filed under Coding challenge

Rosalind: Complementing a Strand of DNA

pythonrosalindbioinformaticsdnastrings

Solution #1

def transcribe(dna):
    for nt in dna:
        if nt == "T":
            yield "U"
        else:
            yield nt
    return "".join(_transcribe(dna))

Solution #2

def transcribe(dna):
    return dna.replace("T", "U")

Solution #3

def transcribe(dna):
    transcriber = str.maketrans("T", "U")
    return dna.translate(transcriber)