marcom / viennarna.jl Goto Github PK
View Code? Open in Web Editor NEWJulia interface to ViennaRNA for RNA structure prediction and analysis
License: Other
Julia interface to ViennaRNA for RNA structure prediction and analysis
License: Other
Love the interface of ViennaRNA for Julia. I've just installed it and I am still testing all the functions.
For now I seem unable to run FoldCompound using either of the DNA parameters. All RNA parameters work.
I've gone through the code to see if I could pick any obvious glitches but I cannot find any faults there. I looked through the ViennaRNA package and both are there so I don't fully understand why I am being pushed onto "unknown energy parameters" error.
Following discussion in #7 (comment)
For sliding window predictions on a sequence that produce an array of results instead of just one (one result for each window).
To use windowed predictions we have to do the following:
vrna_fold_compound()
with option VRNA_OPTION_WINDOW
vrna_md_t.window_size
vrna_mfe_window_cb
, vrna_mfe_window_zscore_cb
, vrna_probs_window
A Julia interface could look like this:
mfe_window(cb::Function, fc::FoldCompound, ...)
mfe_window(fc::FoldCompound, ...)
probs_window(cb::Function, fc::FoldCompound, ...)
probs_window(fc::FoldCompound, ...)
With the callback function in the first position so we can use do-notation to pass custom callback functions.
The second version of each function without the callback just stores all the results in an array and returns that (by calling the first version with a callback that pushes each result to an array).
This style of callback function would also be something useful for subopt
, pbacktrack
, and maybe other functions where ViennaRNA accepts callback functions.
See discussion here: #4
What i tried:
Adding the following to plot_structure.jl
:
(adapted from https://github.com/JuliaPlots/Makie.jl/blob/master/src/precompiles.jl )
function _precompile_()
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
plot_structure_makie("(((...)))")
plot_structure_makie("(((...)))"; sequence="GGGAAACCC")
return
end
_precompile_()
Unfortunately the first plot seems to take even longer with this precompile approach (53s vs 45s without).
As mentioned in #4 using the GLMakie & WGLMakie backends also didn't yield an improvment.
The ViennaRNA C API marks deprecated functions with a comment:
// DEPRECATED
This gets converted by Clang.jl to
# DEPRECATED
It would be even better to change this to the @deprecated
macro so that these annotations are visible to Julia.
I don't know how essential the visualization functions are for users of this package, but loading the whole Makie stack regardless if you need that or not is quite expensive. For comparison (timings in a temporary environment after precompilation):
[email protected]:
julia> @time using ViennaRNA
0.185636 seconds (747.30 k allocations: 48.920 MiB, 5.63% gc time, 6.60% compilation time)
[email protected] (includes Luxor):
julia> @time using ViennaRNA
0.700532 seconds (2.55 M allocations: 171.304 MiB, 5.47% gc time, 6.65% compilation time)
[email protected] (includes CairoMakie):
julia> @time using ViennaRNA
4.242130 seconds (14.88 M allocations: 1010.827 MiB, 9.37% gc time, 21.10% compilation time)
I'm happy to spend an Plots.jl recipe, if thats of interest until Makie has lightweight recipes itself, otherwise I'd prefer the visualization stuff to live in a separate package, such that you can use the other functionality without pulling a large amount of dependencies in.
Another alternative would be to use Requires.jl.
Some of these items might already work, but should still get their own testset in the tests/
dir.
See also: #9
pf_window
pf_window_channel
bpp_window
(using vrna_probs_window
)bpp_window_channel
https://github.com/ViennaRNA/ViennaRNA/releases/tag/v2.6.0
Would be nice to have a function which returns the basepair probabilities as a vector so it can be used later to label visualizations with the right colors.
It seems like the RNAFold webserver does this with a perl script which isnt particularly easy to read.
This is the function I came up with:
function bpp_vec(bppm::Matrix{Float64}, dotbracket::String)
double_bppm = transpose(bppm) + bppm
prob_vec = Vector{Float64}(undef, first(size(double_bppm)))
for (i, row) in enumerate(eachrow(double_bppm))
if dotbracket[i] in ('(', ')')
prob_vec[i] = maximum(row)
else
prob_vec[i] = 1 - maximum(row)
end
end
return prob_vec
end
I'm not 100% sure this is the correct way of extracting this information though.
I've also seen that you still have this in your TODO list so I'm not sure if or how this function would work after this change.
Thanks alot for porting the ViennaRNA package to julia btw. ๐. Very nicely done!
Example:
?ViennaRNA.LibRNA.vrna_plot_coords
The docstring is rendered with Markdown, which breaks the formatting, as the ViennaRNA C library doesn't use markdown, e.g. VRNA_PLOT_TYPE_SIMPLE
is rendered as VRNAPLOTTYPE_SIMPLE
.
Solution:
When generating the bindings with Clang.jl (in gen/generator.jl
), either the docstrings should be surrounded by triple backticks (but backticks would still need to be escaped with a backslash inside the string) or somehow else be made 'markdown-safe'.
Segfault:
using ViennaRNA
plot_coords("()") # sometimes doesn't segfault but keeps on going...
plot_coords(Pairtable("()")) # also segfaults
plot_coords("((()))") # also crashes, but in a different way
These work:
using ViennaRNA
plot_coords("")
plot_coords("(.)")
plot_coords("(..)")
plot_coords("(((.)))")
plot_coords("(((..)))")
It crashes on the line
n = _vrna_plot_coords(structure, ptr_cx, ptr_cy, type)
Which in turn calls
LibRNA.vrna_plot_coords(structure, cx, cy, type)
plot_type
Works
plot_coords("()"; plot_type=:simple) # type = 0
plot_coords("()"; plot_type=:naview) # type = 1
plot_coords("()"; plot_type=:circular) # type = 2
Crashes (sometimes also seems to just hang)
plot_coords("()"; plot_type=:turtle) # type = 3
plot_coords("()"; plot_type=:puzzler) # type = 4
I got a project depending on ViennaRNA.jl which fails to precompile (but only in CI jobs) with the following error
โ Error: /root/.julia/artifacts/725e603448ac6c44bfbbf2df16f3225673d1ff38/include/ViennaRNA/utils/structures.h:140:10: fatal error: 'stdio.h' file not found
โ @ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:377
ERROR: LoadError: Errors parsing C code
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] parse!(ctx::CBinding.Context{:c})
@ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:388
[3] clang_str(mod::Module, loc::LineNumberNode, lang::Symbol, str::String, opts::String)
@ CBinding ~/.julia/packages/CBinding/kBUap/src/context.jl:481
[4] var"@c_str"(__source__::LineNumberNode, __module__::Module, exprs::Vararg{Any})
@ CBinding ~/.julia/packages/CBinding/kBUap/src/context_c.jl:5
[5] include
@ ./Base.jl:418 [inlined]
[6] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
@ Base ./loading.jl:1318
[7] top-level scope
@ none:1
[8] eval
@ ./boot.jl:373 [inlined]
[9] eval(x::Expr)
@ Base.MainInclude ./client.jl:453
[10] top-level scope
@ none:1
in expression starting at /root/.julia/packages/ViennaRNA/7mJxT/src/ViennaRNA.jl:21
in expression starting at /root/.julia/packages/ViennaRNA/7mJxT/src/ViennaRNA.jl:1
So it seems this is not really selfcontained and the container is missing some C dependencies, if I understand correctly
Hi again,
Are there any plans to implement a wrapper for alifold?
As I'm not familiar with C, I dont really know where to start but I would be thankful if you could lead me to the right direction.
My current try looks like this
function alifold(sequences::Vector{AbstractString}, structure::AbstractString)
alifold_output = LibRNA.vrna_alifold(sequences, structure)
return alifold_output
end
Is the following needed somehow to
cstr_structure = Ptr{Cchar}(LibRNA.vrna_alloc(length(structure) + 1))
cstr_sequences = Ptr{Ptr{Cchar}}(LibRNA.vrna_alloc(sizeof(Ptr{Cchar})))
I'm almost certain this is not correct though.
Do I also need to write the wrap_alifold function present in alifold.c?
Do I need a specific struct to return the alifold information?
Would be nice to have this implemented and I would like to help if I can.
Greetings,
Timo
This issue is used to trigger TagBot; feel free to unsubscribe.
If you haven't already, you should update your TagBot.yml
to include issue comment triggers.
Please see this post on Discourse for instructions and more details.
If you'd like for me to do this for you, comment TagBot fix
on this issue.
I'll open a PR within a few hours, please be patient!
Is it currently possible to use the modified base energy parameters built in to Vienna 2.6?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.