Skip to content

Commit 51cb69b

Browse files
authored
Merge pull request #18 from CompOmics/new-api
IM2Deep 2.0 API
2 parents d82de26 + 81ff852 commit 51cb69b

47 files changed

Lines changed: 5677 additions & 2154 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
name: Publish
22

33
on:
4-
workflow_dispatch:
54
release:
65
types: [created]
6+
workflow_dispatch:
77

88
jobs:
9-
publish:
9+
build-python-package:
1010
runs-on: ubuntu-latest
11-
environment:
12-
name: pypi
13-
url: https://pypi.org/p/im2deep
1411
permissions:
15-
id-token: write
12+
contents: read
13+
1614
steps:
17-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v6
1816

19-
- name: Set up Python
20-
uses: actions/setup-python@v4
17+
- uses: actions/setup-python@v5
2118
with:
22-
python-version: "3.10"
19+
python-version-file: "pyproject.toml"
2320

24-
- name: Install dependencies
25-
run: |
26-
python -m pip install --upgrade pip build
21+
- uses: astral-sh/setup-uv@v7
22+
with:
23+
enable-cache: true
2724

2825
- name: Build
29-
run: python -m build
26+
run: uv build --no-sources
27+
28+
- name: Upload dists
29+
uses: actions/upload-artifact@v7
30+
with:
31+
name: python-package-distributions
32+
path: dist/
33+
if-no-files-found: error
3034

31-
- name: Install
32-
run: pip install dist/im2deep-*.whl
35+
publish-python-package:
36+
needs: build-python-package
37+
runs-on: ubuntu-latest
38+
permissions:
39+
id-token: write
3340

34-
- name: Test package
35-
run: |
36-
im2deep --help
41+
steps:
42+
- name: Download dists
43+
uses: actions/download-artifact@v8
44+
with:
45+
name: python-package-distributions
46+
path: dist/
3747

3848
- name: Publish to PyPI
3949
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
lint-python-package:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- uses: astral-sh/setup-uv@v7
20+
with:
21+
enable-cache: true
22+
23+
- name: Lint
24+
uses: astral-sh/ruff-action@v3
25+
with:
26+
src: "im2deep"
27+
28+
- name: Check formatting
29+
uses: astral-sh/ruff-action@v3
30+
with:
31+
args: "format --check --diff im2deep"
32+
src: "im2deep"
33+
34+
typecheck-python-package:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v6
38+
39+
- uses: actions/setup-python@v6
40+
with:
41+
python-version: "3.12"
42+
43+
- uses: astral-sh/setup-uv@v7
44+
with:
45+
enable-cache: true
46+
47+
- name: Install the project
48+
run: uv sync --group dev
49+
50+
- name: Type check
51+
run: uv run ty check im2deep
52+
53+
test-python-package:
54+
needs: [lint-python-package, typecheck-python-package]
55+
runs-on: ubuntu-latest
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
python-version: ["3.11", "3.12", "3.13", "3.14"]
60+
61+
steps:
62+
- uses: actions/checkout@v6
63+
64+
- uses: actions/setup-python@v6
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
68+
- uses: astral-sh/setup-uv@v7
69+
with:
70+
enable-cache: true
71+
72+
- name: Install the project
73+
run: uv sync --group dev
74+
75+
- name: Run tests
76+
run: uv run pytest
77+
78+
- name: Prune cache
79+
run: uv cache prune --ci

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@ IM2Deep.code-workspace
111111

112112
# Testing
113113
test_data/
114-
test.ipynb
114+
test.ipynb
115+
116+
# Profiles
117+
profiles/

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ cd IM2Deep
2323
python -m venv venv
2424
source venv/bin/activate # On Windows: venv\Scripts\activate
2525

