Metadata-Version: 2.5
Name: jrif
Version: 0.2.1
Summary: Peptide retention-time and ion-mobility prediction: pretrained bases, per-experiment calibration, full-library prediction.
Project-URL: Repository, https://github.com/danielgeiszler/JRIF
Author-email: Daniel Geiszler <dgeiszler@parallelsq.org>
License-Expression: Apache-2.0
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
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: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: <3.15,>=3.11
Requires-Dist: pandas>=2.0
Requires-Dist: polars>=1.0
Requires-Dist: pyarrow>=14
Requires-Dist: scikit-learn>=1.4
Requires-Dist: scipy>=1.11
Requires-Dist: torch>=2.2
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# JRIF

Peptide retention time (RT) and ion mobility (IM) prediction.

```
pip install jrif
```

## Models

| name | predicts | chemistry |
|---|---|---|
| `rt_lf` | retention time | label-free |
| `rt_psmtag` | retention time | PSMtag |
| `im_psmtag` | ion mobility | PSMtag |

Weights are bundled with the package.

## Features

- Calibrate a model to your experiment using your identified peptides
- Predict RT/IM for a full spectral library, output in your experiment's units
- New modifications in your data are handled automatically
- Runs on GPU when available (CUDA or Apple), otherwise CPU

## Usage

Calibrate on your IDs, then predict your library:

```python
import pandas as pd
from jrif import RTPredictor
from jrif.checkpoints import checkpoint_path

ids = pd.read_csv("psm_ids.tsv", sep="\t")      # columns: seq, rt
lib = pd.read_csv("library.tsv", sep="\t")      # column:  seq

p = RTPredictor.from_checkpoint(checkpoint_path("rt_psmtag"))
p.calibrate(ids)
lib["pred_rt"] = p.predict(lib)
```

Ion mobility (needs a charge column):

```python
from jrif import IMPredictor

m = IMPredictor.from_checkpoint(checkpoint_path("im_psmtag"))
m.calibrate(ids)                                # columns: seq, charge, im
lib["pred_im"] = m.predict(lib)                 # columns: seq, charge
```

Sequence format: residues, with modifications as delta masses
(`S[+79.9663]`, `C[+57.0215]`) or UniMod (`S(UniMod:21)`). N-terminal
modifications are a leading `n[+mass]`, C-terminal ones a trailing `c[+mass]`.
A bare `C` is unmodified cysteine. Masses match at the precision you write
them, so `S[80]` uses the model's `S[+79.9663]`. The older spellings
`C[160]`, `M[147]`, `K[308]` and `.[308]` are also accepted.

Modifications the model has never seen (e.g. `S[80]`) don't need any setup:
`calibrate()` adds new tokens to the vocabulary and learns them from your
IDs automatically.

Save and reload a calibrated model:

```python
p.save("my_experiment.pt")
p = RTPredictor.from_checkpoint("my_experiment.pt")
```

## Training new base models (maintainers)

```
uv run jrif-train-label-free --data-path <library.tsv>
uv run jrif-train-psmtag    --data-path <library.tsv | report-lib.parquet>
```
