Skip to main content

Sassy Python Bindings

🐍 The python bindings for Sassy

Installation

Pip.

pip install sassy-rs

(as sassy was already taken we chose sassy-rs)

From source. In the root of the repository, run:

maturin develop --features python

You need Maturin for this, see maturin:

Usage

A simple usage is as follows:

import sassy
pattern = b"ATCGATCG"
text = b"GGGGATCGATCGTTTT"
# alphabet: ascii, dna, iupac
searcher = sassy.Searcher("dna")
matches = searcher.search(pattern, text, k=1)
for i, match in enumerate(matches):
    print(f"Match {i+1}:")
    print(f"    Start: {match.text_start}")
    print(f"    End: {match.text_end}")
    print(f"    Cost: {match.cost}")
    print(f"    Strand: {match.strand}")
    print(f"    CIGAR: {match.cigar}")

This finds 3 matches:

Match 1:
    Start: 4
    End: 12
    Cost: 0
    Strand: +
    CIGAR: 8=
Match 2:
    Start: 6
    End: 14
    Cost: 1
    Strand: -
    CIGAR: 6=X=
Match 3:
    Start: 2
    End: 10
    Cost: 1
    Strand: -
    CIGAR: X7=

Further options are sassy.Searcher(alpha=0.5) to allow overhang alignments, sassy.Searcher("dna", rc=False) to disable reverse complements for DNA or IUPAC strings, and sassy.Searcher("dna", max_n_frac=0.1) to drop matches whose aligned text region is more than 10% N bases. Here, max_n_frac is a fraction in [0, 1] where omitting it or using 1.0 disables the filter. searcher.search is the simple function to search one pattern in one text, while searcher.search_many takes multiple patterns and multiple texts and searches each pattern in each text, possibly in multiple threads.

See sassy/example.py for a larger example.

Type Hints

This package ships PEP 561 type stubs (sassy/py.typed + sassy/__init__.pyi) so that type checkers and IDEs can provide autocomplete and type checking out of the box.

The .pyi stubs are auto-generated by the PyPI publishing workflow, and are not stored in git. To manually generate stubs for local testing:

# macOS
RUSTFLAGS="-C link-arg=-undefined -C link-arg=dynamic_lookup" cargo build --features python
cargo run --features python-stubs --bin gen_stubs -- target/debug/libsassy.dylib

# Linux
cargo build --features python
cargo run --features python-stubs --bin gen_stubs -- target/debug/libsassy.so

Once the stubs have been generated, type-checking for the sassy Python library will be enabled. See sassy/example_typed.py for a typed example that exercises all public APIs.

Running the example requires the sassy package be installed in your environment.

To install maturin and the package in an isolated environment, then run the typed example you can use a single uv command:

uv run \
    --with maturin \
    sh -c 'maturin develop && python python/sassy/example_typed.py'

Running type checking on the type exampled requires mypy be installed in your environment.

To install mypy in an isolated environment then run type checking on the typed example you can use a single uv command:

uv run \
    --with mypy \
    sh -c 'mypy python/sassy/example_typed.py'

Troubleshooting

1. I could install sassy-rc but no modules/functions are found.

When creating an issue please include the output of print(dir(sassy)) if you were able to install sassy-rs but no functions/modules were found.

Your output might look like:

['__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']

Whereas it should look like:

['Match', 'Searcher', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'features']

2. Other sassy issues.

If you were able to install sassy, but have other issues please also add the output of sassy.features().

Metadata

Release files for sassy-rs 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sassy-rs 0.3.1
File Size Uploaded Provenance Actions
sassy_rs-0.3.1.tar.gz 1.5 MB Without provenance Details for sassy_rs-0.3.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sassy-rs 0.3.1
File Interpreter ABI Platform Actions
sassy_rs-0.3.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details for sassy_rs-0.3.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
sassy_rs-0.3.1-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details for sassy_rs-0.3.1-cp38-abi3-macosx_11_0_arm64.whl

Total release size: 2.4 MB

Release files / sassy_rs-0.3.1.tar.gz

Download URL sassy_rs-0.3.1.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
7619821a267e8ed1f12a758e3fb847ea91f1fcb688ca096915b59db25b6cb257
BLAKE2b-256 checksum
How to use checksums
4ceaa9f1049c7849091990d26e2ac1f4fe7ab05b4a04e4ecbd36e971bb4dfb24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / sassy_rs-0.3.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL sassy_rs-0.3.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 483.9 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
173a29d9bd040019b00d3778133707e190157d87398b6aeec258ad60014bfa30
BLAKE2b-256 checksum
How to use checksums
0533d61343b008f4351019242dc36c6820b8dc3ee111a0ee0a35e6914c3cf97f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / sassy_rs-0.3.1-cp38-abi3-macosx_11_0_arm64.whl

Download URL sassy_rs-0.3.1-cp38-abi3-macosx_11_0_arm64.whl
Size 429.3 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
578ffbcfefc95abbeb1044f33db4a5e8aed88f39f077dc3aba3618b33fe79c7f
BLAKE2b-256 checksum
How to use checksums
4980709a1caeec2723140f039fcec482f0dee381664872f101be20daf17c16c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for sassy-rs 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page