26-
# Install in development mode
27-
pip install -e .[dev,test]
26+
# Install dependencies (core + dev group)
27+
uv sync --group dev
2828
```
2929

3030
## Code Standards

README.md

Lines changed: 84 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,98 @@ Collisional cross-section prediction for (modified) peptides.
44
---
55
## Introduction
66

7-
IM2Deep is a CCS predictor for (modified) peptides.
8-
It is able to accurately predict CCS for modified peptides, even if the modification wasn't observed during training.
7+
IM2Deep is a deep learning-based CCS predictor for (modified) peptides. It accurately predicts collisional cross-section (CCS) values for modified peptides, even if the modification wasn't observed during training. The tool supports both single-conformer and multi-conformer predictions for peptide ions.
98

109
## Installation
1110
Install with pip:
1211

13-
`pip install im2deep`
14-
15-
If you want to use the multi-output model for CCS prediction of multiconformational peptide ions, use the following installation command:
12+
```bash
13+
pip install im2deep
14+
```
1615

17-
`pip install 'im2deep[er]'`
16+
For local development/docs:
17+
```bash
18+
uv sync --group dev --group docs
19+
```
1820

1921
## Usage
20-
### Basic CLI usage:
21-
```sh
22+
23+
### Command Line Interface (CLI)
24+
25+
**Basic prediction:**
26+
```bash
2227
im2deep <path/to/peptide_file.csv>
2328
```
24-
If you want to calibrate your predictions (HIGHLY recommended), please provide a calibration file:
25-
```sh
26-
im2deep <path/to/peptide_file.csv> --calibration-file <path/to/peptide_file_with_CCS.csv>
29+
30+
**With calibration (HIGHLY recommended):**
31+
```bash
32+
im2deep <path/to/peptide_file.csv> --calibration-precursors <path/to/calibration_file.csv>
2733
```
28-
To use the multi-output prediction model on top of the original model, provide the -e flag
29-
(make sure you have the optional dependencies installed!):
30-
```sh
31-
im2deep <path/to/peptide_file.csv> --calibration-file <path/to/peptide_file_with_CCS.csv> -e
34+
35+
**Calibration options:**
36+
- `--calibrate-per-charge`: Calculate separate calibration shift factors per charge state (recommended, default true)
37+
- `--use-charge-state`: Charge state for global calibration when --calibrate-per-charge is disabled
38+
39+
**Multi-conformer prediction:**
40+
To use the multi-output prediction model (requires optional dependencies):
41+
```bash
42+
im2deep <path/to/peptide_file.csv> --calibration-precursors <path/to/calibration_file.csv> --multi
43+
```
44+
45+
**Output options:**
46+
```bash
47+
im2deep <path/to/peptide_file.csv> --output-file predictions.csv
3248
```
33-
For an overview of all CLI arguments, run `im2deep --help`.
3449

35-
## Input files
36-
Both peptide and calibration files are expected to be comma-separated values (CSV) with the following columns:
37-
- `seq`: unmodified peptide sequence
38-
- `modifications`: every modifications should be listed as `location|name`, separated by a pipe character (`|`)
39-
between the location, the name, and other modifications. `location` is an integer counted starting at 1 for the
40-
first AA. 0 is reserved for N-terminal modifications, -1 for C-terminal modifications. `name` has to correspond
41-
to a Unimod (PSI-MS) name.
42-
- `charge`: peptide precursor charge
43-
- `CCS`: collisional cross-section (only for calibration file)
50+
For a complete overview of all CLI arguments, run:
51+
```bash
52+
im2deep --help
53+
```
54+
55+
### Python API
56+
57+
IM2Deep can also be used programmatically:
4458

