Sequence

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

BA1C — Find the Reverse Complement of a String

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

# Rosalind: BA1C — Find the Reverse Complement of a String
# https://rosalind.info/problems/ba1c/
#
# Given: A DNA string Pattern.
# Return: The reverse complement of Pattern.

let pattern = dna"AAAACCCGGT"

let result = str(reverse_complement(pattern))

println("Result:   " + result)
println("Expected: ACCGGGTTTT")

fn test_ba1c_reverse_complement() {
    assert result == "ACCGGGTTTT", "BA1C: got " + result
}

BA1G — Compute the Hamming Distance Between Two Strings

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

# Rosalind: BA1G — Compute the Hamming Distance Between Two Strings
# https://rosalind.info/problems/ba1g/
#
# Given: Two strings of equal length.
# Return: Their Hamming distance.

let p = "GGGCCGTTGGT"
let q = "GGACCGTTGAC"

let result = hamming_distance(p, q)

println("Result:   " + str(result))
println("Expected: 3")

fn test_ba1g_hamming_distance() {
    assert result == 3, "BA1G: got " + str(result)
}