Sequence
2 problems from Rosalind — Bioinformatics Armory. Press Run on any block to execute it in your browser.
INI — Introduction to the Bioinformatics Armory
solvedbrowser + CLI Problem statement Open in the workbench Download .bl
# Rosalind: INI — Introduction to the Bioinformatics Armory
# https://rosalind.info/problems/ini/
#
# Given: A DNA string s of length at most 1000 bp.
# Return: Four integers separated by spaces counting A, C, G, T occurrences.
let s = dna"AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"
let counts = base_counts(s)
let result = str(counts.A) + " " + str(counts.C) + " " + str(counts.G) + " " + str(counts.T)
println("Result: " + result)
println("Expected: 20 12 17 21")
println("Match: " + str(result == "20 12 17 21"))
fn test_ini_base_counts() {
assert result == "20 12 17 21", "INI: expected '20 12 17 21', got '" + result + "'"
}
RVCO — Complementing a Strand of DNA
solvedbrowser + CLI Problem statement Open in the workbench Download .bl
# Rosalind: RVCO — Complementing a Strand of DNA
# https://rosalind.info/problems/rvco/
#
# Given: A collection of n (n <= 10) DNA strings.
# Return: The number of strings that match their own reverse complement.
let sequences = [
dna"ATAT",
dna"GCATA"
]
let palindrome_count = 0
for seq in sequences {
let rc = reverse_complement(seq)
if str(seq) == str(rc) then
palindrome_count = palindrome_count + 1
}
println("Result: " + str(palindrome_count))
println("Expected: 1")
println("Match: " + str(palindrome_count == 1))
# Verify: ATAT -> rev_comp = ATAT (palindrome), GCATA -> rev_comp = TATGC (not)
println("\nDetail:")
for seq in sequences {
let rc = reverse_complement(seq)
let is_palindrome = str(seq) == str(rc)
println(" " + str(seq) + " -> rc=" + str(rc) + " palindrome=" + str(is_palindrome))
}
fn test_rvco_palindrome_count() {
assert palindrome_count == 1, "RVCO: expected 1, got " + str(palindrome_count)
}