-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathAlphabet.jl
70 lines (52 loc) · 2.34 KB
/
Alphabet.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@testset "Alphabet" begin
@testset "Creation, Iteration and getindex" begin
# Creation & Iteration
@test [ i for i in UngappedAlphabet() ] == Int[ i for i in 1:20 ]
@test [ i for i in GappedAlphabet() ] == Int[ i for i in 1:21 ]
@test [ i for i in ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP") ] ==
Int[ i for i in 1:8 ]
end
@testset "getindex and names" begin
reduced = ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP")
strings = ["AILMV", "NQST", "RHK", "DE", "FWY", "C", "G", "P"]
@test length(reduced) == length(strings)
@test names(reduced) == strings
for i in 1:length(reduced)
@test reduced[strings[i]] == i
end
strings_gapped = ["A","R","N","D","C","Q","E","G","H","I","L","K","M","F","P","S",
"T","W","Y","V","-"]
@test names(GappedAlphabet()) == strings_gapped
@test names(UngappedAlphabet()) == strings_gapped[1:end-1]
for i in 1:20
@test UngappedAlphabet()[strings_gapped[i]] == i
@test GappedAlphabet()[strings_gapped[i]] == i
end
@test GappedAlphabet()["-"] == 21
@test UngappedAlphabet()["-"] == 22
end
@testset "in" begin
# Creation & Iteration
@test in(Residue('A'), UngappedAlphabet())
@test in(Residue('A'), GappedAlphabet())
@test in(Residue('A'), ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP"))
@test !in(GAP, UngappedAlphabet())
@test in(GAP, GappedAlphabet())
@test !in(GAP, ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP"))
@test !in(XAA, UngappedAlphabet())
@test !in(XAA, GappedAlphabet())
@test !in(XAA, ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP"))
end
@testset "Show" begin
tmp = IOBuffer()
show(tmp, UngappedAlphabet())
@test String(take!(tmp)) ==
"MIToS.MSA.UngappedAlphabet of length 20. Residues : res\"ARNDCQEGHILKMFPSTWYV\""
show(tmp, GappedAlphabet())
@test String(take!(tmp)) ==
"MIToS.MSA.GappedAlphabet of length 21. Residues : res\"ARNDCQEGHILKMFPSTWYV-\""
show(tmp, ReducedAlphabet("(AILMV)(NQST)(RHK)(DE)(FWY)CGP"))
@test String(take!(tmp)) ==
"MIToS.MSA.ReducedAlphabet of length 8 : \"(AILMV)(NQST)(RHK)(DE)(FWY)CGP\""
end
end