Commit e7b0966c authored by YAO Hua-Ting's avatar YAO Hua-Ting
Browse files

Merge branch 'document' into 'develop'

Add cartoon like example

See merge request !8
parents a57a71fc 2a6a2e9f
List of VARNA parameters and their default value that can be passed as keyword arguments to `BasicDraw.update()`.
The name of keyword argument is listed in the `name` column in each table.
::: varnaapi.param
selection:
members: ["COLOR_LIST", "BOOLEAN_OPTIONS", "NUMERIC_PARAMS"]
# Choices
There are two VARNA parameters, `algorithm` and `bpStyle`, takes value from defined options.
::: varnaapi.param
selection:
members: ["BP_STYLES", "ALGORITHMS"]
In VARNA API, we offer three Python classes [VARNA](#varnaapi.VARNA), [Comparison](#varnaapi.Comparison), and [Motif](#varnaapi.Motif) for RNA secondary structure visualisation.
In VARNA API, all drawing classes are inherited from the class [BasicDraw][varnaapi.BasicDraw]. We offer three Python classes [Structure][varnaapi.Structure], [Comparison][varnaapi.Comparison], and [Motif][varnaapi.Motif] for different 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
- [Structure][varnaapi.Structure]: The most common drawing class taking a secondary structure and/or an RNA sequence as input.
- [Comparison][varnaapi.Comparison]: Comparison between two structures and two sequences.
- [Motif][varnaapi.Motif]: Customized class to draw motif, an union of loops.
::: varnaapi.models
selection:
members: ["BasicDraw"]
inherited_members: True
::: varnaapi.models
selection:
members: ["VARNA"]
members: ["Structure"]
::: varnaapi
::: varnaapi.models
selection:
members: ["Comparison"]
::: varnaapi
::: varnaapi.models
selection:
filters: ["!savefig"]
members: ["Motif"]
......@@ -22,7 +30,8 @@ Both [Comparison](#varnaapi.Comparison) and [Motif](#varnaapi.Motif) are inherit
### Example
Figure above is created with
```python
from varnaapi import Motif, BaseAnnotation
from varnaapi import Motif
from varnaapi.param import BaseAnnotation
m = Motif("((*)(*)(((*)(*))))", sequence=" *AU* CC * * ")
m.add_annotation(BaseAnnotation(" Root", 1))
m.add_annotation(BaseAnnotation("Dummy", 13))
......
This diff is collapsed.
This diff is collapsed.
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 API is a Python interface for [VARNA](http://varna.lri.fr/index.php) (v3-93), 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"
java -cp VARNAv3-93.jar fr.orsay.lri.varna.applications.VARNAcmd -sequenceDBN " " -structureDBN "((((((.((((((........)))))).((((((.......))))))..))))))" -o example.png -auxBPs "(14,20):color=#ff00ff" -highlightRegion "11-21"
```
The equivalence in python is
The equivalence using VARNA API would be
```python
from varnaapi import VARNA
v = VARNA(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
from varnaapi import Structure
v = Structure(structure="((((((.((((((........)))))).((((((.......))))))..))))))")
v.add_highlight_region(10,20)
v.add_aux_BP(13, 19, edge5="s", color="#FF00FF")
v.savefig("example.png")
......@@ -28,26 +27,89 @@ 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.
The first thing after importing `varnaapi` is to setup the location of VARNA to use.
!!! note "By default, the library assumes the VARNA v3-93 in the current folder is used (`./VARNAv3-93.jar`)"
```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.
Each drawing in VARNA is an object of class inherited from [BasicDraw][varnaapi.BasicDraw]. The standard class to draw from given secondary structure or/and RNA sequence is [Structure][varnaapi.Structure].
```python
ss = "((((((.((((((........)))))).((((((.......))))))..))))))"
v = varnaapi.VARNA(structure=ss)
v = varnaapi.Structure(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.
One can call the member function `#!python BasicDraw.savefig()` with given file name to save the drawing. The format is either `png` or `svg`, that VARNA will determine from the file name.
```python
v.set_algorithm('line')
v.add_highlight_region(0, 5, radius=20)
v.savefig("my_drawing.png")
```
Finally, we can draw the secondary structure
While using jupyter notebook, one can also set the option `show` to `#!python True` to show the drawing in the notebook
```python
v.savefig(path_to_store)
v.savefig("my_drawing.png", show=True)
```
or simply use the member function `#!python BasicDraw.show()`.
```py
v.show()
```
The later one creates a temporary file in `png` format for drawing.
### Configuration
In VARNA, one can chose the structure drawing algorithm, change the style for base pair, or hide backbone in drawing etc.
The full list of parameters with default value can be found [here](config).
In library, the easiest way to modify these parameters is through the member function `#!python BasicDraw.update()`.
Some parameters, such as algorithm, can be set up via specific function. The rest will be supported in future update.
```python
v.update(algorithm='naview', bpStyle='none', drawBackbone=False, bp='#006400')
```
!!! note "Color parameters"
Value for all color parameters in VARNA API should be readable by the object [colour.Color](https://github.com/vaab/colour), such as human color name, hex, RGB etc.
#### Save configuration
The library offers function to save the parameters setting in YAML format for the further use.
```python
v.dump_param('config.yml')
```
#### Load configuration
There are two ways to load the saved configuration.
The first one is using the member function of `BasicDraw`.
```python
v.load_param('config.yml')
```
The second way is loading the configuration as a global setting in the opened session.
```python
varnaapi.load_config('config.yml')
```
!!! note "Parameter value priority order"
VARNA API uses parameter values in the following order, _i.e._ if the value in the current order is undefined, then the next one is used
- Value set by `varnaapi.BasicDraw.update()` or similar functions
- Object Value loaded using `varnaapi.BasicDraw.load_param()`
- Global values loaded using `varnaapi.load_cofig()`
- Default parameter values.
#### Operations
VARNA allows different operations on drawing, such as highlighting a region, adding auxiliary base pairs.
This can be achieved by using the proper functions. We invite users to read API for more details.
```python
v.add_highlight_region(0, 5, radius=20)
v.add_aux_bp(0, 9, color='red')
```
!!! note "The VARNA API is 0-indexed unlike VARNA, which is 1-indexed."
## Credits
Please kindly cite VARNA [supporting manuscript](https://doi.org/10.1093/bioinformatics/btp250) if you use VARNA API in your research.
......
# Style classes for VARNA operations
Two helper class groups can be imported from `#! python varnaapi.param` for two VARNA operations, [add_annotation][varnaapi.BasicDraw.add_annotation] and [add_bases_style][varnaapi.BasicDraw.add_bases_style].
## Annotation
An `Annotation` object represents a textual annotation added to a VARNA drawing.
The object stores the text and other informtation needed.
One can add `Annotation` to drawing using [VARNA.add_annotation](varna.md#varnaapi.VARNA.add_annotation).
One can add `Annotation` to drawing using [BasicDraw.add_annotation][varnaapi.BasicDraw.add_annotation].
Four annotation types allowed in VARNA are represented by four objects below.
::: varnaapi
::: varnaapi.param
selection:
members: ["BaseAnnotation", "LoopAnnotation", "HelixAnnotation", "StaticAnnotation"]
rendering:
heading_level: 3
::: varnaapi.param
selection:
members: ["BasesStyle"]
::: varnaapi
selection:
filters: ["!^VARNA", "!^_", "__init__", "!Annotation", "!Comparison", "!Motif"]
......@@ -9,10 +9,12 @@ theme:
nav:
- Home: index.md
- Gallery:
- Riboswitch cartoon: gallery/Cartoon-like.ipynb
- API:
- VARNA Classes: varna.md
- Annotation: annotation.md
- Miscellaneous: varnaapi.md
- Drawing Classes: drawing.md
- Configurations: config.md
- Style Classes: style.md
plugins:
- search
......@@ -26,10 +28,13 @@ plugins:
rendering:
show_root_toc_entry: False
watch:
- varnaapi.py
- src/varnaapi
- mkdocs-jupyter
markdown_extensions:
- footnotes
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.superfences
- admonition
......@@ -9,7 +9,7 @@ from deprecated import deprecated
from IPython.display import Image, display, SVG
from varnaapi.param import VarnaConfig, BasesStyle, _Title, _Highlight, _Annotation, _BPStyle, _ChemProb, _ColorMap
from varnaapi.param import _VarnaConfig, BasesStyle, _Title, _Highlight, _Annotation, _BPStyle, _ChemProb, _ColorMap
_VARNA_PATH="VARNAv3-93.jar"
......@@ -63,7 +63,7 @@ def _parse_vienna(ss):
return res
class BasicDraw(VarnaConfig):
class BasicDraw(_VarnaConfig):
def __init__(self):
super().__init__()
......@@ -76,7 +76,7 @@ class BasicDraw(VarnaConfig):
self.length = 0
self.colormap = None
def add_aux_BP(self, i:int, j:int, **kwargs):
def add_aux_BP(self, i:int, j:int, edge5='wc', edge3='wc', stericity='cis', color='blue', thickness:float=1):
"""Add an additional base pair `(i,j)`, possibly defining and using custom style
Args:
......@@ -85,12 +85,12 @@ class BasicDraw(VarnaConfig):
edge5: Edge 5' used for interaction in non-canonical base-pairs, as defined by the Leontis/Westhof classification of base-pairs. Admissible values are __wc__ (Watson/Crick edge), __h__ (Hoogsteen edge) and __s__ (Sugar edge).
edge3: Edge 3' used for interaction in non-canonical base-pairs. Admissible values are __wc__, __h__ and __s__.
stericity: Orientation of the strands. Admissible values are __cis__ and __trans__
color (Hex): Base-pair color in Hex color codes
color (color): Base-pair color
thickness: Base-pair thickness
"""
assert_valid_interval(self.length, i, j)
self.aux_BPs.append((i+1, j+1, _BPStyle(**{k: v for k, v in kwargs.items() if v is not None})))
self.aux_BPs.append((i+1, j+1, _BPStyle(edge5=edge5, edge3=edge3, stericity=stericity, color=color, thickness=thickness)))
def add_highlight_region(self, i:int, j:int, radius:float=16, fill="#BCFFDD", outline="#6ED86E"):
"""Highlights a region by drawing a polygon of predefined radius,
......@@ -101,8 +101,8 @@ class BasicDraw(VarnaConfig):
i: 5'-end of the highlight
j: 3'-end of the highlight
radius: Thickness of the highlight
fill (Hex): The color used to fill the highlight
outline (Hex): The color used to draw the line around the highlight
fill (color): The color used to fill the highlight
outline (color): The color used to draw the line around the highlight
"""
assert_valid_interval(self.length, i, j)
......@@ -114,7 +114,7 @@ class BasicDraw(VarnaConfig):
self._title = _Title(title, color, size)
def add_bases_style(self, style:BasesStyle, bases:list):
"""Apply a [BasesStyle][varnaapi.BasesStyle] to a list of positions.
"""Apply a [BasesStyle][varnaapi.param.BasesStyle] to a list of positions.
If a position is assigned to more than one styles,
one of them will be randomly used.
......@@ -123,11 +123,12 @@ class BasicDraw(VarnaConfig):
bases: List of 0-indexed positions
Examples:
>>> style1 = BasesStyle(fill="#FF0000")
>>> style2 = BasesStyle(fill="#FFFF00" outline="#00FF00")
>>> varna.add_bases_style(style1, [0,2,4])
>>> varna.add_bases_style(setye1, [10,11,12])
>>> varna.add_bases_style(style2, [4,5,6,7])
>>> v = varnaapi.Structure()
>>> style1 = varnaapi.param.BasesStyle(fill="#FF0000")
>>> style2 = varnaapi.param.BasesStyle(fill="#FFFF00" outline="#00FF00")
>>> v.add_bases_style(style1, [0,2,4])
>>> v.add_bases_style(setye1, [10,11,12])
>>> v.add_bases_style(style2, [4,5,6,7])
"""
if not isinstance(style, BasesStyle):
......@@ -137,25 +138,50 @@ class BasicDraw(VarnaConfig):
def add_annotation(self, annotation:_Annotation):
"""Add an annotation.
Argument should be a valid [Annotation](annotation.md) object
Argument should be a valid [Annotation](/style#annotation) object
Examples:
>>> a = LoopAnnotation("L1", 6, color="#FF00FF")
>>> varna.add_annotation(a)
>>> v = varnaapi.Structure()
>>> a = varnaapi.param.LoopAnnotation("L1", 6, color="#FF00FF")
>>> v.add_annotation(a)
"""
# Assert is annotation
if not isinstance(annotation, _Annotation):
raise Exception("Should be a valid annotation object")
self.annotations.append(annotation)
def add_chem_prob(self, i, **kwargs):
def add_chem_prob(self, base:int, glyph:str='arrow', dir:str='in', intensity:float=1, color='#0000B2'):
"""Add chemical probing annotation on two adjacent bases.
Args:
base: index of the first base of adjacent bases
glyph: Shape of the annotation chosen from ['arrow', 'dot', 'pin', 'triangle']
dir: Direction of the annotation chosen from ['in', 'out']
intensity: Annotation intensity, _i.e._ thickness
color (color): Color used to draw the annotation
"""
try:
assert i>=0 and i < self.length-1
assert base>=0 and base < self.length-1
except AssertionError:
raise Exception("Base should be in between 0 and {}".format(self.length-1))
self.chem_prob.append((int(i), _ChemProb(**kwargs)))
self.chem_prob.append((int(base), _ChemProb(glyph=glyph, dir=dir, intensity=intensity, color=color)))
def add_colormap(self, values, vMin:float=None, vMax:float=None, caption:str="", style="energy"):
"""Add color map on bases.
Args:
values (float list): list of values in float for each base. `0`s are added at the end of the list if the list length is shorter than the number of bases.
vMin: Minium value for the color map
vMax: Maximum value for the color map
caption: Color map caption
style: Color map style, which is one of the following
- predefined style from
['red', 'blue', 'green', 'heat', 'energy', 'bw']
def add_colormap(self, values, vMin=None, vMax=None, caption="", style="energy"):
- customized style in a list of pairs, (value, color)
"""
self.colormap = _ColorMap(values, vMin, vMax, caption, style)
def _gen_command(self):
......@@ -172,14 +198,14 @@ class BasicDraw(VarnaConfig):
# Title cmd
if self._title is not None:
cmd += self._title.to_cmd()
cmd += self._title._to_cmd()
# Aux Base pairs
if len(self.aux_BPs) > 0:
res = []
for i, j, style in self.aux_BPs:
s = "({},{})".format(i,j)
setting = style.to_cmd(self.get_params(complete=True)['bp'])
setting = style._to_cmd(self.get_params(complete=True)['bp'])
if not setting == "":
s += ":" + setting
res.append(s)
......@@ -190,7 +216,7 @@ class BasicDraw(VarnaConfig):
res = []
for item in self.highlight_regions:
s = "{}-{}".format(item[0], item[1])
setting = item[2].to_cmd()
setting = item[2]._to_cmd()
if not setting == "":
s += ":" + setting
res.append(s)
......@@ -200,21 +226,21 @@ class BasicDraw(VarnaConfig):
styles = {'fill': 'baseInner', 'outline': 'baseOutline', 'label': 'baseName', 'number': 'baseNum'}
styles_dafault = {v: self.get_params().get(v) for v in styles.values() if v in self.get_params()}
for ind, (style, bases) in enumerate(self.bases_styles.items()):
s = style.to_cmd(**styles_dafault)
s = style._to_cmd(**styles_dafault)
if not s == "":
cmd += ["-basesStyle{}".format(ind + 1), s]
cmd += ["-applyBasesStyle{}on".format(ind + 1), ','.join(map(str, bases))]
# Annotations
if len(self.annotations) > 0:
cmd += ["-annotations", ';'.join([t.to_cmd() for t in self.annotations])]
cmd += ["-annotations", ';'.join([t._to_cmd() for t in self.annotations])]
# Chem Prob
if len(self.chem_prob) > 0:
res = []
for i, style in self.chem_prob:
s = "{}-{}".format(i, i+1)
setting = style.to_cmd()
setting = style._to_cmd()
if not setting == "":
s += ":" + setting
res.append(s)
......@@ -222,16 +248,23 @@ class BasicDraw(VarnaConfig):
# Color Map
if self.colormap is not None:
cmd += self.colormap.to_cmd()
cmd += self.colormap._to_cmd()
return cmd
def _gen_input_cmd(self):
pass
def savefig(self, output, show=False):
def savefig(self, output, show:bool=False):
"""
Call VARNA to draw and store the paint in output
Args:
output: Output file name with extension is either png or svg
show: Show the drawing
Note:
The argument `show` is used only in jupyter notebook
"""
self.output = output
cmd = self._gen_command()
......@@ -243,6 +276,8 @@ class BasicDraw(VarnaConfig):
display(Image(filename=output))
elif output[-3:] == 'svg':
display(SVG(filename=output))
else:
raise Exception("File type should be either png or svg")
def show(self, extension='png'):
"""Show the drawing
......@@ -252,22 +287,22 @@ class BasicDraw(VarnaConfig):
self.savefig(tmp.name, show=True)
class Structure(BasicDraw):
def __init__(self, sequence=None, structure=None):
"""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.
"""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.
Args:
seq: Raw nucleotide sequence for the displayed RNA.
Each base must be encoded in a single character.
Letters others than `A`, `C`, `G`, `U` and space are tolerated.
structure (str or list): RNA (pseudoknotted) secondary structure in one of three formats
Args:
sequence: Raw nucleotide sequence for the displayed RNA.
Each base must be encoded in a single character.
Letters others than `A`, `C`, `G`, `U` and space are tolerated.
structure (str or list): RNA (pseudoknotted) secondary structure in one of three formats
- Dot-Bracket Notation (DBN)
- List of pair of int representing a list of base-pairs
- List of int, in which i-th value is `j` if `(i,j)` is a base pair or `-1` if i-th base is unpaired
- Dot-Bracket Notation (DBN)
- List of pair of int representing a list of base-pairs
- List of int, in which i-th value is `j` if `(i,j)` is a base pair or `-1` if i-th base is unpaired
"""
"""
def __init__(self, sequence=None, structure=None):
super().__init__()
self.length = -1
......@@ -337,7 +372,7 @@ def VARNA(*args, **kwargs):
class Comparison(BasicDraw):
"""Drawing of two aligned RNAs.
Unlike classic [VARNA][varnaapi.VARNA] mode,
Unlike classic [Structure][varnaapi.Structure] mode,
both sequences and structures __MUST__ be specified and have the same size.
Additionally, the merged secondary structures must currently be without any crossing
interactions (e.g. pseudoknots), and merging them should give a secondary structure.
......@@ -375,7 +410,7 @@ class Motif(BasicDraw):
represents a closing base pair. A motif can also be seen as an union
of consecutive loops. The figure below represents `((*)(*)(((*)(*))))`.
Motif class inherits from [VARNA][varnaapi.VARNA] with some pre-set
Motif class inherits from [Structure][varnaapi.Structure] with some pre-set
parameters.
- rotation is set at `180`
......@@ -388,7 +423,7 @@ class Motif(BasicDraw):
Therefore, the index of bases is changed after creating the object.
For example, the index of first base of root is `1` instead of `0`.
The default bases style for root is
`BasesStyle(fill="#606060", outline="#FFFFFF",number="#FFFFFF")` and
`BasesStyle(fill="#606060", outline="#FFFFFF", number="#FFFFFF")` and
`BasesStyle(fill="#DDDDDD", outline="#FFFFFF", number="#FFFFFF")` for
dummy bases. One can change them using
[set_root_bases_style][varnaapi.Motif.set_root_bases_style] and
......@@ -445,14 +480,14 @@ class Motif(BasicDraw):
return ["-sequenceDBN", self.sequence, "-structureDBN", self.structure]
def set_dummy_bases_style(self, style):
"""Set style for dummy bases. Argument is a [BasesStyle][varnaapi.BasesStyle] object.
"""Set style for dummy bases. Argument is a [BasesStyle][varnaapi.param.BasesStyle] object.
"""
if not isinstance(style, BasesStyle):
raise Exception('The argument should be BasesStyle object')
self.dummyBasesStyle = style
def set_root_bases_style(self, style):
"""Set style for root bases. Argument is a [BasesStyle][varnaapi.BasesStyle] object.
"""Set style for root bases. Argument is a [BasesStyle][varnaapi.param.BasesStyle] object.
"""
if not isinstance(style, BasesStyle):
raise Exception('The argument should be BasesStyle object')
......
......@@ -64,6 +64,7 @@ COLOR_DEFAULT = {
BOOLEAN_OPTIONS = ['autoHelices', 'autoInteriorLoops', 'autoTerminalLoops', 'drawBackbone', 'drawBases', 'drawNC', 'drawTertiary', 'fillBases', 'flat']
"""Boolean option list
| Name | Option | Default |
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|---------|
| autoHelices | Annotates each and every helix in the RNA with a unique `Hn` label | False |
......@@ -102,9 +103,10 @@ BOOLEAN_DEFAULT = {
NUMERIC_TYPE = {'border': tuple, 'bpIncrement': float, 'periodNum': int, 'resolution': float, 'rotation': float, 'spaceBetweenBases': float, 'zoom': float}
NUMERIC_PARAMS = [k for k in NUMERIC_TYPE.keys()]
"""Allowed numeric parameters
| Label | Type | Description | Default|
|-------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| border | (int, int) | Sets the width and height of the panel border, <i>i.e.</i> the gap between the panel boundaries and those of the surface used to draw the RNA. Border setting is ignored if it's smaller than RNA draw. | N/A |
| Name | Type | Description | Default|
|-------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----|
| border | (int, int) | Sets the width and height of the panel border, <i>i.e.</i> the gap between the panel boundaries and those of the surface used to draw the RNA. Border setting is ignored if it's smaller than RNA draw. | N/A |
| bpIncrement | float | In linear drawing mode, defines the vertical increment used to separate two successive, nested base-pairs | 0.65 |
| periodNum | int | Sets the interval between two successive base numbers. More specifically, if `k` is the period, then the first and last bases of the RNA are numbered, along with each base whose number is a multiple of `k` | 10 |
| resolution | float | Chooses the resolution of a bitmap PNG export, _i.e._ the multiplier in the number of pixels in each dimension of the exported picture. | 1 |
......@@ -134,19 +136,26 @@ CHOICES_PARAMS = ['algorithm', 'bpStyle']
CHOICES_TYPE = {k: 'choices' for k in CHOICES_PARAMS}
BP_STYLES = ['none', 'simple', 'rnaviz', 'lw']
"""Allowed options for base-pair style
| Label | Description |
|--------|--------------------------------------------------------------------------------------------------------|
| none | Base-pairs are not drawn, but can be implicitly seen from "ladders", _i.e_ helix structures |
| simple | A simple line is used to draw any base-pair, regardless of its type |
| rnaviz | A small square is drawn at equal distance of the two partners |
| lw | Both canonical and non-canonical base-pairs are rendered according to the Leontis/Westhof nomenclature |
"""Allowed options for base-pair style (`bpStyle`), default value is `lw`
| Label | Description |
|--------|------------------------------------------------------------------------------------------------------------------|
| none | Base-pairs are not drawn, but can be implicitly seen from "ladders", _i.e_ helix structures |
| simple | A simple line is used to draw any base-pair, regardless of its type |
| rnaviz | A small square is drawn at equal distance of the two partners |
| lw | Both canonical and non-canonical base-pairs are rendered according to the Leontis/Westhof nomenclature (Default) |
__See Also:__ [VARNA.set_bp_style][varnaapi.VARNA.set_bp_style]
Example:
>>> BasicDraw.update(bpStyle="simple")
"""
ALGORITHMS = ['line', 'circular', 'radiate', 'naview']
"""Allowed options for drawing algorithms (`algorithm`) are `line`, `circular`, `radiate`, and `naview`. The default value is `radiate`.
Example:
>>> BasicDraw.update(algorithm="line")
"""
CHOICES_VALUE = {'algorithm': ALGORITHMS, 'bpStyle': BP_STYLES}
CHOICES_DEFAULT = {'algorithm': 'radiate', 'bpStyle': 'lw'}
......@@ -221,7 +230,7 @@ class _DefaultObj:
res[par] = val
return res
def to_cmd(self):
def _to_cmd(self):
res = []
for par, val in self._get_diff().items():
res += ['-'+par, str(val)]
......@@ -252,36 +261,36 @@ class _Highlight(_DefaultObj):
self.values['fill'] = Color(fill)
self.values['outline'] = Color(outline)
def to_cmd(self):
def _to_cmd(self):
return ','.join('{}={}'.format(k, v) for k, v in self._get_diff().items())
class BasesStyle(_DefaultObj):
"""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.
BasesStyle is constructed from given colors for different components.
__See Also:__ [VARNA.add_bases_style][varnaapi.VARNA.add_bases_style]
"""