Skip to content

Commit

Permalink
simplify modification_mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Nov 12, 2024
1 parent 22f17d9 commit a9c2d46
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
3 changes: 2 additions & 1 deletion alphabase/psm_reader/maxquant_reader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
from typing import Optional

import numba
import numpy as np
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions alphabase/psm_reader/msfragger_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions alphabase/psm_reader/pfind_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions alphabase/psm_reader/psm_reader.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import os
import warnings
from typing import Optional

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand All @@ -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()

Expand Down
3 changes: 0 additions & 3 deletions alphabase/psm_reader/sage_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a9c2d46

Please sign in to comment.