diff --git a/alphabase/psm_reader/maxquant_reader.py b/alphabase/psm_reader/maxquant_reader.py index 96c5a67c..5d92d14f 100644 --- a/alphabase/psm_reader/maxquant_reader.py +++ b/alphabase/psm_reader/maxquant_reader.py @@ -1,4 +1,5 @@ import copy +from typing import Optional import numba import numpy as np @@ -191,7 +192,7 @@ def _init_modification_mapping(self): psm_reader_yaml["maxquant"]["modification_mapping"] ) - def set_modification_mapping(self, modification_mapping: dict): + def set_modification_mapping(self, modification_mapping: Optional[dict] = None): super().set_modification_mapping(modification_mapping) self._add_all_unimod() self._extend_mod_brackets() diff --git a/alphabase/psm_reader/msfragger_reader.py b/alphabase/psm_reader/msfragger_reader.py index 6da1b713..e4d8c2f6 100644 --- a/alphabase/psm_reader/msfragger_reader.py +++ b/alphabase/psm_reader/msfragger_reader.py @@ -115,9 +115,6 @@ def __init__( def _init_column_mapping(self): self.column_mapping = psm_reader_yaml["msfragger_pepxml"]["column_mapping"] - def _init_modification_mapping(self): - self.modification_mapping = {} - def _translate_modifications(self): pass diff --git a/alphabase/psm_reader/pfind_reader.py b/alphabase/psm_reader/pfind_reader.py index 69e24549..e5398e13 100644 --- a/alphabase/psm_reader/pfind_reader.py +++ b/alphabase/psm_reader/pfind_reader.py @@ -104,9 +104,6 @@ def __init__( def _init_column_mapping(self): self.column_mapping = psm_reader_yaml["pfind"]["column_mapping"] - def _init_modification_mapping(self): - self.modification_mapping = {} - def _translate_modifications(self): pass diff --git a/alphabase/psm_reader/psm_reader.py b/alphabase/psm_reader/psm_reader.py index 7740828d..7c1160ac 100644 --- a/alphabase/psm_reader/psm_reader.py +++ b/alphabase/psm_reader/psm_reader.py @@ -1,6 +1,7 @@ import copy import os import warnings +from typing import Optional import numpy as np import pandas as pd @@ -153,7 +154,10 @@ def __init__( Defaults to False. """ - self.set_modification_mapping(None) + self.modification_mapping = None + self.rev_mod_mapping = None + + self.set_modification_mapping() self.add_modification_mapping(modification_mapping) if column_mapping is not None: @@ -210,7 +214,7 @@ def add_modification_mapping(self, modification_mapping: dict): self.set_modification_mapping(self.modification_mapping) - def set_modification_mapping(self, modification_mapping: dict): + def set_modification_mapping(self, modification_mapping: Optional[dict] = None): if modification_mapping is None: self._init_modification_mapping() elif isinstance(modification_mapping, str): @@ -224,6 +228,7 @@ def set_modification_mapping(self, modification_mapping: dict): ) else: self.modification_mapping = copy.deepcopy(modification_mapping) + self._mods_as_lists() self._reverse_mod_mapping() diff --git a/alphabase/psm_reader/sage_reader.py b/alphabase/psm_reader/sage_reader.py index 27bc7d5f..5c69b8fd 100644 --- a/alphabase/psm_reader/sage_reader.py +++ b/alphabase/psm_reader/sage_reader.py @@ -593,9 +593,6 @@ def __init__( def _init_column_mapping(self): self.column_mapping = psm_reader_yaml["sage"]["column_mapping"] - def _init_modification_mapping(self): - self.modification_mapping = {} - def _load_file(self, filename): raise NotImplementedError