From 75ecd1c0c1b6b46f54568725045382fd68b4945e Mon Sep 17 00:00:00 2001 From: Marco Matthies Date: Sat, 3 Dec 2022 23:48:50 +0100 Subject: [PATCH] rename R2R.R2Rplot => R2R.Plot, r2r() => run_r2r() --- src/r2r.jl | 22 +++++++++++----------- test/r2r.jl | 7 +++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/r2r.jl b/src/r2r.jl index 351a2bd..c8a0146 100644 --- a/src/r2r.jl +++ b/src/r2r.jl @@ -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 diff --git a/test/r2r.jl b/test/r2r.jl index cca9ffb..54ace48 100644 --- a/test/r2r.jl +++ b/test/r2r.jl @@ -1,7 +1,6 @@ using Test using PlotRNA: R2R using BioStockholm: MSA -using PlotRNA.R2R: R2Rplot const R2R_MSA = [ parse(MSA, @@ -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