Skip to content

Commit 8f47384

Browse files
authored
Use Artifacts.toml to access VARNA jar file (#12)
* Use Artifacts.toml to access VARNA jar file * Have to use LazyArtifacts for a lazy artifact * Improve README for java and artifacts instructions
1 parent 7c2755d commit 8f47384

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

Artifacts.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[VARNAv3-93_jar]
2+
git-tree-sha1 = "7141dcd09e8fced75b19ca928bd4a790af61ffc2"
3+
lazy = true
4+
5+
[[VARNAv3-93_jar.download]]
6+
sha256 = "58e19c60214ca15f8aefe91ba0feafde3c21b2f30700d8b5b718a3c5bf7aaa5d"
7+
url = "https://gist.github.com/marcom/e9f305a65fc6fbd0fef6df2d66d92f88/raw/7141dcd09e8fced75b19ca928bd4a790af61ffc2.tar.gz"

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ version = "0.3.0"
66
[deps]
77
BioStockholm = "eeb925a3-6f9d-43e6-829e-e0ea03b76ecf"
88
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
9+
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
910
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
1011
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
1112
R2R_jll = "1e27f72a-4876-5c10-8678-3341fdb8ba55"
1213
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
13-
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1414
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1515
ViennaRNA = "05a721ad-238d-4945-8c85-8b5c1fff3465"
1616

@@ -31,7 +31,6 @@ Luxor = "3.3"
3131
PrecompileTools = "1"
3232
R2R_jll = "=1.0.6"
3333
Requires = "1.3"
34-
Scratch = "1.1"
3534
UnicodePlots = "3"
3635
ViennaRNA = "0.11"
3736
julia = "1.6"

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ VARNA.plot_compare(dbn1="(((.....)))", seq1="GCGAAAAACGC",
109109
You will need a working Java installation (can be headless i think).
110110
You can test this by running:
111111
```julia
112-
run(`java -version`)
112+
Sys.which("java")
113113
```
114-
If you don't get an error, plotting with VARNA should work.
114+
If you get a file path (e.g. `"/usr/bin/java"`) and not `nothing`,
115+
plotting with VARNA should work.
115116

116117
The VARNA jar file will get downloaded automatically the first time
117-
you plot something with VARNA. It gets stored in a scratch space that
118-
gets cleaned up by the Julia package manager when you uninstall
119-
PlotRNA.
118+
you plot something with one of the VARNA functions. It gets stored in
119+
the Julia artifacts directory.
120120

121121

122122
#### VARNA plot options

src/varna.jl

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,9 @@ module VARNA
55
# `-foo` : error, no argument for option foo
66
# `-foo bar` : no error or warning
77

8-
using Scratch: @get_scratch!
9-
10-
const _download_url = "https://varna.lri.fr/bin/VARNAv3-93.jar"
11-
12-
# this will be filled in by `__init__()`
13-
_download_cache = ""
14-
15-
function __init__()
16-
global _download_cache = @get_scratch!("jar")
17-
end
18-
19-
function _download_varna_jar(url=_download_url)
20-
fname = joinpath(_download_cache, basename(url))
21-
if !isfile(fname)
22-
@info "downloading VARNA jar file from $url"
23-
download(url, fname)
24-
end
25-
return fname
26-
end
8+
# TODO, this doesn't work: using LazyArtifacts: @artifact_str
9+
using LazyArtifacts
10+
_get_varna_jar() = artifact"VARNAv3-93_jar/VARNAv3-93.jar"
2711

2812
# VARNA-3.93 supported formats: JPEG,PNG,EPS,XFIG,SVG
2913
const _map_fileendings_to_mime = Dict(
@@ -187,7 +171,7 @@ function plot(dbn::AbstractString;
187171
fileformat::AbstractString="svg",
188172
verbose::Bool=false,
189173
plot_opts...)
190-
varna_jarpath = _download_varna_jar()
174+
varna_jarpath = _get_varna_jar()
191175
if length(dbn) != length(seq)
192176
throw(ArgumentError("structure and sequence must have same length: $(length(dbn)) != $(length(seq))"))
193177
end
@@ -226,7 +210,7 @@ function plot_compare(; dbn1::AbstractString,
226210
fileformat::AbstractString="svg",
227211
verbose::Bool=false,
228212
plot_opts...)
229-
varna_jarpath = _download_varna_jar()
213+
varna_jarpath = _get_varna_jar()
230214
if length(dbn1) != length(dbn2) || length(dbn1) != length(seq1) || length(dbn1) != length(seq2)
231215
throw(ArgumentError("all structures and sequences must have same length, here they are: " *
232216
"dbn1=$(length(dbn1)), seq1=$(length(seq1)), dbn2=$(length(dbn2)), seq2=$(length(seq2)))"))

0 commit comments

Comments
 (0)