Metadata-Version: 2.4
Name: directlfq_rs
Version: 1.0.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
License-File: LICENSE
Summary: Rust-backed directLFQ quantification for DIA-NN report.parquet and generic TSV inputs
Keywords: proteomics,mass-spectrometry,label-free-quantification,directlfq,diann
Home-Page: https://github.com/wenjiudaijiugui/directlfq-rs
Author: ShenShang
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/wenjiudaijiugui/directlfq-rs
Project-URL: Issues, https://github.com/wenjiudaijiugui/directlfq-rs/issues
Project-URL: Repository, https://github.com/wenjiudaijiugui/directlfq-rs

# directlfq_rs

`directlfq_rs` is a Python package that exposes a Rust implementation of the
core directLFQ protein quantification workflow.

This repository is a mixed Rust/Python project with a split architecture:

- the PyO3 binding crate and Python packaging live at the repository root
- the Rust quantification core lives in `crates/directlfq-core`

It is intended for fast label-free quantification from:

- DIA-NN `report.parquet` files
- Generic wide TSV matrices with `protein`, `ion`, and sample columns

The package currently focuses on the programmatic API rather than the full
feature surface of the original Python `directlfq` package.

## Features

- Native Rust execution for the main LFQ pipeline
- Direct DIA-NN `report.parquet` input support
- Generic TSV fallback for preformatted inputs
- Optional pandas DataFrame convenience wrapper
- Packaged type stubs for IDE signature and type rendering

## Repository Layout

```text
directlfq-rs/
├── pyproject.toml
├── Cargo.toml                 # PyO3 binding crate + workspace root
├── directlfq_rs/              # Python package
├── src/                       # PyO3 Rust bindings
├── tests/                     # Python-side tests
└── crates/
    └── directlfq-core/        # Rust quantification core crate
```

## Installation

Install from PyPI:

```bash
pip install directlfq_rs
```

If you install from a source distribution, a Rust toolchain is required during
build.

## Python Version Support

The package is built with PyO3 `abi3-py310`, so one wheel per platform supports
CPython 3.10 and newer Python 3 releases. The release workflow currently smoke
tests Python 3.10, 3.11, 3.12, 3.13, and 3.14.

## Release Builds

GitHub Actions builds release artifacts for:

- Linux x86_64 and aarch64
- macOS universal2
- Windows x64
- source distribution

Publishing uses PyPI Trusted Publishing from the `Build and Publish` workflow
and the `pypi` GitHub environment.

## Python API

### File-path API

```python
from directlfq_rs import quantify

results = quantify("report.parquet")
print(results["P001"])
```

`quantify()` returns a `dict[str, list[float | None]]` mapping each protein ID
to its per-sample protein intensities in linear space.

### DataFrame API

```python
import pandas as pd
from directlfq_rs import quantify_dataframe

df = pd.DataFrame(
    {
        "protein": ["P001", "P001"],
        "ion": ["I1", "I2"],
        "sample_0": [100.0, 120.0],
        "sample_1": [200.0, 240.0],
    }
)

protein_df = quantify_dataframe(df)
print(protein_df)
```

## Supported Inputs

### DIA-NN `report.parquet`

For DIA-NN output, `.parquet` input is auto-detected and parsed as a precursor
report.

### Generic TSV

For generic wide-table input, the expected shape is:

- one protein column
- one ion column
- one or more sample columns in linear intensity space

Empty cells are treated as missing values.

## Scope

This package ships the Rust-backed quantification core and a compact Python API.
It does not aim to mirror every workflow and helper exposed by the upstream
`directlfq` package.

## License

This project is licensed under the MIT License.

