Translation

2 problems from Rosalind — Bioinformatics Stronghold. Press Run on any block to execute it in your browser.

PROT — Translating RNA into Protein

solvedbrowser + CLI Problem statement Open in the workbench Download .bl

Sixty-four codons encode twenty amino acids and a stop, so the code is degenerate and translation discards information. MRNA counts exactly how much.

# Rosalind: PROT — Translating RNA into Protein
# https://rosalind.info/problems/prot/
#
# Given: An RNA string s corresponding to a strand of mRNA.
# Return: The protein string encoded by s.

let s = rna"AUGGCCAUGGCGCCCAGAACUGAGAUCAAUAGUACCCGUAUUAACGGGUGA"

# translate() stops at the first stop codon, which is what the problem asks for.
let peptide = translate(s)

println("Result:   " ++ str(peptide))
println("Expected: MAMAPRTEINSTRING")

fn test_prot_translation() {
    assert str(peptide) == "MAMAPRTEINSTRING", "PROT: got " ++ str(peptide)
}

SPLC — RNA Splicing

solvedbrowser + CLI Problem statement Open in the workbench Download .bl

What RNA glossed over. A eukaryotic gene is not a contiguous coding sequence — introns are cut out before translation, so the protein comes from the exons joined together. Removing the introns first is the difference between the right protein and nonsense.

# Rosalind: SPLC — RNA Splicing
# https://rosalind.info/problems/splc/
#
# Given: A DNA string s and a collection of introns, all in FASTA format.
# Return: The protein string translated from the exons of s.

let pre_mrna = "ATGGTCTACATAGCTGACAAACAGCACGTAGCAATCGGTCGAATCTCGAGAGGCATATGGTCACATGATCGGTCGAGCGTGTTTCAAAGTTTGCGCCTAG"
let introns = [
    "ATCGGTCGAA",
    "ATCGGTCGAGCGTGT"
]

# Remove each intron once, in the order given, then translate what is left.
let coding = introns |> reduce(|seq, intron| replace(seq, intron, ""), pre_mrna)
let peptide = translate(dna(coding))

println("Result:   " ++ str(peptide))
println("Expected: MVYIADKQHVASREAYGHMFKVCA")

fn test_splc_rna_splicing() {
    assert str(peptide) == "MVYIADKQHVASREAYGHMFKVCA", "SPLC: got " ++ str(peptide)
}