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.

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.4.tar.gz (32.7 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.4-cp38-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.8+Windows x86-64

seqa_py-0.3.4-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.4-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.4-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.4.tar.gz.

File metadata

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

File hashes

Hashes for seqa_py-0.3.4.tar.gz
Algorithm Hash digest
SHA256 028fc708ba2db6f1be42ee9d7a6600d0195541af8cf49f37a70c81d9d5eb04f0
MD5 797e48d7300b05ab78d147dc6d9675e1
BLAKE2b-256 231ae17c8bb4b7940952fdab1a9cf19298dae6d2a366baa0c24f70b7d98c1d95

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seqa_py-0.3.4-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.4-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7a1e53aab37512a9916dc7360f33211ce6c5dc19b7e319267bf7fa6ca14b5d9e
MD5 b75cf77b46cb407bca0b83f8e6dd5348
BLAKE2b-256 aff29819972a5e60dc037cab7df1a9a6a08af4959787461316ed3dcbd0cfb870

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for seqa_py-0.3.4-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29abf30543bf1e320286ff3c577c99608008cec7e7f375684ca22324dee6df1b
MD5 0a2958b41e8213e548564cff6e7d5bc1
BLAKE2b-256 3b33d9a6d1c93cabe0637bf22ad698ff530409d2cb86ed27be19de0b7c58d493

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for seqa_py-0.3.4-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8097aafa372ae3ecd158257103a5fcb373a967723d50463a8b7edd588339dead
MD5 7ef026913ac371481675fa77cb4e3bca
BLAKE2b-256 d0358ae6806a1416751bb64c721b62278d0d3a1eb59507ca2eb5f53fb4526ccf

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.4-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.4-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 6ede82876e595e2f40394e1cb15d971c95236c02bcdd0d6510574219cbd1f400
MD5 bd39238980f758d9252da9f073d0acfb
BLAKE2b-256 6f7a7cd5c3c29647341d952bd29fd5400f8cf1bdbf26c1f39312cf53f4504919

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