Skip to content

Commit 7048864

Browse files
committed
mea: remove trailing \r on windows, add some tests
1 parent cbbf28f commit 7048864

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/LinearFold.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ function mea(seq::AbstractString;
506506
cmd = cmd_linearpartition(; model, verbose, beamsize,
507507
is_sharpturn, mea=true, gamma)
508508
out, err = run_cmd(cmd, seq; verbose)
509-
structure = String(split(out, '\n')[2])
509+
structure = String(strip(split(out, '\n')[2]))
510510
dG_ensemble = parse_energy(err)
511511
return dG_ensemble, structure
512512
end

test/runtests.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,16 @@ end
7575

7676
redirect_stdio(stdout=devnull) do
7777
for kwargs in gen_kwargs()
78+
n = length(seq)
7879
subopts = zuker_subopt(seq; kwargs...)
7980
@test length(subopts) > 0
8081
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
82+
@test all(x -> length(x[2]) == n, subopts)
8183

8284
subopts = zuker_subopt(seq; delta=10u"kcal/mol", kwargs...)
8385
@test length(subopts) > 0
8486
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
87+
@test all(x -> length(x[2]) == n, subopts)
8588
end
8689
end
8790
end
@@ -135,18 +138,21 @@ end
135138

136139
@testset "threshknot" begin
137140
seq = "GGGGAAAACCCC"
141+
n = length(seq)
138142

139143
redirect_stdio(stdout=devnull) do
140144
for kwargs in gen_kwargs()
141145
dG, pt = threshknot(seq; kwargs...)
142146
@test dG isa Unitful.Quantity
143147
@test length(pt) == length(seq)
144148
@test eltype(pt) == Int
149+
@test all(i -> 0 <= i <= n, pt)
145150

146151
dG, pt = threshknot(seq; threshold=0.2, kwargs...)
147152
@test dG isa Unitful.Quantity
148153
@test length(pt) == length(seq)
149154
@test eltype(pt) == Int
155+
@test all(i -> 0 <= i <= n, pt)
150156
end
151157
end
152158
end
@@ -169,13 +175,14 @@ end
169175
end
170176
end
171177
redirect_stdio(stdout=devnull) do
178+
n = length(seq)
172179
samples = sample_structures(seq; kwargs...)
173180
@test length(samples) == 10
174-
@test all(s -> length(s) == length(seq), samples)
181+
@test all(s -> length(s) == n, samples)
175182

176183
samples = sample_structures(seq; num_samples=nsamples, kwargs...)
177184
@test length(samples) == nsamples
178-
@test all(s -> length(s) == length(seq), samples)
185+
@test all(s -> length(s) == n, samples)
179186
end
180187
end
181188
end

0 commit comments

Comments
 (0)