45-
For example:
59+
```python
60+
from im2deep import predict, predict_and_calibrate
61+
from psm_utils import PSMList
62+
63+
# Load your peptides as PSMList
64+
psm_list = PSMList(psm_list=[...]) # or use psm_utils.io.read_file()
65+
66+
# Simple prediction
67+
predictions = predict(psm_list)
68+
69+
# Prediction with calibration
70+
psm_list_calibration = PSMList(psm_list=[...]) # Must contain CCS values
71+
calibrated_predictions = predict_and_calibrate(
72+
psm_list=psm_list,
73+
psm_list_cal=psm_list_calibration
74+
)
75+
```
76+
77+
## Input Files
78+
79+
### Standard Format
80+
IM2Deep accepts any format supported by [psm_utils](https://github.com/compomics/psm_utils), including:
81+
- Peptide Record (.peprec)
82+
- MaxQuant msms.txt
83+
- MSFragger PSM files
84+
- And more...
85+
86+
### Legacy CSV Format
87+
Alternatively, use comma-separated values (CSV) with the following columns:
88+
89+
- **`seq`**: Unmodified peptide sequence
90+
- **`modifications`**: Modifications listed as `location|name`, separated by pipe (`|`) characters
91+
- `location`: Integer starting at 1 for the first amino acid
92+
- `0` = N-terminal modification
93+
- `-1` = C-terminal modification
94+
- `name`: Must correspond to a Unimod (PSI-MS) name
95+
- **`charge`**: Peptide precursor charge state
96+
- **`CCS`**: Collisional cross-section (only required for calibration files)
97+
98+
**Example:**
4699

47100
```csv
48101
seq,modifications,charge,CCS
@@ -54,6 +107,11 @@ DEELIHLDGK,,2,383.8693416055445
54107
IPQEKCILQTDVK,5|Butyryl|6|Carbamidomethyl,3,516.2079366048176
55108
```
56109

110+
## Important Notes
111+
112+
- **Calibration**: Highly recommended for accurate predictions. Calibration corrects for systematic differences between predicted and observed CCS values.
113+
- **Charge states**: IM2Deep predictions are reliable for charge states up to z=6. PSMs with higher charge states are automatically filtered out during validation.
114+
57115
## Citing
58116
If you use IM2Deep within the context of [(TI)MS<sup>2</sup>Rescore](https://github.com/compomics/ms2rescore), please cite the following:
59117
> **TIMS²Rescore: A DDA-PASEF optimized data-driven rescoring pipeline based on MS²Rescore.**
@@ -66,4 +124,3 @@ In other cases, please cite the following:
66124
> _Anal. Chem._ (2025) [doi:10.1021/acs.analchem.5c01142](https://pubs.acs.org/doi/10.1021/acs.analchem.5c01142)
67125
68126

69-

im2deep/__init__.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,20 @@
2020
>>> from psm_utils.psm_list import PSMList
2121
>>> predictions = predict_ccs(psm_list, calibration_data)
2222
23-
Dependencies:
24-
- deeplc: For deep learning model infrastructure
25-
- psm_utils: For peptide and PSM handling
26-
- pandas: For data manipulation
27-
- numpy: For numerical computations
28-
- click: For command-line interface
29-
30-
Authors:
31-
- Robbe Devreese
32-
- Robbin Bouwmeester
33-
- Ralf Gabriels
34-
35-
License:
36-
Apache License 2.0
3723
"""
3824

39-
__version__ = "1.1.1"
25+
from importlib.metadata import PackageNotFoundError, version
4026

41-
# Import main functionality for easier access
42-
from im2deep.im2deep import predict_ccs
43-
from im2deep.calibrate import linear_calibration
27+
from im2deep.core import predict, predict_and_calibrate
4428
from im2deep.utils import ccs2im, im2ccs
45-
from im2deep._exceptions import IM2DeepError, CalibrationError
4629

30+
try:
31+
__version__: str = version("im2deep")
32+
except PackageNotFoundError:
33+
__version__ = "0.0.0" # Fallback for version in pyproject.toml
4734
__all__ = [
48-
"predict_ccs",
49-
"linear_calibration",
35+
"predict",
36+
"predict_and_calibrate",
5037
"ccs2im",
5138
"im2ccs",
52-
"IM2DeepError",
53-
"CalibrationError",
5439
]

0 commit comments

Comments
 (0)