-
Notifications
You must be signed in to change notification settings - Fork 0
/
complement.jl
22 lines (17 loc) · 1.37 KB
/
complement.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""
Complementing a Strand of DNA
complement(s::String) -> String
Given: A DNA string `s` of length at most 1000 bp.
Return: The reverse complement `sc` of `s`.
# Arguments
- `s::String`: a DNA string
"""
function complement(s::String)
pairs = Dict('A' => 'T', 'T' => 'A', 'C' => 'G', 'G' => 'C')
sc = ""
for base in reverse(s)
sc *= pairs[base]
end
return sc
end
println(complement("GAGTCGCTGGGCTCCAGGATTCCAAGAGGTCACAGACCTGTCCTGGCTAGGGGACAAACGTCACGCTTTGGCTCCTAGAACGTACGGCACATGTAGAAATTCCGCCCATGGATTCGAGAGATGCCATCTTTCCACCAAATCCGGAAATAAGCGCCTCCGCCAGGATCTGTACGAAATTAATCATCGGTATAGAGGGGACGTACCCTGGGTTACGATATCACACACTTTGTTAGCCGATCCTCCCCTCCCCAGCGTAAGCTTGCCGGACTCGTTAGCGCACTGATACTATACCTAATAGAGTGTTATAGATGCGCCAAGGTTTAGTTATAGCCCGCGACTGACTGTTCCACCATTCTTGTAACCGGCTGCCCAACATTATATGTCGCGATTATCGCCTTGCTGGTACACGTGTCCGCGGATTGAGTGGAGCCGATGCAGGTTTTCAATCGTAGGTTGATTACGATTTGTGTGGGTGTTTGCTGTATTTTTGCAACAAGTTCAACCAGTCGCCATGAACCACCGTATCAGGACGCGTGCCCGTCTTGTCTTTCGACATATCGCGGTTGAGCACTCGCGGCCGAAAGGAGTCTCGTATTGTAAAACTGGTGAGCACTCCGTTGACGCCAACTCGGTTTCGGTCCTGACCGGCCACATTGATTCACGAGAGGGTATGCGCTCTCTGCAAGGGCACTTCTTGATGCGGGAGGAATGTGTATGTAATCAGGGGATGCCCCCAGGCGACCTGTTGTCGGGAGACTATTTGTCATGTGCTTGGTTCCTGCCTAGGGTCAGATAAAACCGGCCCAACTGAGAGTGATTGTCCCGGCTAAACAAATAGCAGTACACGTCTTATTTTTAATTGCAACTTTGACCCGAAATAGTTTCTATCACCAGGTACTTTCCGAGTCCTGCGGAAGTGCATTTCTGGATGCGGTTTTGTTGTTAGAAATAAAAAAGATTGGTGGCCTTGTCCAGAATT"))