-
Notifications
You must be signed in to change notification settings - Fork 0
/
motifsearch.jl
32 lines (26 loc) · 1.5 KB
/
motifsearch.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Finding a Motif in DNA
motifsearch(s::String, t::String) -> Array
Finds the locations of a motif `t` in nucleotide sequence `s`.
# Arguments
- `s::String`: a DNA string.
- `t::String`: a DNA string.
# Returns
- `Array`: all locations of `t` as a substring of `s`.
"""
function motifsearch(s::String, t::String)
locations = []
for i in 1:length(s)-length(t)+1
if s[i:i+length(t)-1] == t
push!(locations, i)
end
end
return locations
end
"""
s = "ATACACCACACACCACACCACGACCACACGCACCACACTACCACACAACCACACGCCCTACCACACACCACACCCGACCACACCGCATATTAGACCACACGACCACACACCACACTACCACACCCAGAACCACACCTACCACACTACCACACACCACACAACCACACGGACCACACTACATTAACCACACCTCGGACCACACACCACACTACCACACGCACGCCGTCGTCACCACACCGCATCACCACACTACCACACTGGCAACCACACCACCCTACCACACCGACCACACGTACCACACTACGACCACACAACCACACGGACCACACTGACTCTACCACACAACCACACATACCACACTACCACACGACCACACCGCCAACCACACACACTAACCACACACCACACACCACACGAGGAGGCACAAGACCACACCAAGGAGCGAGGACCACACACCACACGAACCACACACCACACAAAACCACACTTTTTACCACACACCACACATTATCACCACACACCACACTGGCGTACCACACAGCACCACACTACCACACGACCACACACCACACGACCACACCGGCTTACATACCACACAGGGACCACACACCACACGTCACCACACATCACCACACGGAACCACACTTCGCTTAGACCACACAACCACACGATGGACCACACTGCTGACCACACCACTACCACACACCACACCACCACACACCACACACCACACTCGCTTACCACACCTAAGGGTTTTGACCACACACCACACGAACCACACCACCACACACCACACACCACACTGGTACCACACTCACCACACACCACACCACACCACACGACCACACCAACACGACCACACACCACACGTACCACACAGACCACACACCACACTGGAAACCACACTACCACACAAAGACCACACCCGACACCACACTCGACCACACACCACACACCACAC"
t = "ACCACACAC"
for i in motifsearch(s, t)
print(i, " ")
end
"""