Skip to content

Commit

Permalink
Use Artifacts.toml to access VARNA jar file
Browse files Browse the repository at this point in the history
  • Loading branch information
marcom committed Jun 27, 2023
1 parent 7c2755d commit 187fe55
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
7 changes: 7 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[VARNAv3-93_jar]
git-tree-sha1 = "7141dcd09e8fced75b19ca928bd4a790af61ffc2"
lazy = true

[[VARNAv3-93_jar.download]]
sha256 = "58e19c60214ca15f8aefe91ba0feafde3c21b2f30700d8b5b718a3c5bf7aaa5d"
url = "https://gist.github.com/marcom/e9f305a65fc6fbd0fef6df2d66d92f88/raw/7141dcd09e8fced75b19ca928bd4a790af61ffc2.tar.gz"
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ version = "0.3.0"
BioStockholm = "eeb925a3-6f9d-43e6-829e-e0ea03b76ecf"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
R2R_jll = "1e27f72a-4876-5c10-8678-3341fdb8ba55"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
ViennaRNA = "05a721ad-238d-4945-8c85-8b5c1fff3465"

Expand All @@ -31,7 +31,6 @@ Luxor = "3.3"
PrecompileTools = "1"
R2R_jll = "=1.0.6"
Requires = "1.3"
Scratch = "1.1"
UnicodePlots = "3"
ViennaRNA = "0.11"
julia = "1.6"
Expand Down
25 changes: 4 additions & 21 deletions src/varna.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,8 @@ module VARNA
# `-foo` : error, no argument for option foo
# `-foo bar` : no error or warning

using Scratch: @get_scratch!

const _download_url = "https://varna.lri.fr/bin/VARNAv3-93.jar"

# this will be filled in by `__init__()`
_download_cache = ""

function __init__()
global _download_cache = @get_scratch!("jar")
end

function _download_varna_jar(url=_download_url)
fname = joinpath(_download_cache, basename(url))
if !isfile(fname)
@info "downloading VARNA jar file from $url"
download(url, fname)
end
return fname
end
using Pkg.Artifacts: @artifact_str
_get_varna_jar() = artifact"VARNAv3-93_jar/VARNAv3-93.jar"

# VARNA-3.93 supported formats: JPEG,PNG,EPS,XFIG,SVG
const _map_fileendings_to_mime = Dict(
Expand Down Expand Up @@ -187,7 +170,7 @@ function plot(dbn::AbstractString;
fileformat::AbstractString="svg",
verbose::Bool=false,
plot_opts...)
varna_jarpath = _download_varna_jar()
varna_jarpath = _get_varna_jar()
if length(dbn) != length(seq)
throw(ArgumentError("structure and sequence must have same length: $(length(dbn)) != $(length(seq))"))
end
Expand Down Expand Up @@ -226,7 +209,7 @@ function plot_compare(; dbn1::AbstractString,
fileformat::AbstractString="svg",
verbose::Bool=false,
plot_opts...)
varna_jarpath = _download_varna_jar()
varna_jarpath = _get_varna_jar()
if length(dbn1) != length(dbn2) || length(dbn1) != length(seq1) || length(dbn1) != length(seq2)
throw(ArgumentError("all structures and sequences must have same length, here they are: " *
"dbn1=$(length(dbn1)), seq1=$(length(seq1)), dbn2=$(length(dbn2)), seq2=$(length(seq2)))"))
Expand Down

0 comments on commit 187fe55

Please sign in to comment.