Skip to content

Commit aef333f

Browse files
committed
add outer testset to all tests, so we see all errors
1 parent 213f34c commit aef333f

File tree

1 file changed

+138
-135
lines changed

1 file changed

+138
-135
lines changed

test/runtests.jl

Lines changed: 138 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -46,163 +46,129 @@ function gen_kwargs(; use_beamsize=true)
4646
end
4747

4848

49-
@testset "energy" begin
50-
redirect_stdio(stdout=devnull) do
51-
for kwargs in gen_kwargs(use_beamsize=false)
52-
@test energy("GGGAAACCC", "(((...)))"; kwargs...) isa Unitful.Quantity
53-
end
54-
end
55-
end
49+
@testset verbose=true "LinearFold tests" begin
5650

57-
@testset "mfe" begin
58-
seq = "GGGAAACCC"
59-
con = ".?(.??)??"
60-
redirect_stdio(stdout=devnull) do
61-
for kwargs in gen_kwargs()
62-
dG, structure = mfe(seq; kwargs...)
63-
@test dG isa Unitful.Quantity
64-
@test length(structure) == length(seq)
65-
66-
dG, structure = mfe(seq; constraints=con, kwargs...)
67-
@test dG isa Unitful.Quantity
68-
@test length(structure) == length(seq)
51+
@testset "energy" begin
52+
redirect_stdio(stdout=devnull) do
53+
for kwargs in gen_kwargs(use_beamsize=false)
54+
@test energy("GGGAAACCC", "(((...)))"; kwargs...) isa Unitful.Quantity
55+
end
6956
end
7057
end
71-
end
7258

73-
@testset "zuker_subopt" begin
74-
seq = "GGGGGGAAAACCCCCAAAGGGGAAAAACCCCCAAAGGGGG"
75-
76-
redirect_stdio(stdout=devnull) do
77-
for kwargs in gen_kwargs()
78-
n = length(seq)
79-
subopts = zuker_subopt(seq; kwargs...)
80-
@test length(subopts) > 0
81-
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
82-
@test all(x -> length(x[2]) == n, subopts)
83-
84-
subopts = zuker_subopt(seq; delta=10u"kcal/mol", kwargs...)
85-
@test length(subopts) > 0
86-
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
87-
@test all(x -> length(x[2]) == n, subopts)
59+
@testset "mfe" begin
60+
seq = "GGGAAACCC"
61+
con = ".?(.??)??"
62+
redirect_stdio(stdout=devnull) do
63+
for kwargs in gen_kwargs()
64+
dG, structure = mfe(seq; kwargs...)
65+
@test dG isa Unitful.Quantity
66+
@test length(structure) == length(seq)
67+
68+
dG, structure = mfe(seq; constraints=con, kwargs...)
69+
@test dG isa Unitful.Quantity
70+
@test length(structure) == length(seq)
71+
end
8872
end
8973
end
90-
end
9174

92-
@testset "partfn" begin
93-
seq = "GGGAAACCC"
94-
redirect_stdio(stdout=devnull) do
95-
for kwargs in gen_kwargs()
96-
dG = partfn(seq; kwargs...)
97-
@test dG isa Unitful.Quantity
75+
@testset "zuker_subopt" begin
76+
seq = "GGGGGGAAAACCCCCAAAGGGGAAAAACCCCCAAAGGGGG"
77+
78+
redirect_stdio(stdout=devnull) do
79+
for kwargs in gen_kwargs()
80+
n = length(seq)
81+
subopts = zuker_subopt(seq; kwargs...)
82+
@test length(subopts) > 0
83+
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
84+
@test all(x -> length(x[2]) == n, subopts)
85+
86+
subopts = zuker_subopt(seq; delta=10u"kcal/mol", kwargs...)
87+
@test length(subopts) > 0
88+
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
89+
@test all(x -> length(x[2]) == n, subopts)
90+
end
9891
end
9992
end
100-
end
10193

