Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
refactor, validate, and utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Aug 24, 2023
1 parent 2f09b1a commit dd22153
Show file tree
Hide file tree
Showing 8 changed files with 365 additions and 283 deletions.
14 changes: 4 additions & 10 deletions seqcol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@

import logging

from ._version import __version__
from .seqcol import SeqColClient
from .seqcol import (
parse_fasta,
explain_flag,
fasta_to_seqcol,
build_sorted_name_length_pairs,
)

from .const import *
from .seqcol import *
from .seqcol_client import *
from .utilities import *
from ._version import __version__


__classes__ = ["SeqColClient"]
__all__ = __classes__ + ["build_sorted_name_length_pairs"]
__all__ = (__classes__ + ["build_sorted_name_length_pairs", "compare", "validate_seqcol"],)
3 changes: 3 additions & 0 deletions seqcol/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ def _schema_path(name):
SCHEMA_NAMES = [ASL_NAME + ".yaml"]
SCHEMA_FILEPATH = os.path.join(os.path.dirname(__file__), "schemas")
INTERNAL_SCHEMAS = [_schema_path(s) for s in SCHEMA_NAMES]

# Alias dict to make typehinting clearer
SeqCol = dict
10 changes: 10 additions & 0 deletions seqcol/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class InvalidSeqColError(Exception):
"""Object was not validated successfully according to schema."""

def __init__(self, message, errors):
super().__init__(message)
self.message = message
self.errors = errors

def __str__(self):
return f"InvalidSeqColError ({self.message}): {self.errors}"
1 change: 1 addition & 0 deletions seqcol/schemas/seqcol.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ properties:
description: "Digests of sequences computed using the GA4GH digest algorithm (sha512t24u)."
required:
- lengths
- names
inherent:
- lengths
- names
Expand Down
Loading

0 comments on commit dd22153

Please sign in to comment.