Skip to content

Commit

Permalink
fixed pre-commits
Browse files Browse the repository at this point in the history
  • Loading branch information
picciama committed Nov 22, 2024
1 parent 87ca080 commit af5b835
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 1 addition & 4 deletions spectrum_fundamentals/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@
# OpenMS constants #
#######################

OPENMS_VAR_MODS = {
"M(Oxidation)": "M[UNIMOD:35]",
"C(Carbamidomethyl)": "C[UNIMOD:4]"
}
OPENMS_VAR_MODS = {"M(Oxidation)": "M[UNIMOD:35]", "C(Carbamidomethyl)": "C[UNIMOD:4]"}

####################
# MASS CALCULATION #
Expand Down
9 changes: 5 additions & 4 deletions spectrum_fundamentals/mod_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pandas as pd

from .constants import MOD_MASSES, MOD_NAMES, SPECTRONAUT_MODS, XISEARCH_VAR_MODS, OPENMS_VAR_MODS
from .constants import MOD_MASSES, MOD_NAMES, OPENMS_VAR_MODS, SPECTRONAUT_MODS, XISEARCH_VAR_MODS


def sage_to_internal(sequences: List[str], mods: Dict[str, str]) -> List[str]:
Expand Down Expand Up @@ -188,6 +188,7 @@ def msfragger_to_internal(sequences: Union[np.ndarray, pd.Series, List[str]], mo
"""
return _to_internal(sequences=sequences, mods=mods)


def openms_to_internal(sequences: List[str], fixed_mods: Optional[Dict[str, str]] = None) -> List[str]:
"""
Function to translate a OpenMS modstring to the Prosit format.
Expand All @@ -200,9 +201,8 @@ def openms_to_internal(sequences: List[str], fixed_mods: Optional[Dict[str, str]
:raises AssertionError: if illegal modification was provided in the fixed_mods dictionary.
:return: a list of modified sequences
"""

if fixed_mods is None:
fixed_mods = {"C": "C[UNIMOD:4]"}
fixed_mods = {"C": "C[UNIMOD:4]"}
err_msg = f"Provided illegal fixed mod, supported modifications are {set(OPENMS_VAR_MODS.values())}."
assert all(x in OPENMS_VAR_MODS.values() for x in fixed_mods.values()), err_msg

Expand All @@ -229,11 +229,12 @@ def find_replacement(match: re.Match) -> str:
:return: substitution string for the given match
"""
key = match.string[match.start() : match.end()]

return replacements[key]

return [regex.sub(find_replacement, seq) for seq in sequences]


def internal_without_mods(sequences: List[str]) -> List[str]:
"""
Function to remove any mod identifiers and return the plain AA sequence.
Expand Down

0 comments on commit af5b835

Please sign in to comment.