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 iv #246

Open
wants to merge 8 commits into
base: refactor_readers_III
Choose a base branch
from
Open

Conversation

mschwoer
Copy link
Contributor

Trying to simplify the inheritance structure

  • make self.csv_sep a ordinary variable
  • move some logic up to the reader base class
  • extract static helper methods to utils.py, add tests

@mschwoer mschwoer requested a review from GeorgWa November 19, 2024 10:40
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

"[Phospho]",
"_(Phospho)",
"_[Phospho]",
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jalew188 just by symmetry, I would expect (Phospho) here too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be, but I am not sure what is this testing for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@jalew188 jalew188 Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. It looks like () processing is missing here .

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe currently, this is not used by any readers, but we should add () case

@@ -0,0 +1,113 @@
"""Utility functions for PSM readers."""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only moved code

Copy link
Collaborator

@GeorgWa GeorgWa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

"""

_reader_type = "spectronaut"
_add_unimod_to_mod_mapping = True
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also add this to the base class?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind :D

self.rev_mod_mapping = self._get_reversed_mod_mapping()

def _init_modification_mapping(self) -> None:
self.modification_mapping = {}

def _add_all_unimod(self) -> None:
for mod_name, unimod in MOD_TO_UNIMOD_DICT.items():
if mod_name in self.modification_mapping:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we reuse the logic used to add custom mods here? I feel like adding unimod, adding reader specific mods and adding custom mods is very similar.

else:
self.modification_mapping[mod_name] = [unimod]

def _extend_mod_brackets(self) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code (ab in general, not your PR) feels to me like we should start a ModificationMapping class 😆

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree. It also depends on how heavy we are going to use these reader classes. Before, I just used them to get unified training data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done here #247

@@ -457,20 +428,9 @@ def _translate_columns(self, origin_df: pd.DataFrame) -> None:
self._psm_df[PsmDfCols.SPEC_IDX] = self._psm_df[PsmDfCols.SCAN_NUM] - 1

def _transform_table(self) -> None: # noqa: B027 empty method in an abstract base class
"""Transform the dataframe format if needed.
"""Transform the dataframe format if needed, ddd information inplace into self._psm_df.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) typo: add

Copy link
Collaborator

@jalew188 jalew188 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants