MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 8e10ead3 authored by htyao's avatar htyao
Browse files

Finish doc

parent cf5ae7ed
VARNA API is a Python interface for [VARNA](http://varna.lri.fr/index.php), a Java lightweight component and applet for drawing the RNA secondary structure.
VARNA allows users to produce drawing in a non-iteractive way via command line.
However, the command line might be massive and complicate in some use cases.
VARNA API aims to simplify such process.
__NOTE__: The VARNA API is 0-indexed unlike VARNA, which is 1-indexed.
## Example
The command below highlights region 11-21 and adds a non-canonical base pair at position (14,20)
on secondary structure `((((((.((((((........)))))).((((((.......))))))..))))))`.
```bash
java -cp VARNAv3-93.jar fr.orsay.lri.varna.applications.VARNAcmd -sequenceDBN " " -structureDBN "((((((.((((((........)))))).((((((.......))))))..))))))" -o example.png -algorithm radiate -auxBPs "(14,20):color=#FF00FF,thickness=1.0,edge5=s,edge3=wc,stericity=cis" -highlightRegion "11-21:radius=15.0,fill=#9999FF,outline=#3333FF"
```
The equivalence in python is
```python
from varnaapi import VARNA
v = VARNA(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
v.add_highlight_region(10,20)
v.add_aux_BP(13, 19, edge5="s", color="#FF00FF")
v.savefig("example.png")
```
## Installation
```
python3 -m pip install varnaapi
```
## Usage
Here, we show the basic usage of varnaapi. Please refer the [API](https://htyao.gitlab.io/varna-api/varna) page for more details.
The first thing after importing `varnaapi` is to setup the location of VARNA used.
The default is `VARNAv3-93.jar` in the current folder.
```python
import varnaapi
varnaapi.set_VARNA(path_to_VARNA)
```
Each drawing in VARNA is an object called `VARNA` created from given secondary structure or/and RNA sequence.
```python
ss = "((((((.((((((........)))))).((((((.......))))))..))))))"
v = varnaapi.VARNA(structure=ss)
```
Then we can add operations on drawing by calling object functions, such as `VARNA.set_algorithm()` to choose a drawing algorithm, `VARNA.add_highlight_region()` to highlight a region etc.
```python
v.set_algorithm('line')
v.add_highlight_region(0, 5, radius=20)
```
Finally, we can draw the secondary structure
```python
v.savefig(path_to_store)
```
## Credits
Please kindly cite VARNA [supporting manuscript](https://doi.org/10.1093/bioinformatics/btp250) if you use VARNA API in your research.
Download [bibtex](https://gitlab.inria.fr/amibio/varna-api/-/blob/master/varna.bib) format.
```
Darty, K., Denise, A., & Ponty, Y. (2009). VARNA: Interactive drawing and editing of the RNA secondary structure. Bioinformatics, 25(15), 1974.
```
Hello!
VARNA API is a Python interface for [VARNA](http://varna.lri.fr/index.php), a Java lightweight component and applet for drawing the RNA secondary structure.
VARNA allows users to produce drawing in a non-iteractive way via command line.
However, the command line might be massive and complicate in some use cases.
VARNA API aims to simplify such process.
__NOTE__: The VARNA API is 0-indexed unlike VARNA, which is 1-indexed.
## Example
The command below highlights region 11-21 and adds a non-canonical base pair at position (14,20)
on secondary structure `((((((.((((((........)))))).((((((.......))))))..))))))`.
```bash
java -cp VARNAv3-93.jar fr.orsay.lri.varna.applications.VARNAcmd -sequenceDBN " " -structureDBN "((((((.((((((........)))))).((((((.......))))))..))))))" -o example.png -algorithm radiate -auxBPs "(14,20):color=#FF00FF,thickness=1.0,edge5=s,edge3=wc,stericity=cis" -highlightRegion "11-21:radius=15.0,fill=#9999FF,outline=#3333FF"
```
The equivalence in python is
```python
from varnaapi import VARNA
v = VARNA(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
v.add_highlight_region(10,20)
v.add_aux_BP(13, 19, edge5="s", color="#FF00FF")
v.savefig("example.png")
```
## Installation
```
python3 -m pip install varnaapi
```
## Usage
Here, we show the basic usage of varnaapi. Please refer the [API](https://htyao.gitlab.io/varna-api/varna) page for more details.
The first thing after importing `varnaapi` is to setup the location of VARNA used.
The default is `VARNAv3-93.jar` in the current folder.
```python
import varnaapi
varnaapi.set_VARNA(path_to_VARNA)
```
Each drawing in VARNA is an object called `VARNA` created from given secondary structure or/and RNA sequence.
```python
ss = "((((((.((((((........)))))).((((((.......))))))..))))))"
v = varnaapi.VARNA(structure=ss)
```
Then we can add operations on drawing by calling object functions, such as `VARNA.set_algorithm()` to choose a drawing algorithm, `VARNA.add_highlight_region()` to highlight a region etc.
```python
v.set_algorithm('line')
v.add_highlight_region(0, 5, radius=20)
```
Finally, we can draw the secondary structure
```python
v.savefig(path_to_store)
```
## Credits
Please kindly cite VARNA [supporting manuscript](https://doi.org/10.1093/bioinformatics/btp250) if you use VARNA API in your research.
Download [bibtex](https://gitlab.inria.fr/amibio/varna-api/-/blob/master/varna.bib) format.
```
Darty, K., Denise, A., & Ponty, Y. (2009). VARNA: Interactive drawing and editing of the RNA secondary structure. Bioinformatics, 25(15), 1974.
```
@article{darty2009varna,
title={VARNA: Interactive drawing and editing of the RNA secondary structure},
author={Darty, K{\'e}vin and Denise, Alain and Ponty, Yann},
journal={Bioinformatics},
volume={25},
number={15},
pages={1974},
year={2009},
publisher={Oxford University Press}
}
We offer two python classes [VARNA](#varnaapi.VARNA) and [Comparison](#varnaapi.Comparison) corresponding to the classic mode and the comparison mode in VARNA.
In VARNA API, we offer three Python classes [VARNA](#varnaapi.VARNA), [Comparison](#varnaapi.Comparison), and [Motif](#varnaapi.Motif) for RNA secondary structure visualisation.
The first two correspond to the classic and the comparison mode in VARNA. The last one is the special case for motif drawing.
Both [Comparison](#varnaapi.Comparison) and [Motif](#varnaapi.Motif) are inherited classes of [VARNA](#varnaapi.VARNA).
::: varnaapi
selection:
......
# mkdocs.yml
site_name: VARNA API
repo_url: "https://gitlab.inria.fr/amibio/varna-api"
repo_name: "AMIBio/VARNA-API"
theme:
# name: "readthedocs"
name: "material"
nav:
- Overview: index.md
- API: varnaapi.md
- Annotation: annotation.md
- VARNA: varna.md
- Home: index.md
- API:
- VARNA Classes: varna.md
- Annotation: annotation.md
- Miscellaneous: varnaapi.md
plugins:
- search
......
#!/usr/bin/env python3
import setuptools
from distutils.core import setup
def read_version(fpath):
with open(fpath) as f:
for line in f.readlines():
if line.startswith('__version__'):
return line.strip().split()[-1][1:-1]
raise Exception('Version not found')
VERSION = read_version('./varnaapi.py')
with open("README.md", "r") as fh:
long_description = fh.read()
CLASSIFIERS = """\
Development Status :: 5 - Production/Stable
Intended Audience :: Science/Research
Intended Audience :: Developers
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Topic :: Scientific/Engineering
Operating System :: OS Independent
"""
setup(name='varnaapi',
version=VERSION,
description='Python Class for VARNA',
long_description=long_description,
long_description_content_type="text/markdown",
maintainer='Hua-Ting Yao',
maintainer_email='hua-ting.yao@polytechnique.edu',
author='Hua-Ting Yao',
author_email='hua-ting.yao@polytechnique.edu',
url='https://gitlab.inria.fr/amibio/varna-api',
classifiers=[_f for _f in CLASSIFIERS.split('\n') if _f],
py_modules=['varnaapi'],
python_requires='>=3'
)
......@@ -2,11 +2,10 @@ import re
import os
import abc
from string import ascii_lowercase, ascii_uppercase
from typing import Union
__version__ = '0.1.0'
VARNA_PATH="VARNAv3-93.jar"
_VARNA_PATH="VARNAv3-93.jar"
HEX = re.compile('^#(?:[0-9a-fA-F]{3}){1,2}$')
BORDER = re.compile('^\d+x\d+$')
......@@ -37,10 +36,12 @@ OPTIONS = ['autoHelices', 'autoInteriorLoops', 'autoTerminalLoops', 'drawBackbon
| drawBackbone | Backbone drawing | True |
| drawBases | Displays the outline of a nucleotide base | True |
| drawNC | Displays non-canonical base-pairs | True |
| drawTertiary | Display of `non-planar` base-pairs, _i.e._ pseudoknots | False |
| drawTertiary | Display of `non-planar` base-pairs, _i.e._ pseudoknots [^1] | False |
| fillBases | Fill bases | True |
| flat | In `radiate` drawing mode, redraws the whole structure, aligning to a baseline the base featured on the exterior loops (aka "dangling ends") | False |
[^1]: Since there is no canonical definition of pseudoknotted portions, a maximal planar subset is extracted from the input structure, defined to be the planar portion, and used as a scaffold for the drawing algorithms.
"""
NUMERIC_PARAMS = ['bpIncrement', 'periodNum', 'resolution', 'rotation', 'spaceBetweenBases', 'zoom']
......@@ -79,11 +80,16 @@ PARENTHESES_SYSTEMS = [
PARENTHESES_OPENING = [c1 for c1, c2 in PARENTHESES_SYSTEMS]
PARENTHESES_CLOSING = {c2: c1 for c1, c2 in PARENTHESES_SYSTEMS}
def set_VARNA(path):
"""Set VARNA location
"""
global _VARNA_PATH
_VARNA_PATH = path
class BasesStyle:
"""Defines a custom base-style, to be applied later to a set of bases.
A BasesStyle style contains colors used for different components of a base.
See [\_\_init\_\_][varnaapi.BasesStyle.\_\_init\_\_] for more details.
See [\_\_init\_\_][varnaapi.BasesStyle.__init__] for more details.
__See Also:__ [VARNA.add_bases_style][varnaapi.VARNA.add_bases_style]
"""
......@@ -105,7 +111,7 @@ class BasesStyle:
def update(self, fill=None, outline=None, label=None, number=None):
"""Update component colors.
Same rule as [\_\_init\_\_][varnaapi.BasesStyle.\_\_init\_\_]
Same rule as [\_\_init\_\_][varnaapi.BasesStyle.__init__]
"""
if fill is None and outline is None and label is None and number is None:
raise Exception("At least one should not be None")
......@@ -267,7 +273,7 @@ def _parse_vienna(ss):
class VARNA:
def __init__(self, seq:str=None, structure=None):
"""Classis VARNA drawing mode. Constructor from given RNA sequence or/and secondary structure.
"""Classic VARNA drawing mode. Constructor from given RNA sequence or/and secondary structure.
If sequence and structure have different size, the larger one is used
and ` `s or `.`s will be added to sequence or structure to complement.
......@@ -535,7 +541,7 @@ class VARNA:
"""
Return command to run VARNA
"""
cmd = "java -cp {} fr.orsay.lri.varna.applications.VARNAcmd".format(VARNA_PATH)
cmd = "java -cp {} fr.orsay.lri.varna.applications.VARNAcmd".format(_VARNA_PATH)
cmd += self._gen_input_cmd()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment