Skip to main content

Python library for querying genomic files across cloud and local storage

Project description

seqa_py

Python library for querying genomic files (BAM, VCF, BED, BigWig, BigBed, FASTA, GFF, GTF) across local and cloud storage. Built on seqa_core via PyO3.

Installation

Requires uv and a Rust toolchain (rustup).

git clone <repo>
cd seqa_py
uv run maturin develop   # compile the Rust extension
uv sync --all-groups     # install runtime + dev dependencies (pytest, ruff, maturin)

After any change to src/lib.rs, re-run maturin develop.

Quick start

from seqa_py import file_search

lines = file_search("s3://my-bucket/sample.vcf.gz", "chr1:100000-200000")
for line in lines:
    print(line)

file_search

file_search(
    file_path: str,
    coordinates: str,
    include_header: bool = True,
    header_only: bool = False,
    genome: str | None = None,
) -> list[str]

Returns a list of tab-delimited result lines.

Parameter Description
file_path Local path or cloud URI (s3://, az://, gs://, https://)
coordinates Genomic region — see formats below
include_header Include file header lines in the result (default True)
header_only Return only header lines, no data records (default False)
genome Reference build for whole-chromosome length resolution: hg38, hg19, grch38, grch37

Coordinate formats

Input Meaning
chr1:100000-200000 Range
chr1:100000 Single position
chr1:100,000-200,000 Commas ignored
chr1 Whole chromosome

Supported file types

Extension Format
.bam BAM (requires .bai index alongside)
.vcf.gz VCF (requires .tbi index)
.bed.gz / .bed BED (requires .tbi index)
.bedgraph.gz BedGraph (requires .tbi)
.gff.gz GFF3 (requires .tbi)
.gtf.gz GTF (requires .tbi)
.bw / .bigwig BigWig (self-indexed)
.bb / .bigbed BigBed (self-indexed)
.fa / .fasta FASTA (requires .fai index)

Index files must be at <file>.<ext> — e.g. sample.bam.bai, variants.vcf.gz.tbi. BigWig and BigBed embed their own index and need no companion file.

Errors

file_search raises ValueError for invalid paths, unsupported extensions, bad coordinates, or search failures.


Cloud credentials

Set environment variables before querying cloud files. A .env file in the working directory is loaded automatically.

AWS S3

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
S3_BUCKET=

Azure Blob Storage

AZURE_TENANT_ID=
AZURE_CLIENT_ID=
AZURE_CLIENT_SECRET=
AZURE_STORAGE_ACCOUNT=
AZURE_STORAGE_CONTAINER=

Google Cloud Storage

GOOGLE_STORAGE_ACCOUNT=
GOOGLE_BUCKET=

Copy .env.example to .env and fill in the values.


Development

uv run maturin develop          # rebuild Rust extension
uv sync --all-groups            # restore dev dependencies (maturin develop resets the venv)
uv run pytest                   # all tests
uv run pytest tests/test_local.py -v    # local tests only (no cloud creds needed)
uv run ruff check .             # lint
uv run ruff format .            # format

Tests in tests/test_cloud.py are skipped automatically unless the relevant credentials are present in the environment.


Releasing

Releases are published to PyPI by .github/workflows/publish.yml, triggered by pushing a v* tag. The workflow builds wheels for Linux (x86_64, aarch64), macOS (universal2), and Windows (x86_64), plus an sdist, then uploads via maturin upload.

One-time setup: a pypi GitHub environment with a PYPI_API_TOKEN secret.

To cut a release:

  1. Bump version in Cargo.toml. The workflow's check-version job fails if the tag and Cargo.toml version don't match.
  2. Commit the bump.
  3. Tag and push:
    git tag vX.Y.Z
    git push origin main --tags
    
  4. Watch the Publish to PyPI workflow in the Actions tab.

Uploads use --skip-existing, so re-running on an already-published version is safe.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seqa_py-0.3.5.tar.gz (33.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

seqa_py-0.3.5-cp38-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

seqa_py-0.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

seqa_py-0.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

seqa_py-0.3.5-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (7.3 MB view details)

Uploaded CPython 3.8+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file seqa_py-0.3.5.tar.gz.

File metadata

  • Download URL: seqa_py-0.3.5.tar.gz
  • Upload date:
  • Size: 33.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for seqa_py-0.3.5.tar.gz
Algorithm Hash digest
SHA256 0c12d195544b5d51a431c2fa2bf4801e072b55685c8f3d45713f7901792364b2
MD5 264d65656ef566c4b167e55f65ef9433
BLAKE2b-256 82e72c51f417eb6eedebb379dba4783a5c8fa675b9369d936a33aab7d95ab39d

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.5-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: seqa_py-0.3.5-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for seqa_py-0.3.5-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e6a0646b6d4af6ed5094a8866f3dfa953829b0bc6d9037b0eb2469cf98eb3606
MD5 09a095cf56cea53e65325188465689af
BLAKE2b-256 f9025543f751f12bea53eb502f108cf7f8c924ecd75c5016c6fc3c2b60d15d38

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for seqa_py-0.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2667ccbe3b92cb423927391b2a2ecbce6faa9f525c3cb0aa0dc82f983465f830
MD5 53a9929d78dc0d80393f43ca2187b4d4
BLAKE2b-256 443a05f0c7265ddf47c20a48e22817123a8a2869e58c527ec6e184cf4770b58c

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for seqa_py-0.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 87b2a8b7723c4525a6a9b713fa07edbc81291d8db58e2a09663df08484b20df2
MD5 113b17f3852b9f8e9f6cfc9f8394d5aa
BLAKE2b-256 dd1d7c23f9b9ce233a5ab897ae3a977a9460bf4766614f96c9f9b24bbf7723d4

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.5-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for seqa_py-0.3.5-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 ba0263a362b03d0ab1452503e34f373f6e59fa65b91d72cfcd402fc2ae675931
MD5 39d57cb384258121673231c25371a387
BLAKE2b-256 a8bb7fae8154443f9fe9ccd094111650f23361d32a5dbc2f1f6f7ca97fd3ebe7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page