Metadata-Version: 2.5
Name: ra-library
Version: 0.4.1
Summary: Chemical risk assessment library based on publicly documented methodology references
Project-URL: Repository, https://github.com/Ameyanagi/ra-library
Author-email: Ameyanagi <contact@ameyanagi.com>
License: MIT
License-File: LICENSE
Keywords: chemical-safety,chemical-screening,occupational-health,risk-assessment
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Chemistry
Requires-Python: >=3.12
Requires-Dist: pydantic>=2.0
Description-Content-Type: text/markdown

# RA Library

<p align="center">
  <img src="assets/logo.png" alt="RA Suite logo" width="180">
</p>

Chemical risk assessment library built from publicly documented methodology references.

## Overview

This library implements an independent risk assessment workflow with detailed explanations, recommendations, and optional bundled SQLite reference data.

## Features

- **Verbose Calculations**: Every step is explained with references
- **Verified Scenario Analysis**: Recalculate bounded control ranges and explicit batches
- **Auditable Recommendations**: Preserve mixture, method version, risk domains, and baseline fingerprint
- **Limitation Transparency**: Explains when Level I is impossible
- **Official Japanese Terminology**: v3.2.1 workbook labels with sheet/cell and SHA-256 provenance

## Installation

```bash
uv add ra-library
```

Or with pip: `pip install ra-library`.

## Usage

```python
from ra_library import AssessmentInput, Substance
from ra_library.calculators import calculate_inhalation_risk

# Create assessment input
input = AssessmentInput(
    title="Toluene handling",
    product_property=PropertyType.LIQUID,
    amount_level=AmountLevel.MEDIUM,
    ventilation=VentilationLevel.INDUSTRIAL,
)

# Calculate risk
result = calculate_inhalation_risk(input, substance)
print(f"Risk Level: {result.risk_level.name}")
print(f"RCR: {result.rcr:.4f}")
```

Verified control ranges are available from the service layer:

```python
from ra_library.services import calculate_risk

result = calculate_risk(
    substances=[{"cas_number": "108-88-3", "content_percent": 100}],
    preset="lab_organic",
    include_recommendations="verified",
    recommendation_scope={
        "ventilation": ["local_enclosed", "sealed"],
        "hours": [4, 2, 1],
        "max_combination_size": 2,
        "max_scenarios": 30,
    },
    language="ja",
)
print(result.data["recommendation_analysis"])
```

## Development

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

## Release

A matching `v*` tag tests and publishes distributions to PyPI, then attaches
the same artifacts to a GitHub Release.

## Notes

- The package includes extracted terminology and provenance, not the original XLSM workbook.
- This is an independent implementation and is not an official MHLW distribution.
- Public methodology documents may be cited for interoperability and validation, but official workbook assets are not redistributed here.

## References

- Public CREATE-SIMPLE design and manual documents
- HSE COSHH Essentials
- ECETOC TRA
- Potts-Guy Equation for dermal absorption