102-
@testset "bpp" begin
103-
seq = "GGGAAACCC"
104-
n = length(seq)
105-
106-
redirect_stdio(stdout=devnull) do
107-
for kwargs in gen_kwargs()
108-
dG, p = bpp(seq; kwargs...)
109-
@test dG isa Unitful.Quantity
110-
@test eltype(p) <: AbstractFloat
111-
@test axes(p) == (1:n, 1:n)
112-
@test all(x -> 0.0 <= x <= 1.0, p)
113-
114-
dG, p = bpp(seq; bpp_cutoff=0.2, kwargs...)
115-
@test dG isa Unitful.Quantity
116-
@test eltype(p) <: AbstractFloat
117-
@test axes(p) == (1:n, 1:n)
118-
@test all(x -> 0.0 <= x <= 1.0, p)
94+
@testset "partfn" begin
95+
seq = "GGGAAACCC"
96+
redirect_stdio(stdout=devnull) do
97+
for kwargs in gen_kwargs()
98+
dG = partfn(seq; kwargs...)
99+
@test dG isa Unitful.Quantity
100+
end
119101
end
120102
end
121-
end
122-
123-
@testset "mea" begin
124-
seq = "GGGAAAACCCC"
125103

126-
redirect_stdio(stdout=devnull) do
127-
for kwargs in gen_kwargs()
128-
dG, structure = mea(seq; kwargs...)
129-
@test dG isa Unitful.Quantity
130-
@test length(structure) == length(seq)
104+
@testset "bpp" begin
105+
seq = "GGGAAACCC"
106+
n = length(seq)
131107

132-
dG, structure = mea(seq; gamma=2.0, kwargs...)
133-
@test dG isa Unitful.Quantity
134-
@test length(structure) == length(seq)
108+
redirect_stdio(stdout=devnull) do
109+
for kwargs in gen_kwargs()
110+
dG, p = bpp(seq; kwargs...)
111+
@test dG isa Unitful.Quantity
112+
@test eltype(p) <: AbstractFloat
113+
@test axes(p) == (1:n, 1:n)
114+
@test all(x -> 0.0 <= x <= 1.0, p)
115+
116+
dG, p = bpp(seq; bpp_cutoff=0.2, kwargs...)
117+
@test dG isa Unitful.Quantity
118+
@test eltype(p) <: AbstractFloat
119+
@test axes(p) == (1:n, 1:n)
120+
@test all(x -> 0.0 <= x <= 1.0, p)
121+
end
135122
end
136123
end
137-
end
138124

139-
@testset "threshknot" begin
140-
seq = "GGGGAAAACCCC"
141-
n = length(seq)
142-
143-
redirect_stdio(stdout=devnull) do
144-
for kwargs in gen_kwargs()
145-
dG, pt = threshknot(seq; kwargs...)
146-
@test dG isa Unitful.Quantity
147-
@test length(pt) == length(seq)
148-
@test eltype(pt) == Int
149-
@test all(i -> 0 <= i <= n, pt)
150-
151-
dG, pt = threshknot(seq; threshold=0.2, kwargs...)
152-
@test dG isa Unitful.Quantity
153-
@test length(pt) == length(seq)
154-
@test eltype(pt) == Int
155-
@test all(i -> 0 <= i <= n, pt)
156-
end
157-
end
158-
end
125+
@testset "mea" begin
126+
seq = "GGGAAAACCCC"
159127

160-
@testset "sample_structures" begin
161-
seq = "GGGAAACC"
162-
nsamples = 20
163-
164-
for opts in Iterators.product(
165-
[nothing, 50],
166-
[nothing, true, false],
167-
[nothing, true, false],
168-
[nothing, true, false])
169-
optnames = [:beamsize, :is_nonsaving, :is_sharpturn, :verbose]
170-
kwargs = NamedTuple()
171-
for (i, name) in enumerate(optnames)
172-
val = opts[i]
173-
if !isnothing(val)
174-
kwargs = NamedTuple((pairs(kwargs)..., name => val))
128+
redirect_stdio(stdout=devnull) do
129+
for kwargs in gen_kwargs()
130+
dG, structure = mea(seq; kwargs...)
131+
@test dG isa Unitful.Quantity
132+
@test length(structure) == length(seq)
133+
134+
dG, structure = mea(seq; gamma=2.0, kwargs...)
135+
@test dG isa Unitful.Quantity
136+
@test length(structure) == length(seq)
175137
end
176138
end
139+
end
140+
141+
@testset "threshknot" begin
142+
seq = "GGGGAAAACCCC"
143+
n = length(seq)
144+
177145
redirect_stdio(stdout=devnull) do
178-
n = length(seq)
179-
samples = sample_structures(seq; kwargs...)
180-
@test length(samples) == 10
181-
@test all(s -> length(s) == n, samples)
182-
183-
samples = sample_structures(seq; num_samples=nsamples, kwargs...)
184-
@test length(samples) == nsamples
185-
@test all(s -> length(s) == n, samples)
146+
for kwargs in gen_kwargs()
147+
dG, pt = threshknot(seq; kwargs...)
148+
@test dG isa Unitful.Quantity
149+
@test length(pt) == length(seq)
150+
@test eltype(pt) == Int
151+
@test all(i -> 0 <= i <= n, pt)
152+
153+
dG, pt = threshknot(seq; threshold=0.2, kwargs...)
154+
@test dG isa Unitful.Quantity
155+
@test length(pt) == length(seq)
156+
@test eltype(pt) == Int
157+
@test all(i -> 0 <= i <= n, pt)
158+
end
186159
end
187160
end
188-
end
189161

