ViennaRNA / ViennaRNA

The ViennaRNA Package
Other
303 stars 78 forks source link

Change salt concentration, and increase job numbers using python viennaRNA distribution: #218

Closed MathiasCharconnet closed 2 months ago

MathiasCharconnet commented 11 months ago

Contact Details

mathias.charconnet@live.fr

What happened?

Hi,

I have been using viennaRNA using sourcecode and python, and there are several interesting options that I could use with the source and that I would like to be using with python scripts, I was wondering whether this was possible. Here are some of the options:

Best, Mathias Charconnet.

Version

2.6.x (Default)

Which operating system are you using?

Linux (Default)

Does the problem occur with one of our executable program or the C-library?

No response

Relevant log output

No response

Code of Conduct

anthonyhtyao commented 11 months ago

From python side, I would recommend using RNA.fold_compound where you can pass the model as an argument For example

md = RNA.md(temperature=25, salt=0.1)
fc = RNA.fold_compout(your_sequence, md)
fc.mfe()
MathiasCharconnet commented 11 months ago

@anthonyhtyao Why do you recommend using fold_compound ? I've seen rna_cofold was deprecated which might be the reason, however when I used RNA.cvar.salt=0.1 I did obtained some changes in interaction energy and secondary structure folding which did make sense. Any idea on using the jobs option ? I'm trying to make the simulation faster by optimizing the number of cores I'm using on a server.

anthonyhtyao commented 11 months ago

Functions provided in ViennaRNA are wrapped as member functions of RNA.fold_compound in RNAlib. You can see from its documentation here. This aims to simplify the use of RNAlib from Python.

Unfortunately, jobs option is not provided in RNAlib. One needs to write the parallel calculation on their own.

RaumZeit commented 10 months ago

@anthonyhtyao Why do you recommend using fold_compound ? I've seen rna_cofold was deprecated which might be the reason, however when I used RNA.cvar.salt=0.1 I did obtained some changes in interaction energy and secondary structure folding which did make sense. Any idea on using the jobs option ? I'm trying to make the simulation faster by optimizing the number of cores I'm using on a server.

Indeed, setting the global RNA.cvar.salt to a different value will change all subsequent computations to use the updated salt concentration. What @anthonyhtyao suggested was to use the v3.0 API instead of the 'simple' API to allow for concurrent computations even with different model setttings. Using the fold_compound object and the methods attached separates the model and predictions for each object from the global defaults. It is therefore the best choice if you want to go for parallel/concurrent computations.

I second @anthonyhtyao with his second answer: There is no parallelization implemented in the ViennaRNA library except for some highly special algorithms. If you want to simulate the -j/--jobs option of RNAfold or RNAcofold, you need to write you own threaded code.

RaumZeit commented 2 months ago

closing this issue since it seems resolved... Feel free to re-open if necessary!