RNA Transcription

Given a DNA strand, return its RNA complement (per RNA transcription).

Both DNA and RNA strands are a sequence of nucleotides.

The four nucleotides found in DNA are adenine (A), cytosine (C), guanine (G) and thymine (T).

The four nucleotides found in RNA are adenine (A), cytosine (C), guanine (G) and uracil (U).

Given a DNA strand, its transcribed RNA strand is formed by replacing each nucleotide with its complement:

  • G -> C
  • C -> G
  • T -> A
  • A -> U ## Source

Hyperphysics http://hyperphysics.phy-astr.gsu.edu/hbase/Organic/transcription.html

Version compatibility

This exercise has been tested on Julia versions >=1.0.

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Your solution


In [ ]:
# submit
function to_rna(dna::AbstractString)

end

Test suite


In [ ]:
using Test

# include("rna-transcription.jl")

@testset "basic transformations" begin
    @testset "rna complement of cytosine is guanine" begin
      @test to_rna("C") == "G"
    end

    @testset "rna complement of guanine is cytosine" begin
      @test to_rna("G") == "C"
    end

    @testset "rna complement of thymine is adenine" begin
      @test to_rna("T") == "A"
    end

    @testset "rna complement of adenine is uracil" begin
      @test to_rna("A") == "U"
    end
end

@testset "rna complement" begin
    @test to_rna("ACGTGGTCTTAA") == "UGCACCAGAAUU"
end

@testset "error handling" begin
    @testset "dna correctly handles invalid input" begin
      @test_throws ErrorException to_rna("U")
    end

    @testset "dna correctly handles completely invalid input" begin
      @test_throws ErrorException to_rna("XXX")
    end

    @testset "dna correctly handles partially invalid input" begin
      @test_throws ErrorException to_rna("ACGTXXXCTTAA")
    end
end

Prepare submission

To submit your exercise, you need to save your solution in a file called rna-transcription.jl before using the CLI. You can either create it manually or use the following functions, which will automatically write every notebook cell that starts with # submit to the file rna-transcription.jl.


In [ ]:
# using Pkg; Pkg.add("Exercism")
# using Exercism
# Exercism.create_submission("rna-transcription")