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

Uploaded CPython 3.8+Windows x86-64

seqa_py-0.3.3-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.3-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.3-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.3.tar.gz.

File metadata

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

File hashes

Hashes for seqa_py-0.3.3.tar.gz
Algorithm Hash digest
SHA256 67867760c69b9f182d58757ad0d407e0c980d660ddf3721388e7d975ca32b0c1
MD5 3f5a9efdce0fc232012f8aa4ad4199c0
BLAKE2b-256 3d49b59a8306f67abcafe3651a8fee4933752b878ade6762b22294343be7f7f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seqa_py-0.3.3-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.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 240c965435d36cca5b1231abba3c415c442b5629f63ad2dd51b532fabae64cc8
MD5 ba0aaa72879be1e4a02a6c58576b0479
BLAKE2b-256 19d0b3e2978bfa1d98b8917c519e10cd36694a3c1c3a3521c192072e922453ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for seqa_py-0.3.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0997a9b71f49e3ace7a93521f8df1acc10e67810e222e6bf4c15a42775511dcc
MD5 8845fd30460892c1f9f676e91aee4621
BLAKE2b-256 1e23232e4f3a3f732114bc17454d355ed81e1e726ea4f0f8d76155f9455fe381

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for seqa_py-0.3.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 22bb33e09d788d928bac25f7cb44cb138292bd0b90e5f51fb38da568fb205e7f
MD5 134a8d88a53e5409ad583df8b687355b
BLAKE2b-256 2b4276ac7299667cda07b2e4490edc3cf37fce12c3c369ec2f44300414bba49d

See more details on using hashes here.

File details

Details for the file seqa_py-0.3.3-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.3-cp38-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 9e5df49dab0868b0cb0e43d41255548c5f1ac4ce5785420f25a2893ca8e2aefe
MD5 9e54d9995b70b1344a0cd15130c7ae87
BLAKE2b-256 389b805358110878fae367412021d0477c3e1fcf2653355bbfaef1cbf4bd6638

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