Kevin Silberberg
  • Home
  • Photos
  • Study

Transcribing DNA into RNA

Author

Kevin Silberberg

Published

March 12, 2025

Problem definition

Write a program

Given: A DNA string \(t\) having length at most 1000 nucleotides

Return: The transcribed RNA string of \(t\).

Sample data

GATGGAACTTGACTACGTAAATT

Sample output

GAUGGAACUUGACUACGUAAAUU

Solution

transcription.jl

transcribe(s::AbstractString) = replace(s, 'T'=>'U')

function main()
    if length(ARGS) < 2
        println("Usage: julia $(Base.PROGRAM_FILE) <fineIN> <fileOUT>")
        exit(1)
    end

    s = read(ARGS[1], String)

    open(ARGS[2], "w") do file
        println(file, transcribe(s))
    end
    exit(0)
end

main()

We use the in-built function replace which takes in a collection and for each pair old=>new returns a copy of the collection where all occurances of old are replaced by new.

© Copyright 2025 Kevin Silberberg. Except where otherwise noted, all text and images licensed CC-BY-NC 4.0.