162+
@testset "sample_structures" begin
163+
seq = "GGGAAACC"
164+
nsamples = 20
190165

191-
@testset "turbofold" begin
192-
for seqs in [
193-
["GGGAAACC", "GCGAAAAAACGCA"],
194-
["GGGAAACC", "GCGAAAAAACGCA", "CCCCUUUUUGGGGG"]]
195166
for opts in Iterators.product(
196167
[nothing, 50],
197-
[nothing, 50],
198-
[nothing, 2],
199-
[nothing, 4],
200-
[nothing, 2],
201-
[nothing, 0.2],
168+
[nothing, true, false],
169+
[nothing, true, false],
202170
[nothing, true, false])
203-
optnames = [:beamsize_hmm, :beamsize_cky, :iterations,
204-
:threshknot_min_helix_len, :threshknot_iterations, :threshknot_threshold,
205-
:verbose]
171+
optnames = [:beamsize, :is_nonsaving, :is_sharpturn, :verbose]
206172
kwargs = NamedTuple()
207173
for (i, name) in enumerate(optnames)
208174
val = opts[i]
@@ -211,13 +177,50 @@ end
211177
end
212178
end
213179
redirect_stdio(stdout=devnull) do
214-
msa, pts = turbofold(seqs; kwargs...)
215-
@test msa isa Vector{FASTA.Record}
216-
@test pts isa Vector{Vector{Int}}
217-
@test length(msa) == length(seqs)
218-
@test length(pts) == length(seqs)
219-
@test length.(pts) == length.(seqs)
180+
n = length(seq)
181+
samples = sample_structures(seq; kwargs...)
182+
@test length(samples) == 10
183+
@test all(s -> length(s) == n, samples)
184+
185+
samples = sample_structures(seq; num_samples=nsamples, kwargs...)
186+
@test length(samples) == nsamples
187+
@test all(s -> length(s) == n, samples)
220188
end
221189
end
222190
end
191+
192+
@testset "turbofold" begin
193+
for seqs in [
194+
["GGGAAACC", "GCGAAAAAACGCA"],
195+
["GGGAAACC", "GCGAAAAAACGCA", "CCCCUUUUUGGGGG"]]
196+
for opts in Iterators.product(
197+
[nothing, 50],
198+
[nothing, 50],
199+
[nothing, 2],
200+
[nothing, 4],
201+
[nothing, 2],
202+
[nothing, 0.2],
203+
[nothing, true, false])
204+
optnames = [:beamsize_hmm, :beamsize_cky, :iterations,
205+
:threshknot_min_helix_len, :threshknot_iterations, :threshknot_threshold,
206+
:verbose]
207+
kwargs = NamedTuple()
208+
for (i, name) in enumerate(optnames)
209+
val = opts[i]
210+
if !isnothing(val)
211+
kwargs = NamedTuple((pairs(kwargs)..., name => val))
212+
end
213+
end
214+
redirect_stdio(stdout=devnull) do
215+
msa, pts = turbofold(seqs; kwargs...)
216+
@test msa isa Vector{FASTA.Record}
217+
@test pts isa Vector{Vector{Int}}
218+
@test length(msa) == length(seqs)
219+
@test length(pts) == length(seqs)
220+
@test length.(pts) == length.(seqs)
221+
end
222+
end
223+
end
224+
end
225+
223226
end

0 commit comments

Comments
 (0)