Skip to content

Commit

Permalink
Merge pull request #130 from wilhelm-lab/patch/0.7.2
Browse files Browse the repository at this point in the history
Patch/0.7.2
  • Loading branch information
picciama authored Aug 6, 2024
2 parents bab673b + 39c18f5 commit 6f0465f
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .cookietemple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ full_name: Victor Giurcoiu
email: victor.giurcoiu@tum.de
project_name: spectrum_fundamentals
project_short_description: Fundamentals public repo
version: 0.7.1
version: 0.7.2
license: MIT
4 changes: 2 additions & 2 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name-template: "0.7.1 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.1 # <<COOKIETEMPLE_FORCE_BUMP>>
name-template: "0.7.2 🌈" # <<COOKIETEMPLE_FORCE_BUMP>>
tag-template: 0.7.2 # <<COOKIETEMPLE_FORCE_BUMP>>
exclude-labels:
- "skip-changelog"

Expand Down
2 changes: 1 addition & 1 deletion cookietemple.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.1
current_version = 0.7.2

[bumpversion_files_whitelisted]
init_file = spectrum_fundamentals/__init__.py
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
# the built documents.
#
# The short X.Y version.
version = "0.7.1"
version = "0.7.2"
# The full version, including alpha/beta/rc tags.
release = "0.7.1"
release = "0.7.2"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "spectrum_fundamentals"
version = "0.7.1" # <<COOKIETEMPLE_FORCE_BUMP>>
version = "0.7.2" # <<COOKIETEMPLE_FORCE_BUMP>>
description = "Fundamental functions, annotation pipeline and constants for oktoberfest"
authors = ["Wilhelmlab at Technical University of Munich"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = "Mario Picciani"
__email__ = "mario.picciani@tum.de"
__version__ = "0.7.1"
__version__ = "0.7.2"

import logging
import logging.handlers
Expand Down
2 changes: 1 addition & 1 deletion spectrum_fundamentals/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


@click.command()
@click.version_option(version="0.7.1", message=click.style("spectrum_fundamentals Version: 0.7.1"))
@click.version_option(version="0.7.2", message=click.style("spectrum_fundamentals Version: 0.7.2"))
def main() -> None:
"""spectrum_fundamentals."""

Expand Down
16 changes: 8 additions & 8 deletions spectrum_fundamentals/annotation/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def annotate_spectra(
un_annot_spectra: pd.DataFrame,
mass_tolerance: Optional[float] = None,
unit_mass_tolerance: Optional[str] = None,
custom_mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] = None,
custom_mods: Optional[Dict[str, float]] = None,
fragmentation_method: str = "HCD",
) -> pd.DataFrame:
"""
Expand All @@ -142,7 +142,7 @@ def annotate_spectra(
:param mass_tolerance: mass tolerance to calculate min and max mass
:param unit_mass_tolerance: unit for the mass tolerance (da or ppm)
:param fragmentation_method: fragmentation method that was used
:param custom_mods: Custom Modifications with the identifier, the unimod equivalent and the respective mass
:param custom_mods: mapping of custom UNIMOD string identifiers ('[UNIMOD:xyz]') to their mass
:return: a Pandas DataFrame containing the annotated spectra with meta data
"""
raw_file_annotations = []
Expand Down Expand Up @@ -345,7 +345,7 @@ def parallel_annotate(
index_columns: Dict[str, int],
mass_tolerance: Optional[float] = None,
unit_mass_tolerance: Optional[str] = None,
custom_mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] = None,
custom_mods: Optional[Dict[str, float]] = None,
fragmentation_method: str = "HCD",
) -> Optional[
Union[
Expand All @@ -367,7 +367,7 @@ def parallel_annotate(
:param index_columns: a dictionary that contains the index columns of the spectrum
:param mass_tolerance: mass tolerance to calculate min and max mass
:param unit_mass_tolerance: unit for the mass tolerance (da or ppm)
:param custom_mods: Custom Modifications with the identifier, the unimod equivalent and the respective mass
:param custom_mods: mapping of custom UNIMOD string identifiers ('[UNIMOD:xyz]') to their mass
:param fragmentation_method: fragmentation method that was used
:return: a tuple containing intensity values (np.ndarray), masses (np.ndarray), calculated mass (float),
and any removed peaks (List[str])
Expand Down Expand Up @@ -397,7 +397,7 @@ def _annotate_linear_spectrum(
index_columns: Dict[str, int],
mass_tolerance: Optional[float],
unit_mass_tolerance: Optional[str],
custom_mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] = None,
custom_mods: Optional[Dict[str, float]] = None,
fragmentation_method: str = "HCD",
):
"""
Expand All @@ -407,7 +407,7 @@ def _annotate_linear_spectrum(
:param index_columns: Index columns of the spectrum
:param mass_tolerance: Mass tolerance for calculating min and max mass
:param unit_mass_tolerance: Unit for the mass tolerance (da or ppm)
:param custom_mods: Custom Modifications with the identifier, the unimod equivalent and the respective mass
:param custom_mods: mapping of custom UNIMOD string identifiers ('[UNIMOD:xyz]') to their mass
:param fragmentation_method: fragmentation method that was used
:return: Annotated spectrum
"""
Expand Down Expand Up @@ -454,7 +454,7 @@ def _annotate_crosslinked_spectrum(
crosslinker_type: str,
mass_tolerance: Optional[float] = None,
unit_mass_tolerance: Optional[str] = None,
custom_mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] = None,
custom_mods: Optional[Dict[str, float]] = None,
):
"""
Annotate a crosslinked peptide spectrum.
Expand All @@ -464,7 +464,7 @@ def _annotate_crosslinked_spectrum(
:param crosslinker_type: Type of crosslinker used
:param mass_tolerance: Mass tolerance for calculating min and max mass
:param unit_mass_tolerance: Unit for the mass tolerance (da or ppm)
:param custom_mods: Custom Modifications with the identifier, the unimod equivalent and the respective mass
:param custom_mods: mapping of custom UNIMOD string identifiers ('[UNIMOD:xyz]') to their mass
:raises ValueError: if unsupported crosslinker type was supplied.
:return: Annotated spectrum
Expand Down
29 changes: 2 additions & 27 deletions spectrum_fundamentals/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from enum import Enum
from typing import Dict, List, Optional, Tuple

import numpy as np

Expand Down Expand Up @@ -235,32 +234,6 @@
}


def update_mod_masses(mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] = None) -> Dict[str, float]:
"""
Function to update MOD_MASSES with custom modifications.
:param mods: Modifications with respective mass
:raises AssertionError: if mass of modification was not provided as float.
:return: updated MOD_MASSES
"""
mod_masses = {}
if mods:
try:
stat_mods: List[Tuple[str, float]] = [
(value[0], float(value[1])) for key, value in (mods.get("stat_mods") or {}).items()
]
var_mods: List[Tuple[str, float]] = [
(value[0], float(value[1])) for key, value in (mods.get("var_mods") or {}).items()
]
except ValueError as e:
raise AssertionError("All custom modifications value entries must be of type Tuple[str, float]") from e

for value in stat_mods + var_mods:
mod_masses[value[0]] = float(value[1])

return MOD_MASSES | mod_masses


MOD_MASSES_SAGE = {
"229.1629": "[UNIMOD:737]",
"304.2071": "[UNIMOD:2016]",
Expand All @@ -276,6 +249,8 @@ def update_mod_masses(mods: Optional[Dict[str, Dict[str, Tuple[str, float]]]] =
"42.0105": "[UNIMOD:1]",
}
# these are only used for prosit_grpc, oktoberfest uses the masses from MOD_MASSES


AA_MOD_MASSES = {
"K[UNIMOD:737]": AA_MASSES["K"] + MOD_MASSES["[UNIMOD:737]"],
"M[UNIMOD:35]": AA_MASSES["M"] + MOD_MASSES["[UNIMOD:35]"],
Expand Down
Loading

0 comments on commit 6f0465f

Please sign in to comment.