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 57480deb authored by htyao's avatar htyao
Browse files

Doc for annotation

parent f1c4f4ca
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).
Four annotation types allowed in VARNA are represented by four objects below.
::: varnaapi
selection:
members: ["BaseAnnotation", "LoopAnnotation", "HelixAnnotation", "StaticAnnotation"]
::: varnaapi
selection:
filters: ["!^VARNA", "!^_", "__init__"]
filters: ["!^VARNA", "!^_", "__init__", "!Annotation"]
......@@ -8,6 +8,7 @@ theme:
nav:
- Overview: index.md
- API: varnaapi.md
- Annotation: annotation.md
- VARNA: varna.md
plugins:
......@@ -19,6 +20,8 @@ plugins:
filters:
- "!^_"
- "^__init__$"
rendering:
show_root_toc_entry: False
watch:
- varnaapi.py
......
......@@ -129,11 +129,13 @@ class BasesStyle:
class _Annotation:
"""Basic Annotation
"""
def __init__(self, text, type, color="#000000", size=10):
self.text = text
self.type = type
self.color = color
self.size = size
self.size = size #: int: font size
def asdict(self):
return {'text': self.text, 'type': self.type, 'color': self.color,
......@@ -160,22 +162,49 @@ class _ObjectAnnotation(_Annotation):
class BaseAnnotation(_ObjectAnnotation):
def __init__(self, text, anchor, color="#000000", size=10):
def __init__(self, text:str, anchor:int, color="#000000", size=10):
"""Annoation on a base.
Args:
text: Annotation caption
anchor: Index of base to annotate
color (Hex): Annotation color
size (int): Font size
"""
super().__init__(text, 'B', color, size)
class LoopAnnotation(_ObjectAnnotation):
"""Same as [BaseAnnotation][varnaapi.BaseAnnotation] but on a loop.
Argument `anchor` can be index of any base in the loop of interest.
"""
def __init__(self, text, anchor, color="#000000", size=10):
super().__init__(text, 'L', anchor, color, size)
class HelixAnnotation(_ObjectAnnotation):
"""Same as [BaseAnnotation][varnaapi.BaseAnnotation] but on an helix.
Argument `anchor` can be index of any base in the helix of interest.
"""
def __init__(self, text, anchor, color="#000000", size=10):
super().__init__(text, 'H', anchor, color, size)
class StaticAnnotation(_Annotation):
def __init__(self, text, x, y, color="#000000", size=10):
"""Annotation on a specified position in VARNA drawing.
Unlike [BaseAnnotation][varnaapi.BaseAnnotation], argument `anchor` is omitted.
However, arguments `x` and `y` are needed to specify annotation position.
__Note:__ It is unrecommended to use static annotation unless you know what you're doing
Args:
x (int): x-coordinate of position
y (int): y-ccordinate of position
Examples:
>>> sa = StaticAnnotation("Hello World", 100, 150, color="#FF0000")
"""
super().__init__(text, 'P', color, size)
self.x = x
self.y = y
......@@ -489,7 +518,10 @@ class VARNA:
self.bases_styles[style] = self.bases_styles.get(style, set()).union({i+1 for i in bases})
def add_annotation(self, annotation):
def add_annotation(self, annotation:_Annotation):
"""Add an annotation.
Argument should be a valid [Annotation](/annotation/) object
"""
# Assert is annotation
if not isinstance(annotation, _Annotation):
raise Exception("Should be a valid annotation object")
......
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