function reverse_complement(s::AbstractString)
= Dict{Char, Char}(
rev_map 'A' => 'T', 'T' => 'A',
'G' => 'C', 'C' => 'G'
)= IOBuffer()
io for char in reverse(s)
write(io, rev_map[char])
end
return String(take!(io))
end
function main()
= readline(ARGS[1])
first_line = reverse_complement(first_line)
output write("output.txt", output)
println(output)
end
main()
Complementing a Strand of DNA
Problem definition
In DNA strings, sysmbols ‘A’ and ‘T’ are complements of each other, as are ‘C’ and ‘G’.
The reverse complement of a DNA string \(s\) is the string \(s^C\) formed by reversing the symbols of \(s\), then taking the complement of each symbol (e.g., the reverse complement of ‘GTCA’ is ‘TGAC’).
Given
A DNA string \(s\) of length at most 1000 base pairs.
Return
The reverse complement \(s^C\) of \(s\).
Sample dataset
AAAACCCGGT
Sample Output
ACCGGGTTTT