Skip to content

Commit

Permalink
mea: remove trailing \r on windows, add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcom committed Nov 28, 2022
1 parent cbbf28f commit 7048864
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/LinearFold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ function mea(seq::AbstractString;
cmd = cmd_linearpartition(; model, verbose, beamsize,
is_sharpturn, mea=true, gamma)
out, err = run_cmd(cmd, seq; verbose)
structure = String(split(out, '\n')[2])
structure = String(strip(split(out, '\n')[2]))
dG_ensemble = parse_energy(err)
return dG_ensemble, structure
end
Expand Down
11 changes: 9 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ end

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

subopts = zuker_subopt(seq; delta=10u"kcal/mol", kwargs...)
@test length(subopts) > 0
@test subopts isa Vector{Tuple{typeof(1.0u"kcal/mol"),String}}
@test all(x -> length(x[2]) == n, subopts)
end
end
end
Expand Down Expand Up @@ -135,18 +138,21 @@ end

@testset "threshknot" begin
seq = "GGGGAAAACCCC"
n = length(seq)

redirect_stdio(stdout=devnull) do
for kwargs in gen_kwargs()
dG, pt = threshknot(seq; kwargs...)
@test dG isa Unitful.Quantity
@test length(pt) == length(seq)
@test eltype(pt) == Int
@test all(i -> 0 <= i <= n, pt)

dG, pt = threshknot(seq; threshold=0.2, kwargs...)
@test dG isa Unitful.Quantity
@test length(pt) == length(seq)
@test eltype(pt) == Int
@test all(i -> 0 <= i <= n, pt)
end
end
end
Expand All @@ -169,13 +175,14 @@ end
end
end
redirect_stdio(stdout=devnull) do
n = length(seq)
samples = sample_structures(seq; kwargs...)
@test length(samples) == 10
@test all(s -> length(s) == length(seq), samples)
@test all(s -> length(s) == n, samples)

samples = sample_structures(seq; num_samples=nsamples, kwargs...)
@test length(samples) == nsamples
@test all(s -> length(s) == length(seq), samples)
@test all(s -> length(s) == n, samples)
end
end
end
Expand Down

0 comments on commit 7048864

Please sign in to comment.