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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ MATCH_TOLERANCE = 0.02
iRT_PARAMS = {"iRT_m": 1.3066, "iRT_t": 29.502}
# regex pattern used for parsing scan number from the spectrum title
PARSER_PATTERN = "\\.\\d+\\."
# only take the best CSM per unique peptidoform and charge (True) or not (False)
GROUP_PRECURSORS = True
# raise an error if spectra do not contain FAIMS compensation voltage information
ERROR_ON_NO_FAIMS = True
```

In case you have more than one `SPECTRA_FILE` you can specify that like this:
Expand Down
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
PARSER_PATTERN = "\\.\\d+\\."
# only take the best CSM per unique peptidoform and charge (True) or not (False)
GROUP_PRECURSORS = True
# raise an error if spectra do not contain FAIMS compensation voltage information
ERROR_ON_NO_FAIMS = True
15 changes: 12 additions & 3 deletions create_spectral_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# micha.birklbauer@gmail.com

# version tracking
__version = "1.4.19"
__date = "2026-01-20"
__version = "1.4.22"
__date = "2026-01-22"

# REQUIREMENTS
# pip install pandas
Expand Down Expand Up @@ -45,6 +45,11 @@
except ImportError as e:
GROUP_PRECURSORS = True

try:
from config import ERROR_ON_NO_FAIMS
except ImportError as e:
ERROR_ON_NO_FAIMS = True

######################

# import packages
Expand Down Expand Up @@ -311,6 +316,8 @@ def read_spectra(filename: Union[str, BinaryIO]) -> Dict[int, Dict]:
spectrum_dict["charge"] = int(ion["charge state"])
spectrum_dict["rt"] = rt_in_sec
spectrum_dict["max_intensity"] = float(max(spectrum["intensity array"])) if "intensity array" in spectrum and len(spectrum["intensity array"]) > 0 else 0.0
if ERROR_ON_NO_FAIMS and "FAIMS compensation voltage" not in spectrum:
raise RuntimeError(f"Spectrum with scan number {scan_nr} does not contain FAIMS compensation voltage!")
spectrum_dict["compensation_voltage"] = float(spectrum["FAIMS compensation voltage"]) if "FAIMS compensation voltage" in spectrum else 0.0
peaks = dict()
if "m/z array" in spectrum:
Expand Down Expand Up @@ -1142,7 +1149,9 @@ def get_IonMobility(csm: pd.Series,
Retrieve compensation voltage from CSM or spectrum.
"""
if "Compensation Voltage" in csm:
return float(csm["Compensation Voltage"])
if not pd.isna(csm["Compensation Voltage"]):
if abs(float(csm["Compensation Voltage"])) > 0.0:
return float(csm["Compensation Voltage"])
spectrum_file = ".".join(str(csm["Spectrum File"]).split(".")[:-1]).strip()
scan_nr = int(csm["First Scan"])
return spectra[spectrum_file][scan_nr]["compensation_voltage"]
Expand Down
2 changes: 2 additions & 0 deletions data/config_xi.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@
PARSER_PATTERN = "\\.\\d+\\."
# only take the best CSM per unique peptidoform and charge (True) or not (False)
GROUP_PRECURSORS = True
# raise an error if spectra do not contain FAIMS compensation voltage information
ERROR_ON_NO_FAIMS = True