NAME

Bioconda::Packages::DB - Locate, load and save the bundled JSON package database.

DESCRIPTION

A tiny storage layer shared by the read-only API (Bioconda::Packages) and the maintainer tooling (Bioconda::Packages::Updater). The on-disk format is a single JSON file; keeping all I/O here means a different backend (e.g. SQLite) could be slotted in later without touching callers.

DATABASE FORMAT

{
  "meta": {
    "generated_at": "2026-11-24T10:00:00Z",
    "generator":    "Bioconda::Packages::Updater 0.01",
    "recipes_commit": "<git sha or null>",
    "package_count": 11500,
    "removed_count": 3
  },
  "packages": {
    "samtools": {
      "name": "samtools",
      "current_version": "1.25",
      "recipe_versions": ["0.1.18", "...", "1.25"],
      "published_versions": [...],   # from anaconda.org (optional)
      "downloads": 123456,           # from anaconda.org (optional)
      "build_number": 0,
      "noarch": null,
      "summary": "...",
      "license": "MIT",
      "license_family": null,
      "home": "...",
      "dev_url": "...",
      "doc_url": "...",
      "identifiers": ["biotools:samtools"],
      "outputs": ["samtools"],
      "depends": { "build": [...], "host": [...], "run": [...] },
      "recipe_path": "recipes/samtools",
      "is_removed": false,
      "removed_at": null,
      "first_seen": "2026-11-24T10:00:00Z",
      "last_seen":  "2026-11-24T10:00:00Z"
    }
  }
}

locate_db

my $path = Bioconda::Packages::DB->locate_db;
my $path = Bioconda::Packages::DB->locate_db($explicit_path);

Returns the path to the database, searching in order:

1. an explicit path argument (if given);
2. the BIOCONDA_PACKAGES_DB environment variable;
3. File::ShareDir (when the dist is installed and that module is present);
4. the share/ directory relative to this module (running from the source tree).

Dies if nothing can be found.

load

my $data = Bioconda::Packages::DB->load($path);

Reads and decodes the JSON database. Dies on failure.

save

Bioconda::Packages::DB->save($path, $data);

Encodes $data as canonical JSON and writes it atomically (temp file + rename). If $path ends in .gz the output is gzip-compressed and written compact (it is ~1.4MB that way); otherwise it is pretty-printed for human readability.