-
Notifications
You must be signed in to change notification settings - Fork 17
FragPipe PG Reader #332
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
Merged
lucas-diedrich
merged 16 commits into
pg-reader-6-spectronaut
from
pg-reader-7-msfragger
Aug 26, 2025
Merged
FragPipe PG Reader #332
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
85e05cb
[Feature] Implement fragpipe reader
lucas-diedrich 4a46205
[API] Expose FragPipeReader to users
lucas-diedrich 808547b
[Tests] Add integration test for FragPipeReader
lucas-diedrich 38b995d
[Fix] Fix typo in URL
lucas-diedrich deccde6
[Test] Update tests to work with local data (FragPipe PG reader)
lucas-diedrich 6cbe7d9
[Test-data] Add test reference data (PG fragpipe)
lucas-diedrich cc9b861
[Feature] Add MZTab protein group reader
lucas-diedrich 6699fac
[API] Expose MZTab to users
lucas-diedrich 8e0e8c5
[Tests] Add integration tests
lucas-diedrich 2a2848e
[Refactor] Set correct default values
lucas-diedrich 00c72f0
[Tests] Add integration tests
lucas-diedrich 86eeb7a
[Test] Refactor mztab integration test so that it runs with local data
lucas-diedrich 15545aa
[Test-data] Add local test data (mzTAB PG Reader)
lucas-diedrich 0343aeb
[Doc] Add PG-reader API docs
lucas-diedrich 75b5ab1
Merge pull request #334 from MannLabs/pg-reader-9-docs-I
lucas-diedrich 639c81e
Merge pull request #333 from MannLabs/pg-reader-8-mztab
lucas-diedrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| """FragPipe protein group reader.""" | ||
|
|
||
| from typing import Literal, Optional, Union | ||
|
|
||
| from .pg_reader import PGReaderBase, pg_reader_provider | ||
|
|
||
|
|
||
| class FragPipePGReader(PGReaderBase): | ||
| """Reader for `protein.tsv` reports from FragPipe. | ||
|
|
||
| Example: | ||
| ------- | ||
| Per default, the reader will return the raw intensities from the `razor` method. Additional protein features are stored | ||
| in the dataframe index, samples are stored as columns. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| # Get raw intensities | ||
| reader = FragPipePGReader() | ||
| results = reader.import_file(download_path) | ||
|
|
||
|
|
||
| References: | ||
| ---------- | ||
| - FragPipe Documentation https://fragpipe.nesvilab.org/docs/tutorial_fragpipe_outputs.html#proteintsv | ||
|
|
||
| """ | ||
|
|
||
| _reader_type: str = "fragpipe" | ||
|
|
||
| def __init__( # noqa: D107 inherited from base class | ||
| self, | ||
| *, | ||
| column_mapping: Optional[dict[str, str]] = None, | ||
| measurement_regex: Union[ | ||
| Literal[ | ||
| "raw", "razor", "unique", "total", "lfq", "lfq_unique", "lfq_total" | ||
| ], | ||
| None, | ||
| ] = "razor", | ||
| ): | ||
| super().__init__( | ||
| column_mapping=column_mapping, measurement_regex=measurement_regex | ||
| ) | ||
|
|
||
|
|
||
| pg_reader_provider.register_reader("fragpipe", reader_class=FragPipePGReader) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| """FragPipe protein group reader.""" | ||
|
|
||
| from pathlib import Path | ||
| from typing import Literal, Optional, Union | ||
|
|
||
| import pandas as pd | ||
|
|
||
| from .pg_reader import PGReaderBase, pg_reader_provider | ||
|
|
||
|
|
||
| class MZTabPGReader(PGReaderBase): | ||
| """Reader for MZTab search engine output. | ||
|
|
||
| MZTab is a standardized tab-delimited format for reporting proteomics and metabolomics results. | ||
| The format organizes data into distinct sections: metadata (MTD), protein groups (PRH/PRT), | ||
| peptides (PEH/PEP), PSMs (PSH/PSM), and small molecules (SMH/SML), with each section identified | ||
| by specific three-letter prefixes. This reader extracts protein-level quantification data from | ||
| the PRT lines, which contain protein abundances across samples or study variables. | ||
|
|
||
| Example: | ||
| ------- | ||
| Per default, the reader will return the raw intensities from the `razor` method. Additional protein features are stored | ||
| in the dataframe index, samples are stored as columns. | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from alphabase.pg_reader import MZTabPGReader | ||
|
|
||
| # Get raw intensities | ||
| reader = MZTabPGReader() | ||
| results = reader.import_file(path) | ||
|
|
||
|
|
||
| References: | ||
| ---------- | ||
| - Griss, J. et al. The mzTab Data Exchange Format: Communicating Mass-spectrometry-based Proteomics and Metabolomics Experimental Results to a Wider Audience*. Molecular & Cellular Proteomics 13, 2765-2775 (2014). | ||
| - Official MZTab Repository: https://github.com/HUPO-PSI/mzTab.git | ||
| - Official documentation: https://hupo-psi.github.io/mzTab/ | ||
|
|
||
| """ | ||
|
|
||
| _reader_type: str = "mztab" | ||
|
|
||
| _PROTEIN_ROW_INDICATOR: str = "PRT" | ||
| _PROTEIN_HEADER_INDICATOR: str = "PRH" | ||
| _SEPARATOR: str = "\t" | ||
|
|
||
| def __init__( # noqa: D107 inherited from base class | ||
| self, | ||
| *, | ||
| column_mapping: Optional[dict[str, str]] = None, | ||
| measurement_regex: Union[ | ||
| str, Literal["assay", "study_variable"], None # noqa: PYI051 raw and lfq are special cases and not equivalent to string | ||
| ] = "assay", | ||
| ): | ||
| super().__init__( | ||
| column_mapping=column_mapping, measurement_regex=measurement_regex | ||
| ) | ||
|
|
||
| def _load_file(self, file_path: str) -> pd.DataFrame: | ||
| """Load MZTab file and extract protein data section. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| file_path : str | ||
| Path to MZTab file | ||
|
|
||
| Returns | ||
| ------- | ||
| pd.DataFrame | ||
| DataFrame containing protein data from MZTab file | ||
|
|
||
| Notes | ||
| ----- | ||
| Protein lines are indicated with a leading `PRT`. The protein metadata header is | ||
| indicated with a leading `PRH`. The file is tab separated. | ||
|
|
||
| Raises | ||
| ------ | ||
| ValueError | ||
| If no protein data or metadata is found in the file | ||
|
|
||
| """ | ||
| file_path = Path(file_path) | ||
| protein_header = None | ||
| protein_rows = [] | ||
|
|
||
| with file_path.open() as f: | ||
| for line in f: | ||
| line_stripped = line.strip() | ||
|
|
||
| if line_stripped.startswith(self._PROTEIN_HEADER_INDICATOR): | ||
| # Protein header line - remove 'PRH' prefix and parse columns | ||
| header_content = line_stripped[3:].strip() | ||
| protein_header = header_content.split(self._SEPARATOR) | ||
|
|
||
| elif line_stripped.startswith(self._PROTEIN_ROW_INDICATOR): | ||
| # Protein data line - remove 'PRT' prefix and parse data | ||
| row_content = line_stripped[3:].strip() | ||
| protein_rows.append(row_content.split(self._SEPARATOR)) | ||
|
|
||
| # Validate that we found protein data | ||
| if protein_header is None: | ||
| raise ValueError( | ||
| f"No protein header ({self._PROTEIN_HEADER_INDICATOR}) found in MZTab file" | ||
| ) | ||
|
|
||
| if not protein_rows: | ||
| raise ValueError( | ||
| f"No protein data rows ({self._PROTEIN_ROW_INDICATOR}) found in MZTab file" | ||
| ) | ||
|
|
||
| return pd.DataFrame(protein_rows, columns=protein_header) | ||
|
|
||
|
|
||
| pg_reader_provider.register_reader("mztab", reader_class=MZTabPGReader) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ Reader | |
| :maxdepth: 2 | ||
|
|
||
| modules_psm_reader | ||
| modules_pg_reader | ||
|
|
||
|
|
||
| I/O | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| alphabase.pg_reader | ||
| =========================== | ||
|
|
||
| All pg_readers can be accessed by | ||
| :obj:`pg_reader_provider <alphabase.pg_reader.pg_reader.pg_reader_provider>`. | ||
|
|
||
| .. toctree:: | ||
| :maxdepth: 1 | ||
|
|
||
| pg_reader/pg_base | ||
| pg_reader/alphadia_pg_reader | ||
| pg_reader/alphapept_pg_reader | ||
| pg_reader/diann_pg_reader | ||
| pg_reader/fragpipe_pg_reader | ||
| pg_reader/maxquant_pg_reader | ||
| pg_reader/mztab_pg_reader | ||
| pg_reader/spectronaut_pg_reader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.alphadia_pg_reader | ||
| ====================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.alphadia_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.alphapept_pg_reader | ||
| ======================================= | ||
|
|
||
| .. automodule:: alphabase.pg_reader.alphapept_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.diann_pg_reader | ||
| =================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.diann_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.fragpipe_pg_reader | ||
| ====================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.fragpipe_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.maxquant_pg_reader | ||
| ====================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.maxquant_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.mztab_pg_reader | ||
| ====================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.mztab_pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.base | ||
| ======================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.pg_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| alphabase.pg_reader.spectronaut_reader | ||
| ====================================== | ||
|
|
||
| .. automodule:: alphabase.pg_reader.spectronaut_reader | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.