Skip to content
openvaxPublic

About

Serializable collection class with filtering and grouping methods

Resources

Stars

0 stars

Watchers

5 watching

Forks

Repository files navigation

Tests Coverage Status Documentation PyPI

sercol

sercol provides Collection, a sequence that filters and groups while keeping its collection type and source metadata, and saves to JSON through serializable. It is the base class for varcode's VariantCollection and EffectCollection and mhctools' BindingPredictionCollection, so their filtering and grouping behave the same.

Install

python -m pip install sercol

sercol needs Python 3.11 or later; it installs serializable and pandas 3.

Quick start

from sercol import Collection

values = Collection([5, 2, 3, 2])
selected = values.filter(lambda value: value >= 3)
groups = values.groupby(lambda value: value % 2)
print(list(selected))
print({key: list(group) for key, group in groups.items()})
[5, 3]
{1: [5, 3], 0: [2, 2]}

filter() returns a new collection and groupby() a dictionary of collections, each of the original class with the same distinct, sort_key and sources. The original collection is unchanged.

Documentation

The documentation covers, in reading order:

  1. Getting started: filter, group, save and reload.
  2. Select, order and track values: duplicates, sorting, threshold lookups, multiple groups, source metadata and subclassing.
  3. API reference.

Development

python -m pip install -e . pytest pytest-cov ruff
./lint.sh   # ruff check
./test.sh   # pytest with coverage
python -m pip install -r requirements-docs.txt
./docs.sh   # mkdocs build --strict, then a rendered-link check
python scripts/check_docs_examples.py   # run docs examples, compare output

License

Apache 2.0; see LICENSE.

About

Serializable collection class with filtering and grouping methods

Resources

Stars

0 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages