Skip to content

Commit

Permalink
add annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
akikuno committed Sep 2, 2023
1 parent 24ba388 commit d08c665
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/cstag/consensus.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from itertools import chain
from collections import deque, Counter
Expand Down
3 changes: 2 additions & 1 deletion src/cstag/lengthen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re
from __future__ import annotations

import re
from cstag.utils.validator import validate_short_format


Expand Down
8 changes: 5 additions & 3 deletions src/cstag/mask.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

import re

from cstag.utils.validator import validate_long_format, validate_threshold


def mask(cs_tag: str, cigar: str, qual: str, threshold: int = 10, prefix: bool = False):
def mask(cs_tag: str, cigar: str, qual: str, threshold: int = 10, prefix: bool = False) -> str:
"""Mask low-quality bases to 'N'
Args:
cs_tag (str): cs tag in the **long** format
Expand All @@ -15,11 +17,11 @@ def mask(cs_tag: str, cigar: str, qual: str, threshold: int = 10, prefix: bool =
str: Masked cs tag
Example:
>>> import cstag
>>> cs_tag = "cs:Z:=ACGT*ac+gg-cc=T"
>>> cs_tag = "=ACGT*ac+gg-cc=T"
>>> cigar = "5M2I2D1M"
>>> qual = "AA!!!!AA"
>>> cstag.mask(cs_tag, qual)
cs:Z:=ACNN*an+ng-cc=T
=ACNN*an+ng-cc=T
"""

validate_long_format(cs_tag)
Expand Down
2 changes: 2 additions & 0 deletions src/cstag/shorten.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re


Expand Down
2 changes: 2 additions & 0 deletions src/cstag/to_html.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re

from cstag.utils.validator import validate_long_format
Expand Down
7 changes: 7 additions & 0 deletions tests/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def test_basic_with_prefix():
assert cstag.mask(CSTAG, CIGAR, QUAL, prefix=True) == "cs:Z:=ACNN*an+ng-cc=T"


def test_all_n():
CSTAG = "=ACGT"
CIGAR = "4M"
QUAL = "!!!!"
assert cstag.mask(CSTAG, CIGAR, QUAL) == "=NNNN"


def test_softclip():
CSTAG = "=ACGT*ac+gg-cc=T"
CIGAR = "2S5M2I2D1M"
Expand Down

0 comments on commit d08c665

Please sign in to comment.