From 187fe55e667b69f243aeebeedbed4d47d20dbc38 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Tue, 27 Jun 2023 12:28:38 +0200 Subject: [PATCH 1/3] Use Artifacts.toml to access VARNA jar file --- Artifacts.toml | 7 +++++++ Project.toml | 3 +-- src/varna.jl | 25 ++++--------------------- 3 files changed, 12 insertions(+), 23 deletions(-) create mode 100644 Artifacts.toml diff --git a/Artifacts.toml b/Artifacts.toml new file mode 100644 index 0000000..247ee5e --- /dev/null +++ b/Artifacts.toml @@ -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" diff --git a/Project.toml b/Project.toml index 6468dae..ce197c0 100644 --- a/Project.toml +++ b/Project.toml @@ -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" @@ -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" diff --git a/src/varna.jl b/src/varna.jl index 6985178..a1ac739 100644 --- a/src/varna.jl +++ b/src/varna.jl @@ -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( @@ -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 @@ -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)))")) From 5837f5f8d48f6006d494789fc179d40c07273a37 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Tue, 27 Jun 2023 12:48:06 +0200 Subject: [PATCH 2/3] Have to use LazyArtifacts for a lazy artifact --- Project.toml | 2 +- src/varna.jl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index ce197c0..b13adcc 100644 --- a/Project.toml +++ b/Project.toml @@ -6,8 +6,8 @@ version = "0.3.0" [deps] BioStockholm = "eeb925a3-6f9d-43e6-829e-e0ea03b76ecf" ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" +LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3" 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" diff --git a/src/varna.jl b/src/varna.jl index a1ac739..7ac10c4 100644 --- a/src/varna.jl +++ b/src/varna.jl @@ -5,7 +5,8 @@ module VARNA # `-foo` : error, no argument for option foo # `-foo bar` : no error or warning -using Pkg.Artifacts: @artifact_str +# TODO, this doesn't work: using LazyArtifacts: @artifact_str +using LazyArtifacts _get_varna_jar() = artifact"VARNAv3-93_jar/VARNAv3-93.jar" # VARNA-3.93 supported formats: JPEG,PNG,EPS,XFIG,SVG From f22ff3ee1160b1d57fb286dc315739f2761eef6e Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Tue, 27 Jun 2023 13:01:29 +0200 Subject: [PATCH 3/3] Improve README for java and artifacts instructions --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 98275d4..903b382 100644 --- a/README.md +++ b/README.md @@ -109,14 +109,14 @@ VARNA.plot_compare(dbn1="(((.....)))", seq1="GCGAAAAACGC", You will need a working Java installation (can be headless i think). You can test this by running: ```julia -run(`java -version`) +Sys.which("java") ``` -If you don't get an error, plotting with VARNA should work. +If you get a file path (e.g. `"/usr/bin/java"`) and not `nothing`, +plotting with VARNA should work. The VARNA jar file will get downloaded automatically the first time -you plot something with VARNA. It gets stored in a scratch space that -gets cleaned up by the Julia package manager when you uninstall -PlotRNA. +you plot something with one of the VARNA functions. It gets stored in +the Julia artifacts directory. #### VARNA plot options