Skip to content

Commit

Permalink
rename R2R.R2Rplot => R2R.Plot, r2r() => run_r2r()
Browse files Browse the repository at this point in the history
  • Loading branch information
marcom committed Dec 3, 2022
1 parent 700e9a1 commit 75ecd1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
22 changes: 11 additions & 11 deletions src/r2r.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,35 @@ function _runcmd(cmd::Cmd)
return exitcode, out, err
end

struct R2Rplot
struct Plot
svg::String
end

function Base.showable(mime::Type{T}, p::R2Rplot) where {T <: MIME}
function Base.showable(mime::Type{T}, p::Plot) where {T <: MIME}
if mime === MIME"image/svg+xml"
return true
end
return false
end

function Base.show(io::IO, mime::MIME"image/svg+xml", p::R2Rplot)
function Base.show(io::IO, mime::MIME"image/svg+xml", p::Plot)
# TODO: why doesn't the following signature work? claims there is
# no method to call for MIME"image/svg+xml", but
# MIME"image/svg+xml" <: MIME ???
# function Base.show(io::IO, mime::T, p::R2Rplot) where {T <: MIME}
# function Base.show(io::IO, mime::T, p::Plot) where {T <: MIME}
println(io, p.svg)
end

function plot(msa::MSA; kwargs...)
ps, res, out, err = r2r(msa; kwargs...)
return R2Rplot(res)
ps, res, out, err = run_r2r(msa; kwargs...)
return Plot(res)
end

function r2r(msa::MSA;
GSC_weighted_consensus::Bool = true,
identity_levels = [0.97, 0.9, 0.75],
present_levels = [0.97, 0.9, 0.75, 0.5],
max_noncanon::Real = 0.1)
function run_r2r(msa::MSA;
GSC_weighted_consensus::Bool = true,
identity_levels = [0.97, 0.9, 0.75],
present_levels = [0.97, 0.9, 0.75, 0.5],
max_noncanon::Real = 0.1)
# TODO
# - output file type: svg or pdf
# - assertions on identity_levels, present_levels, max_noncanon
Expand Down
7 changes: 3 additions & 4 deletions test/r2r.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Test
using PlotRNA: R2R
using BioStockholm: MSA
using PlotRNA.R2R: R2Rplot

const R2R_MSA = [
parse(MSA,
Expand All @@ -17,17 +16,17 @@ MSA{Char}(; seq = Dict("a" => "GAAAC", "b" => "UAAAA"),
GC = Dict("SS_cons" => "<...>")),
]

@testset "R2R.r2r" begin
@testset "R2R.run_r2r" begin
showtestset()
Tres = Tuple{Int, String, String, String}
for msa in R2R_MSA
@test R2R.r2r(msa) isa Tres
@test R2R.run_r2r(msa) isa Tres
end
end

@testset "R2R.plot" begin
showtestset()
Tres = R2Rplot
Tres = R2R.Plot
for msa in R2R_MSA
@test R2R.plot(msa) isa Tres
end
Expand Down

0 comments on commit 75ecd1c

Please sign in to comment.