Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Generate a spectral library for [Spectronaut](https://biognosys.com/software/spe
- Alternatively you can also use [uv](https://docs.astral.sh/uv/getting-started/installation/).
- We recommend at least 32 GB of memory for larger MS files!

> [!NOTE]
> Pinned python and package versions are available in the `uv.lock` file!

## Usage

> [!IMPORTANT]
Expand All @@ -33,6 +36,76 @@ Generate a spectral library for [Spectronaut](https://biognosys.com/software/spe
- The full spectral library including all target and decoy annotations is created with extension `_spectralLibraryFULL.csv`.
- This spectral library should be used with [Spectronaut](https://biognosys.com/software/spectronaut/)!

## Example

Here is a minimal example (we are using [uv](https://docs.astral.sh/uv/) here):

- You can download some example data from [here](http://u.pc.cd/omH).
- Clone this repository:
```bash
git clone https://github.com/hgb-bin-proteomics/MSAnnika_Spectral_Library_exporter.git
```
- Extract the example data into the `MSAnnika_Spectral_Library_exporter` folder.
- **Overwrite any files if prompted!**
- Go into the `MSAnnika_Spectral_Library_exporter` folder.
- The folder should contain the example files:
- `config.py`
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2.mzML`
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs.xlsx`
- Now run the spectral library creation script with [uv](https://docs.astral.sh/uv/):
```bash
uv run create_spectral_library.py
```
- The script should run for about one minute and you should see output like this:
<details><summary>Expand for output!</summary>

```text
INFO: Spectral library creation started at 2026-05-12 15:34:30.616870.
INFO: Creating spectral library with input files:
Spectra:
XLpeplib_Beveridge_QEx-HFX_DSS_R2.mzML
CSMs: XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs.xlsx
INFO: Using the following modifications:
{'Oxidation': [15.994915], 'Carbamidomethyl': [57.021464], 'DSSO': [54.01056, 85.98264, 103.9932], 'DSS': [138.06808]}
INFO: Using the following ion types:
('b', 'y')
INFO: Using the following charge states:
[1, 2, 3, 4]
INFO: Using a match tolerance of: 0.02 Da
INFO: Starting annotation process...
INFO: Reading CSMs...
INFO: Done reading CSMs! Filtering for unique residue pairs...
INFO: Done filtering for unique residue pairs!
INFO: Sorting CSMs...
INFO: Finished sorting CSMs! Starting spectral library creation...
INFO: Processing CSMs...: 0%| | 0/382 [00:00<?, ?it/s]Found unseen spectrum file! Trying to read spectrum file...
Reading mzML file...
Found 0/10951 spectra without peaks in file XLpeplib_Beveridge_QEx-HFX_DSS_R2.mzML!
INFO: Read all spectra from file XLpeplib_Beveridge_QEx-HFX_DSS_R2.mzML.
INFO: Read 1/1 files...
INFO: Read all spectra files successfully!
INFO: Processing CSMs...: 100%|██████| 382/382 [00:14<00:00, 27.15it/s]
SUCCESS: Spectral library created with filename:
XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibrary.csv
SUCCESS: Decoy Spectral libraries created with filenames:
XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_DD.csv
XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_DT.csv
XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_TD.csv
Creating merged library...
SUCCESS: Merged spectral library created with filename:
XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryFULL.csv
SUCCESS: Spectral library creation finished at 2026-05-12 15:34:45.473506.
```

</details>
- You should see the following files created:
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibrary.csv` ➡️ Target(-Target) spectral library
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_DD.csv` ➡️ Decoy-Decoy spectral library
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_DT.csv` ➡️ Decoy-Target spectral library
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryDECOY_TD.csv` ➡️ Target-Decoy spectral library
- `XLpeplib_Beveridge_QEx-HFX_DSS_R2_CSMs_spectralLibraryFULL.csv` ➡️ Full spectral library
- The full library can now be used in Spectronaut!

## Usage with xiSearch + xiFDR

Starting with version [1.4.4](https://github.com/hgb-bin-proteomics/MSAnnika_Spectral_Library_exporter/releases/tag/v1.4.4) this script also supports input from
Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "msannika-spectral-library-exporter"
version = "1.4.22"
description = "Generate a spectral library for Spectronaut from MS Annika results."
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"openpyxl>=3.1.5",
"pandas>=3.0.3",
"pyteomics[xml]>=4.7.5",
"tqdm>=4.67.3",
]
Loading
Loading