cstag.utils.validator
1from __future__ import annotations 2 3import re 4 5 6def validate_cs_tag(cs_tag: str) -> None: 7 pattern = re.compile( 8 r"^(=[ACGTN]+|:[0-9]+|\*[acgtn][acgtn]|\+[acgtn]+|\-[acgtn]+|\~[acgtn][acgtn][0-9]+[acgtn][acgtn])*$" 9 ) 10 11 if not pattern.fullmatch(cs_tag.replace("cs:Z:", "")): 12 raise ValueError(f"Invalid cs tag: {cs_tag}") 13 14 15def validate_short_format(cs_tag: str) -> None: 16 if re.search(r"=[ACGTN]+", cs_tag): 17 raise ValueError("cs tag must be in short format") 18 19 20def validate_long_format(cs_tag: str) -> None: 21 if re.search(r":[0-9]+", cs_tag): 22 raise ValueError("cs tag must be in long format") 23 24 25def validate_threshold(threshold: int) -> None: 26 if not isinstance(threshold, int): 27 raise ValueError("threshold must be an integer") 28 29 if not 0 <= threshold <= 40: 30 raise ValueError("threshold must be within a range between 0 to 40") 31 32 33def validate_pos(pos: int) -> None: 34 if pos < 1: 35 raise ValueError(f"pos must be a positive integer, but got {pos}")
def
validate_cs_tag(cs_tag: str) -> None:
def
validate_short_format(cs_tag: str) -> None:
def
validate_long_format(cs_tag: str) -> None:
def
validate_threshold(threshold: int) -> None:
def
validate_pos(pos: int) -> None: