Skip to main content

fsspec filesystem adapter for accessing MaveDB score set data through the MaveDB API.

Project description

mavedb-fsspec

mavedb-fsspec is a read-only fsspec filesystem adapter for MaveDB. It exposes MaveDB score set data as filesystem-like paths so Python tools that understand fsspec can browse and read MaveDB data without using MaveDB API endpoints directly.

What is fsspec?

fsspec is a Python interface for working with many storage systems through a common filesystem API. Code can use familiar operations such as ls, info, open, and cat against local files, HTTP resources, cloud buckets, and custom filesystems.

mavedb-fsspec registers the mavedb:// protocol with fsspec. This lets code access MaveDB data like:

mavedb://score-sets/urn:mavedb:00000670-a-1/scores.csv

instead of manually constructing API requests.

Installation

Install from PyPI:

pip install mavedb-fsspec

Or with uv:

uv add mavedb-fsspec

fsspec and the other runtime dependencies are installed automatically.

Filesystem layout

The filesystem currently exposes score set data:

mavedb://
  score-sets/
    {urn}/
      scores.csv
      counts.csv
      variants.csv
      metadata.json
      mapped-variants.json
  my-score-sets/
    {urn}/
      scores.csv
      counts.csv
      variants.csv
      metadata.json
      mapped-variants.json

score-sets/ lists public published score sets using the MaveDB search API.

my-score-sets/ is only available when an API key is provided. It lists score sets associated with the authenticated MaveDB user.

mapped-variants.json is only listed for a score set when MaveDB has mapped variants for that score set.

Basic usage

import fsspec

fs = fsspec.filesystem("mavedb")

print(fs.ls("mavedb://", detail=False))
print(fs.ls("mavedb://score-sets", detail=False, limit=25, offset=0))

data = fs.cat("mavedb://score-sets/urn:mavedb:00000670-a-1/scores.csv")
print(data[:500].decode())

The filesystem class can also be instantiated directly:

from mavedb_fsspec import MaveDBFileSystem

fs = MaveDBFileSystem()
print(fs.ls("score-sets", detail=False, limit=25))

Authenticated usage

Use an API key to access my-score-sets/ and private score set files that your MaveDB account can read:

import fsspec

fs = fsspec.filesystem("mavedb", api_key="YOUR_MAVEDB_API_KEY")

print(fs.ls("mavedb://", detail=False))
print(fs.ls("mavedb://my-score-sets", detail=False, limit=25, offset=0))

Reading with file-like objects

mavedb-fsspec supports fsspec's file-like API:

import fsspec

with fsspec.open("mavedb://score-sets/urn:mavedb:00000670-a-1/metadata.json", "rb") as handle:
    metadata = handle.read()

Files are currently downloaded completely into memory when opened. Similarly, cat_file() downloads the complete file before applying start and end slicing; these operations do not issue HTTP range requests.

Configuration

The public MaveDB API is used by default:

fs = fsspec.filesystem("mavedb")

Advanced options:

fs = fsspec.filesystem(
    "mavedb",
    base_url="https://api.mavedb.org/api/v1",
    api_key="YOUR_MAVEDB_API_KEY",
    timeout=30.0,
)

Development

Install this repository in editable mode with the development dependencies:

python -m pip install -e ".[dev]"

Run tests with:

python -m pytest

Run Ruff with:

python -m ruff check .

Notes

This filesystem is read-only. It does not upload data to MaveDB.

File information uses -1 when the size is unknown. MaveDB endpoints can return 405 Method Not Allowed for HEAD requests, so a size may remain unknown until the file has been read.

The JSON files returned by this adapter escape literal <, >, and & characters. This keeps JSON safe for consumers that reject HTML-like content during upload, while preserving equivalent JSON string values.

License

MIT. See LICENSE.

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

mavedb_fsspec-0.1.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

mavedb_fsspec-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file mavedb_fsspec-0.1.0.tar.gz.

File metadata

  • Download URL: mavedb_fsspec-0.1.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mavedb_fsspec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9fb5ddb2a4995a11d98e941984bcadc039bcbe87d49040f4eef02bcc4756cf8a
MD5 c9f4b7f43f860274c1a982b632c50af8
BLAKE2b-256 9bf7c178507afa45458a87f4c828ca4ed5c4a0bf162386866bc4e2b7ad336a96

See more details on using hashes here.

Provenance

The following attestation bundles were made for mavedb_fsspec-0.1.0.tar.gz:

Publisher: publish.yml on PlushZ/mavedb-fsspec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mavedb_fsspec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mavedb_fsspec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mavedb_fsspec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e0334753ec23892edd4e3aa9cca3b68beeb48f008d4dea11430219fa56881b2
MD5 06a492bb40110931de34fd8940a1654c
BLAKE2b-256 41cfd23b0120d8064c374abf638f4f94298d1b6d978b8f3572a329507f75e5cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for mavedb_fsspec-0.1.0-py3-none-any.whl:

Publisher: publish.yml on PlushZ/mavedb-fsspec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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