Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor readers ix #251

Open
wants to merge 7 commits into
base: refactor_readers_VIII
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion alphabase/psm_reader/maxquant_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PSMReaderBase,
psm_reader_provider,
)
from alphabase.psm_reader.utils import get_column_mapping_for_df

# make sure all warnings are shown
warnings.filterwarnings("always")
Expand Down Expand Up @@ -180,7 +181,7 @@ def _pre_process(self, df: pd.DataFrame) -> pd.DataFrame:
df.fillna("", inplace=True)

# remove MBR PSMs as they are currently not supported and will crash import
mapped_columns = self._find_mapped_columns(df)
mapped_columns = get_column_mapping_for_df(self.column_mapping, df)
if PsmDfCols.SCAN_NUM in mapped_columns:
scan_num_col = mapped_columns[PsmDfCols.SCAN_NUM]
no_ms2_mask = df[scan_num_col] == ""
Expand Down
2 changes: 1 addition & 1 deletion alphabase/psm_reader/modification_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class ModificationMapper:
def __init__(
self,
custom_modification_mapping: Optional[Dict[str, str]],
*,
reader_yaml: Dict,
modification_type: Optional[str],
*,
add_unimod_to_mod_mapping: bool,
):
"""Initialize the ModificationMapper.
Expand Down
6 changes: 3 additions & 3 deletions alphabase/psm_reader/msfragger_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def _translate_score(self) -> None:
# evalue score
self._psm_df[PsmDfCols.SCORE] = -np.log(self._psm_df[PsmDfCols.SCORE] + 1e-100)

def _load_modifications(self, msf_df: pd.DataFrame) -> None:
if len(msf_df) == 0:
def _load_modifications(self, origin_df: pd.DataFrame) -> None:
if len(origin_df) == 0:
self._psm_df[PsmDfCols.MODS] = ""
self._psm_df[PsmDfCols.MOD_SITES] = ""
self._psm_df[PsmDfCols.AA_MASS_DIFFS] = ""
Expand All @@ -182,7 +182,7 @@ def _load_modifications(self, msf_df: pd.DataFrame) -> None:
self._psm_df[PsmDfCols.AA_MASS_DIFFS],
self._psm_df[PsmDfCols.AA_MASS_DIFF_SITES],
) = zip(
*msf_df[["peptide", "modifications"]].apply(
*origin_df[["peptide", "modifications"]].apply(
lambda x: _get_mods_from_masses(*x), axis=1
)
)
Expand Down
6 changes: 3 additions & 3 deletions alphabase/psm_reader/pfind_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ def _translate_score(self) -> None:
self._psm_df[PsmDfCols.SCORE].astype(float) + 1e-100
)

def _load_modifications(self, pfind_df: pd.DataFrame) -> None:
if len(pfind_df) == 0:
def _load_modifications(self, origin_df: pd.DataFrame) -> None:
if len(origin_df) == 0:
self._psm_df[PsmDfCols.MODS] = ""
self._psm_df[PsmDfCols.MOD_SITES] = ""
return

(self._psm_df[PsmDfCols.MODS], self._psm_df[PsmDfCols.MOD_SITES]) = zip(
*pfind_df["Modification"].apply(get_pFind_mods)
*origin_df["Modification"].apply(get_pFind_mods)
)

self._psm_df[PsmDfCols.MODS] = self._psm_df[PsmDfCols.MODS].apply(
Expand Down
Loading
Loading