Skip to main content

ra-bio

Public runtime library for microorganism risk-reference data derived from NITE/MRINDA.

ra_bio is the canonical non-MCP API for direct consumers. It ships a bundled SQLite database generated by the ra-bio-scraper repository.

What it does

  • resolves microorganism names against canonical names and synonyms
  • supports fuzzy search for misspellings and historical names
  • returns aggregated organism profiles with structured law/risk annotations
  • keeps raw evidence under risk_annotations while also exposing grouped sections like regulations and biosafety

Install

pip install ra-bio
uv add ra-bio

Usage

from ra_bio import get_bio_database, search_organisms, lookup_bio_profile

db = get_bio_database()

lookup = db.lookup(query="Mortierella wolfii", language="ja")
search = db.search(query="Granulicatella adiacen", limit=5, min_score=0.6)
sources = db.get_source_snapshots()

search_via_helper = search_organisms(query="Granulicatella adiacen", limit=5, min_score=0.6)
lookup_via_helper = lookup_bio_profile(query="Mortierella wolfii", language="ja")

Examples

Search a synonym or misspelling and get the current accepted name:

from ra_bio import get_bio_database

db = get_bio_database()
result = db.search(query="Mortierella wolfii", limit=3, min_score=0.6)

print(result["hits"][0]["canonical_name"])
# Actinomortierella wolfii

Look up a canonical profile with host and disease information:

from ra_bio import get_bio_database

db = get_bio_database()
profile = db.lookup(query="Vibrio salmonicida", language="ja")

print(profile["profile"]["canonical_name"])
# Aliivibrio salmonicida

print(profile["profile"]["hosts"])
# ['サケ科魚類']

print(profile["profile"]["diseases"])
# ['冷水性ビブリオ病*']

Look up law and biosafety annotations in a stable structure:

from ra_bio import get_bio_database

db = get_bio_database()
profile = db.lookup(query="Anaplasma bovis", language="ja")

print(profile["profile"]["regulations"]["cartagena"]["values"])
# ['クラス2']

print(profile["profile"]["biosafety"]["bsl_bsj"]["values"])
# ['BSL2']

Inspect the bundled source-update metadata:

from ra_bio import get_bio_database

db = get_bio_database()
for row in db.get_source_snapshots():
    print(row["dataset_id"], row["source_filename"], row["source_version"], row["fetched_at"])

Example search result:

{
  "cluster_id": "ORG-000093",
  "canonical_name": "Actinomortierella wolfii",
  "preferred_scientific_name": "Actinomortierella wolfii",
  "datasets": ["fungi"],
  "score": 1.0,
  "match_type": "exact_raw",
  "matched_value": "Mortierella wolfii",
  "match_sources": ["canonical_name", "scientific_name", "synonym:m"],
  "regulation_keys": [],
  "biosafety_keys": ["trba"]
}

Example lookup summary:

{
  "matched": true,
  "profile": {
    "canonical_name": "Granulicatella adiacens",
    "scientific_names": [
      "Abiotrophia adiacens",
      "Granulicatella adiacens",
      "Streptococcus adjacens"
    ],
    "datasets": ["bacteria"],
    "regulations": {
      "cartagena": {
        "values": ["クラス2"]
      }
    },
    "biosafety": {
      "bsl_bsj": {
        "values": ["BSL1*"]
      },
      "trba": {
        "values": ["2"]
      }
    }
  }
}

Example source snapshot metadata:

[
  {
    "dataset_id": "bacteria",
    "source_filename": "risk_bacteria_20260120.csv",
    "source_version": "20260120"
  },
  {
    "dataset_id": "bacteria_fish",
    "source_filename": "risk_bacteria_fish_20240924.csv",
    "source_version": "20240924"
  },
  {
    "dataset_id": "fungi",
    "source_filename": "risk_fungi.xlsx",
    "source_version": "20260120"
  }
]

Public runtime API:

  • get_bio_database(db_path: str | None = None)
  • search_organisms(query, mode="auto", dataset=None, limit=20, min_score=0.6, db_path=None)
  • lookup_bio_profile(query=None, scientific_name=None, language="ja", db_path=None)
  • get_bio_source_snapshots(db_path=None)
  • get_bio_runtime_status(db_path=None)
  • BioDatabase.get_source_snapshots()
  • BioDatabase.get_runtime_status()
  • BioDatabase.lookup(query=None, scientific_name=None, language="ja")
  • BioDatabase.search(query, mode="auto", dataset=None, limit=20, min_score=0.6)

Lookup payload highlights:

  • profile["regulations"]: 法令・制度の注記を安定キーで参照
  • profile["biosafety"]: BSL / TRBA などの注記を参照
  • profile["designations"]: 魚病菌・植物病原菌・住環境菌などの指定区分を参照
  • profile["pathogen_profiles"]: 魚病データセット由来の宿主・疾病プロファイルを参照
  • profile["risk_annotations"]: 元データに近い証跡を保持

Default behavior:

  • if db_path is omitted, ra_bio uses the packaged bundled SQLite database
  • db_path may point to:
    • a direct SQLite file
    • a checked-out ra-bio directory containing bio.sqlite3

Runtime artifact

The canonical runtime artifact is the bundled SQLite database:

  • packaged path: src/ra_bio/data/bio.sqlite3
  • published repo artifact: bio.sqlite3

Normal installed consumers should rely on the packaged bundled database. The public repo intentionally stays small: detailed raw CSV/HTML retention is handled by ra-bio-scraper, not by ra-bio.

Data sources

The current dataset is derived from these NITE/MRINDA downloads:

  • https://www.nite.go.jp/mrinda/list/risk/download/bacteria
  • https://www.nite.go.jp/mrinda/list/risk/download/bacteria_fish
  • https://www.nite.go.jp/mrinda/list/risk/download/fungi

Source update metadata

Source update information is part of the public runtime data.

  • the SQLite bundle stores source_filename, source_version, fetched_at, and content_hash
  • the public repo keeps parsed/source_snapshots.jsonl
  • consumers can inspect the same information via BioDatabase.get_source_snapshots()

Detailed raw CSV files, extracted CSVs, and HTML snapshots are retained in ra-bio-scraper.

Development

uv sync --group dev
uv run pre-commit install
uv run pre-commit run --all-files
uv run pytest -q

Release

PyPI publishing is handled by GitHub Actions only when a matching v* tag is pushed. See docs/release.md for the cleanup and release checklist.

Download files

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

Source Distribution

ra_bio-0.2.0.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

ra_bio-0.2.0-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

Details for the file ra_bio-0.2.0.tar.gz.

File metadata

  • Download URL: ra_bio-0.2.0.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ra_bio-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b098d57d0f39ba85eb3fb059165ac6a5f965c68addcc0486f7d53ef4f6d3d821
MD5 8d0971e7f1f15a0609ea069e7af1a2e9
BLAKE2b-256 6832634738fe39cb917a5c432401dbe302ce6e9b52bf93469f093b1362ad80b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ra_bio-0.2.0.tar.gz:

Publisher: publish.yml on Ameyanagi/ra-bio

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

File details

Details for the file ra_bio-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ra_bio-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ra_bio-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a17a8cf3e516e71e453449a69e8d8d12d3fcd2334e4832d17b53de53adb2ad68
MD5 12f3489700dff0ea90245d560351cdc3
BLAKE2b-256 cfb1c87dd7d52cb02d71c56934567c4213fa064b9cab23adb8c9b786a55a1cd8

See more details on using hashes here.

Provenance

The following attestation bundles were made for ra_bio-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Ameyanagi/ra-bio

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