flippr 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ .DS_Store
2
+ flippr/.DS_Store
3
+
4
+ __pycache__
5
+ flippr/__pycache__
6
+
7
+ /**/.*
8
+ /**/.*/
9
+ /**/data/
10
+ /**/*.log
11
+ /**/*.txt
12
+ /**/*.ipynb
13
+ /**/*.xlsx
14
+ /**/__pycache__
15
+ !/.gitignore
flippr-0.1.1/LICENSE ADDED
Binary file
flippr-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,168 @@
1
+ Metadata-Version: 2.3
2
+ Name: flippr
3
+ Version: 0.1.1
4
+ Summary: FragPipe Limited-Proteolysis Processor (FLiPPR) is modular, fast, and easy-to-use data processing tool for LiP-MS & LFQ-based experiments analyzed in FragPipe
5
+ Project-URL: Documentation, https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor#readme
6
+ Project-URL: Issues, https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processorissues
7
+ Project-URL: Source, https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor
8
+ Author-email: Edgar Manriquez-Sandoval <emanriq1@jhu.edu>
9
+ Maintainer-email: "FriedLab@JHU" <friedlab.jhu@gmail.com>, "Stephen D. Fried" <sdfried@jhu.edu>, Edgar Manriquez-Sandoval <emanriq1@jhu.edu>
10
+ License-File: LICENSE
11
+ Keywords: bottom-up proteomics,computational mass spectrometry,differential analysis,flippr,fragpipe,fragpipe analysis,label-free,label-free quantification,lfq,limited proteolysis,lip-ms,proteomics
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: Implementation :: CPython
17
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: biopython
20
+ Requires-Dist: h2
21
+ Requires-Dist: httpx
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: nest-asyncio
24
+ Requires-Dist: numpy
25
+ Requires-Dist: pandas
26
+ Requires-Dist: polars
27
+ Requires-Dist: pyarrow
28
+ Requires-Dist: requests
29
+ Requires-Dist: scipy
30
+ Requires-Dist: seaborn
31
+ Requires-Dist: xlsx2csv
32
+ Requires-Dist: xlsxwriter
33
+ Description-Content-Type: text/markdown
34
+
35
+ ![FLiPPR Logo](/assets/images/flippr_long_logo.png)
36
+
37
+ ## Table of Contents
38
+
39
+ - [Overview](#overview)
40
+ - [Support](#support)
41
+ - [Installation](#installation)
42
+ - [Usage](#usage)
43
+ - [License](#license)
44
+ - [Citation](#citation)
45
+
46
+ ## Overview
47
+
48
+ FLiPPR (**F**ragPipe **Li**mited-**P**roteolysis **Pr**ocessor) is modular, fast, and easy-to-use data processing tool for LiP-MS & LFQ-based experiments analyzed in FragPipe.
49
+
50
+ FLiPPR is:
51
+ * **Super Fast**: FLiPPR utilizes [Polars](https://pola.rs/) in the back-end to ensure all CPU cores contribute to your data processing.
52
+ * **Convinent to Use**: [FragPipe](https://fragpipe.nesvilab.org/) produces standarized outputs, FLiPPR takes full advantage of this feat and integrates seemlessly with any FragPipe LFQ-MBR anaylsis.
53
+ * **Flexible and Expandable**: Experiments introduce unique and novel variables, FLiPPR ensures capatibility with all experimental setups and gives you full control of the data processing pipeline.
54
+
55
+ ## Support
56
+ FLiPPR has been tested with Python 3.10 – 3.12
57
+ To learn more about how FLiPPR can help you analyze your LiP-MS or LFQ data, head over to the [FLiPPR docs](https://flippr.readthedocs.io)
58
+
59
+ ## Installation
60
+
61
+ To get started with FLiPPR, follow these steps:
62
+
63
+ ```bash
64
+ # 1. Clone the repository:
65
+ git clone https://https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor.git
66
+
67
+ # 2. Navigate to the project directory:
68
+ cd FragPipe-Limited-Proteolysis-Processor
69
+
70
+ # 3. Install FLiPPR:
71
+ python -m pip install .
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ 1. Start a `Study`
77
+
78
+ ```python
79
+ import flippr as fp
80
+ from flippr import Study
81
+
82
+ # Pass the FragPipe output directory path from your LiP-MS experiment
83
+ study = Study(lip = "path/to/lip")
84
+
85
+ # Include protein normalization factors from a Trypsin-only experiment
86
+ study = Study(lip = "path/to/lip", trp = "path/to/trp")
87
+
88
+ # Including the protein FASTA file will add metadata and remove contaminants
89
+ study = Study(lip = "path/to/lip", trp = "path/to/trp", fasta = "UP000000625_83333.fasta")
90
+ ```
91
+
92
+ 2. View the experimental sample annotations
93
+
94
+ ```python
95
+ print(study.samples)
96
+ # >>> { 'LiP': {'Native', 'Refolded_001_min', 'Refolded_005_min', 'Refolded_120_min'}, 'TrP': {'Refolded', 'Native'}}
97
+ ```
98
+
99
+ 3. Add an experimental process
100
+
101
+ ```python
102
+ # Process without normalization
103
+ study.add_process(1, "Native", "Refolded_001_min", 3)
104
+
105
+ # Process with normalizations (only when `trp` is included in the study)
106
+ study.add_process(5, "Native", "Refolded_005_min", 3, "Native", "Refolded", 3)
107
+
108
+ # Multiple processes within one study
109
+ study.add_process(1, "Native", "Refolded_001_min", 3, "Native", "Refolded", 3)
110
+ study.add_process(5, "Native", "Refolded_005_min", 3, "Native", "Refolded", 3)
111
+ study.add_process(120, "Native", "Refolded_120_min", 3, "Native", "Refolded", 3)
112
+ ```
113
+
114
+ 4. Run your study
115
+
116
+ ```python
117
+ # Running a study returns results and populates the `Study().results` dictionary
118
+ results = study.run()
119
+ # >>> {1: <flippr.Results>, 5: <flippr.Results>, 120: <flippr.Results>}
120
+
121
+ # Change analysis parameters within `fp.rcParams` before running for more control
122
+ fp.rcParams["protein.fc_sig_thresh"] = 2.0
123
+ results = study.run()
124
+ ```
125
+
126
+ 5. View or save your results as Polars DataFrames
127
+
128
+ ```python
129
+ # 1 min time point results
130
+ results_1_min = results[1]
131
+
132
+ # View all ions included in the 1 min experimental process
133
+ results_1_min.ion
134
+
135
+ # View higher-order results
136
+ results_1_min.modified_peptide
137
+ results_1_min.peptide
138
+ results_1_min.cut_site
139
+
140
+ # View protein-level summary of all data
141
+ results_1_min.protein_summary
142
+ ```
143
+
144
+ | Protein ID | Protein | Entry Name | Gene | ... | No. of Valid Cut Sites | No. of Significant Cut Sites | No. of Significant Cut Sites |
145
+ |------------|-----------------------------|-------------|--------|-----|------------------------|------------------------------|------------------------------|
146
+ | P00350 | sp\|P00350\|6PGD_ECOLI | 6PGD_ECOLI | gnd | ... | 111 | 40 | 50 |
147
+ | P00363 | sp\|P00363\|FRDA_ECOLI | FRDA_ECOLI | frdA | ... | 15 | 2 | 2 |
148
+ | Q57261 | sp\|Q57261\|TRUD_ECOLI | TRUD_ECOLI | truD | ... | 24 | 7 | 8 |
149
+ | Q59385 | sp\|Q59385\|COPA_ECOLI | COPA_ECOLI | copA | ... |13 | 2 | 1 |
150
+ | Q7DFV3 | sp\|Q7DFV3\|YMGG_ECOLI | YMGG_ECOLI | ymgG | ... | 4 | 2 | 4 |
151
+ | Q93K97 | sp\|Q93K97\|ADPP_ECOLI | ADPP_ECOLI | nudF | ... | 9 | 4 | 5 |
152
+
153
+ ## License
154
+
155
+ This project is licensed under the CC BY-NC-ND 4.0 License. Feel free to use the code according to the terms specified in the license.
156
+ This project is licensed under the CC BY-NC-ND 4.0 License. Feel free to use the code according to the terms specified in the license.
157
+
158
+ Thank you for your interest in FLiPPR!
159
+ If you encounter any issues or have suggestions, please open an issue.
160
+ We appreciate your feedback!
161
+
162
+ ## Citation
163
+ If you found this work helpful in your research, please cite us!
164
+
165
+ **FLiPPR: A Processor for Limited Proteolysis (LiP) Mass Spectrometry Data Sets Built on FragPipe**
166
+ Edgar Manriquez-Sandoval, Joy Brewer, Gabriela Lule, Samanta Lopez, and Stephen D. Fried
167
+ *Journal of Proteome Research*
168
+ DOI: ***10.1021/acs.jproteome.3c00887***
flippr-0.1.1/README.md ADDED
@@ -0,0 +1,134 @@
1
+ ![FLiPPR Logo](/assets/images/flippr_long_logo.png)
2
+
3
+ ## Table of Contents
4
+
5
+ - [Overview](#overview)
6
+ - [Support](#support)
7
+ - [Installation](#installation)
8
+ - [Usage](#usage)
9
+ - [License](#license)
10
+ - [Citation](#citation)
11
+
12
+ ## Overview
13
+
14
+ FLiPPR (**F**ragPipe **Li**mited-**P**roteolysis **Pr**ocessor) is modular, fast, and easy-to-use data processing tool for LiP-MS & LFQ-based experiments analyzed in FragPipe.
15
+
16
+ FLiPPR is:
17
+ * **Super Fast**: FLiPPR utilizes [Polars](https://pola.rs/) in the back-end to ensure all CPU cores contribute to your data processing.
18
+ * **Convinent to Use**: [FragPipe](https://fragpipe.nesvilab.org/) produces standarized outputs, FLiPPR takes full advantage of this feat and integrates seemlessly with any FragPipe LFQ-MBR anaylsis.
19
+ * **Flexible and Expandable**: Experiments introduce unique and novel variables, FLiPPR ensures capatibility with all experimental setups and gives you full control of the data processing pipeline.
20
+
21
+ ## Support
22
+ FLiPPR has been tested with Python 3.10 – 3.12
23
+ To learn more about how FLiPPR can help you analyze your LiP-MS or LFQ data, head over to the [FLiPPR docs](https://flippr.readthedocs.io)
24
+
25
+ ## Installation
26
+
27
+ To get started with FLiPPR, follow these steps:
28
+
29
+ ```bash
30
+ # 1. Clone the repository:
31
+ git clone https://https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor.git
32
+
33
+ # 2. Navigate to the project directory:
34
+ cd FragPipe-Limited-Proteolysis-Processor
35
+
36
+ # 3. Install FLiPPR:
37
+ python -m pip install .
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ 1. Start a `Study`
43
+
44
+ ```python
45
+ import flippr as fp
46
+ from flippr import Study
47
+
48
+ # Pass the FragPipe output directory path from your LiP-MS experiment
49
+ study = Study(lip = "path/to/lip")
50
+
51
+ # Include protein normalization factors from a Trypsin-only experiment
52
+ study = Study(lip = "path/to/lip", trp = "path/to/trp")
53
+
54
+ # Including the protein FASTA file will add metadata and remove contaminants
55
+ study = Study(lip = "path/to/lip", trp = "path/to/trp", fasta = "UP000000625_83333.fasta")
56
+ ```
57
+
58
+ 2. View the experimental sample annotations
59
+
60
+ ```python
61
+ print(study.samples)
62
+ # >>> { 'LiP': {'Native', 'Refolded_001_min', 'Refolded_005_min', 'Refolded_120_min'}, 'TrP': {'Refolded', 'Native'}}
63
+ ```
64
+
65
+ 3. Add an experimental process
66
+
67
+ ```python
68
+ # Process without normalization
69
+ study.add_process(1, "Native", "Refolded_001_min", 3)
70
+
71
+ # Process with normalizations (only when `trp` is included in the study)
72
+ study.add_process(5, "Native", "Refolded_005_min", 3, "Native", "Refolded", 3)
73
+
74
+ # Multiple processes within one study
75
+ study.add_process(1, "Native", "Refolded_001_min", 3, "Native", "Refolded", 3)
76
+ study.add_process(5, "Native", "Refolded_005_min", 3, "Native", "Refolded", 3)
77
+ study.add_process(120, "Native", "Refolded_120_min", 3, "Native", "Refolded", 3)
78
+ ```
79
+
80
+ 4. Run your study
81
+
82
+ ```python
83
+ # Running a study returns results and populates the `Study().results` dictionary
84
+ results = study.run()
85
+ # >>> {1: <flippr.Results>, 5: <flippr.Results>, 120: <flippr.Results>}
86
+
87
+ # Change analysis parameters within `fp.rcParams` before running for more control
88
+ fp.rcParams["protein.fc_sig_thresh"] = 2.0
89
+ results = study.run()
90
+ ```
91
+
92
+ 5. View or save your results as Polars DataFrames
93
+
94
+ ```python
95
+ # 1 min time point results
96
+ results_1_min = results[1]
97
+
98
+ # View all ions included in the 1 min experimental process
99
+ results_1_min.ion
100
+
101
+ # View higher-order results
102
+ results_1_min.modified_peptide
103
+ results_1_min.peptide
104
+ results_1_min.cut_site
105
+
106
+ # View protein-level summary of all data
107
+ results_1_min.protein_summary
108
+ ```
109
+
110
+ | Protein ID | Protein | Entry Name | Gene | ... | No. of Valid Cut Sites | No. of Significant Cut Sites | No. of Significant Cut Sites |
111
+ |------------|-----------------------------|-------------|--------|-----|------------------------|------------------------------|------------------------------|
112
+ | P00350 | sp\|P00350\|6PGD_ECOLI | 6PGD_ECOLI | gnd | ... | 111 | 40 | 50 |
113
+ | P00363 | sp\|P00363\|FRDA_ECOLI | FRDA_ECOLI | frdA | ... | 15 | 2 | 2 |
114
+ | Q57261 | sp\|Q57261\|TRUD_ECOLI | TRUD_ECOLI | truD | ... | 24 | 7 | 8 |
115
+ | Q59385 | sp\|Q59385\|COPA_ECOLI | COPA_ECOLI | copA | ... |13 | 2 | 1 |
116
+ | Q7DFV3 | sp\|Q7DFV3\|YMGG_ECOLI | YMGG_ECOLI | ymgG | ... | 4 | 2 | 4 |
117
+ | Q93K97 | sp\|Q93K97\|ADPP_ECOLI | ADPP_ECOLI | nudF | ... | 9 | 4 | 5 |
118
+
119
+ ## License
120
+
121
+ This project is licensed under the CC BY-NC-ND 4.0 License. Feel free to use the code according to the terms specified in the license.
122
+ This project is licensed under the CC BY-NC-ND 4.0 License. Feel free to use the code according to the terms specified in the license.
123
+
124
+ Thank you for your interest in FLiPPR!
125
+ If you encounter any issues or have suggestions, please open an issue.
126
+ We appreciate your feedback!
127
+
128
+ ## Citation
129
+ If you found this work helpful in your research, please cite us!
130
+
131
+ **FLiPPR: A Processor for Limited Proteolysis (LiP) Mass Spectrometry Data Sets Built on FragPipe**
132
+ Edgar Manriquez-Sandoval, Joy Brewer, Gabriela Lule, Samanta Lopez, and Stephen D. Fried
133
+ *Journal of Proteome Research*
134
+ DOI: ***10.1021/acs.jproteome.3c00887***
@@ -0,0 +1,114 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "flippr"
7
+ dynamic = ["version"]
8
+ description = "FragPipe Limited-Proteolysis Processor (FLiPPR) is modular, fast, and easy-to-use data processing tool for LiP-MS & LFQ-based experiments analyzed in FragPipe"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ keywords = [
12
+ "bottom-up proteomics",
13
+ "computational mass spectrometry",
14
+ "fragpipe",
15
+ "fragpipe analysis",
16
+ "limited proteolysis",
17
+ "lip-ms",
18
+ "lfq",
19
+ "label-free",
20
+ "label-free quantification",
21
+ "differential analysis",
22
+ "proteomics",
23
+ "flippr",
24
+ "fragpipe"
25
+ ]
26
+ authors = [
27
+ { name = "Edgar Manriquez-Sandoval", email = "emanriq1@jhu.edu"},
28
+ ]
29
+ maintainers = [
30
+ {name = "FriedLab@JHU", email = "friedlab.jhu@gmail.com"},
31
+ {name = "Stephen D. Fried", email = "sdfried@jhu.edu"},
32
+ {name = "Edgar Manriquez-Sandoval", email = "emanriq1@jhu.edu"},
33
+ ]
34
+ classifiers = [
35
+ "Development Status :: 4 - Beta",
36
+ "Programming Language :: Python",
37
+ "Programming Language :: Python :: 3.10",
38
+ "Programming Language :: Python :: 3.11",
39
+ "Programming Language :: Python :: Implementation :: CPython",
40
+ "Programming Language :: Python :: Implementation :: PyPy",
41
+ ]
42
+ dependencies = [
43
+ "biopython",
44
+ "h2",
45
+ "httpx",
46
+ "matplotlib",
47
+ "nest_asyncio",
48
+ "numpy",
49
+ "pandas",
50
+ "polars",
51
+ "pyarrow",
52
+ "requests",
53
+ "scipy",
54
+ "seaborn",
55
+ "xlsx2csv",
56
+ "xlsxwriter"
57
+ ]
58
+
59
+ [project.urls]
60
+ Documentation = "https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor#readme"
61
+ Issues = "https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processorissues"
62
+ Source = "https://github.com/FriedLabJHU/FragPipe-Limited-Proteolysis-Processor"
63
+
64
+ [tool.hatch.version]
65
+ path = "src/flippr/__about__.py"
66
+
67
+ [tool.hatch.envs.default]
68
+ dependencies = [
69
+ "coverage[toml]>=6.5",
70
+ "pytest",
71
+ ]
72
+ [tool.hatch.envs.default.scripts]
73
+ test = "pytest {args:tests}"
74
+ test-cov = "coverage run -m pytest {args:tests}"
75
+ cov-report = [
76
+ "- coverage combine",
77
+ "coverage report",
78
+ ]
79
+ cov = [
80
+ "test-cov",
81
+ "cov-report",
82
+ ]
83
+
84
+ [tool.setuptools.package-data]
85
+ "flippr" = ["py.typed"]
86
+
87
+ [[tool.hatch.envs.all.matrix]]
88
+ python = ["3.10", "3.11", "3.12"]
89
+
90
+ [tool.hatch.envs.types]
91
+ dependencies = [
92
+ "mypy>=1.0.0",
93
+ ]
94
+ [tool.hatch.envs.types.scripts]
95
+ check = "mypy --install-types --non-interactive {args:src/flippr tests}"
96
+
97
+ [tool.coverage.run]
98
+ source_pkgs = ["flippr", "tests"]
99
+ branch = true
100
+ parallel = true
101
+ omit = [
102
+ "src/flippr/__about__.py",
103
+ ]
104
+
105
+ [tool.coverage.paths]
106
+ flippr = ["src/flippr", "*/flippr/src/flippr"]
107
+ tests = ["tests", "*/flippr/tests"]
108
+
109
+ [tool.coverage.report]
110
+ exclude_lines = [
111
+ "no cov",
112
+ "if __name__ == .__main__.:",
113
+ "if TYPE_CHECKING:",
114
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.1"
@@ -0,0 +1,172 @@
1
+ from functools import cached_property
2
+ from pathlib import Path
3
+
4
+ import polars as pl
5
+
6
+ from . import spr as _spr
7
+ from . import validate as _validate
8
+ from .parameters import rcParams
9
+ from .uniprot import fasta as _fasta
10
+
11
+
12
+ class Study:
13
+ """
14
+ A FLiPPR Study is used to coordinate Limited Proteolysis (LiP) data processing for a single experiment analyzed with FragPipe.
15
+ Studies can contain LiP data alone or LiP and TrP data; with the inclusion of a FASTA file for automatic metadata generation.
16
+ TrP data should result from the same experimental conditions as the LiP data, but without including a broad-spectrum protease like Proteinase K (PK).
17
+
18
+ Args:
19
+ lip (str | Path): Directory or path to the FragPipe LFQ output data for Limited Proteolysis (LiP) experiment data.
20
+ trp (str | Path, optional): Directory or path to the FragPipe LFQ output data for Trypsin Only (TrP) experiment data. Defaults to None.
21
+ fasta (str | Path, optional): Path to the FASTA file containing the same protein sequences used in the LiP/TrP experiments. Defaults to None.
22
+ method (str): Method used to quantify ion intensities in FragPipe. `lfq` - Label-Free Quantification, `silac` - Stable Isotope Labelling (currently not incorporated). Defaults to `lfq`.
23
+
24
+ Examples:
25
+ Analysis of a single dataset
26
+ >>> flippr.Study(lip = "PXD025926/FragPipe/LiP_LFQ")
27
+
28
+ Analysis of a single dataset with metadata integration
29
+ >>> flippr.Study(lip = "PXD025926/FragPipe/LiP_LFQ", fasta = "UP000000625.fasta")
30
+
31
+ Including protein-level normalization from trypsin-only data
32
+ >>> flippr.Study(lip = "PXD025926/FragPipe/LiP_LFQ", trp = "PXD025926/FragPipe/TrP_LFQ")
33
+
34
+ """
35
+
36
+ def __init__(self, lip: str | Path, trp: str | Path | None = None, fasta: str | Path | None = None, method: str = "lfq") -> None:
37
+
38
+ _lip, _trp, _fasta_path, _method = _validate._validate_study(lip, trp, fasta, method)
39
+
40
+ self.lip: Path = _lip
41
+ self.trp: Path | None = _trp
42
+ self._fasta_path: Path | None = _fasta_path
43
+ self.method: str = _method
44
+
45
+ self._pid: int = 0
46
+ self.processes: dict = dict()
47
+ self.results: dict = dict()
48
+
49
+ @property
50
+ def samples(self) -> dict:
51
+ """
52
+ Returns the names of the samples or experimental annotations found in the FragPipe outputs for LiP and TrP (if include) datasets.
53
+
54
+ Examples:
55
+ Including only LiP data
56
+ >>> e_coli_refolding = flippr.Study(lip = "PXD025926/FragPipe/LiP_LFQ")
57
+ >>> print(e_coli_refolding.samples)
58
+ {"LiP": ("Native", "Refolded_01_min", "Refolded_05_min", "Refolded_30_min")}
59
+
60
+ Including LiP and TrP data
61
+ >>> e_coli_refolding = flippr.Study(lip = "PXD025926/FragPipe/LiP_LFQ", trp = "PXD025926/FragPipe/TrP_LFQ")
62
+ >>> print(e_coli_refolding.samples)
63
+ {"LiP": ("Native", "Refolded_01_min", "Refolded_05_min", "Refolded_30_min"),
64
+ "TrP": ("Native", "Refolded")}
65
+
66
+ """
67
+
68
+ if self.trp is not None:
69
+ return {"LiP": self.lip_samples, "TrP": self.trp_samples}
70
+
71
+ return {"LiP": self.lip_samples}
72
+
73
+ @property
74
+ def lip_samples(self) -> set:
75
+ """
76
+ Returns the names of the samples or experimental annotations found in the FragPipe outputs for LiP datasets.
77
+
78
+ """
79
+
80
+ return self.__read_annotation(self.lip)
81
+
82
+ @property
83
+ def trp_samples(self) -> set:
84
+ """
85
+ Returns the names of the samples or experimental annotations found in the FragPipe outputs for TrP datasets.
86
+
87
+ """
88
+
89
+ return self.__read_annotation(self.trp)
90
+
91
+ @cached_property
92
+ def fasta(self) -> pl.DataFrame | None:
93
+ """
94
+ Returns a three column dataframe containing Protein IDs, Sequences, and Valid ID if the Protein ID is interpretable as an official Uniprot ID.
95
+
96
+ """
97
+ if self._fasta_path is not None:
98
+ return _fasta._read_fasta(self._fasta_path)
99
+
100
+ return None
101
+
102
+ def add_process(
103
+ self, pid: object | None, lip_ctrl: str, lip_test: str, n_rep: int, trp_ctrl: str | None = None, trp_test: str | None = None, trp_n_rep: int | None = None) -> None:
104
+ """
105
+ Adding a process to calculate the fold-change between test and control conditions.
106
+ Normalization is optional and must include a TrP experiment in the `Study` set-up.
107
+
108
+ Args:
109
+ pid (Any): Process ID used to index the `Study().results` dictionary after running `Study().run()`.
110
+ lip_ctrl (str): Control condition sample name from the LiP experiment.
111
+ lip_test (str): Test condition sample name from the LiP experiment.
112
+ n_rep (int): Number of replicates in the LiP experiment.
113
+ trp_ctrl (str, optional): Control condition sample name from the TrP experiment.
114
+ trp_test (str, optional): Test condition sample name from the TrP experiment.
115
+ trp_n_rep (int, optional): Number of replicates in the TrP experiment.
116
+
117
+ Examples:
118
+ Simple fold-change calculation between two conditions
119
+ >>> study.add_process("sample", "WT", "Drug", 3)
120
+
121
+ Fold-change calculation with normalization
122
+ >>> study.add_process("sample", "WT", "Drug", 3, "WT_TrP", "DMSO_TrP", 3)
123
+
124
+ Add multiple processes to the same study
125
+ >>> study.add_process("cond_1", "WT", "Cond1", 5)
126
+ >>> study.add_process("cond_2", "WT", "Cond2", 5, "WT_TrP", "DMSO_TrP", 5)
127
+ """
128
+
129
+ if pid is None:
130
+ pid = self._pid
131
+ self._pid += 1
132
+
133
+ self.processes.update(
134
+ {
135
+ pid: _spr.Process(
136
+ self.fasta,
137
+ self.lip,
138
+ self.trp,
139
+ pid,
140
+ lip_ctrl,
141
+ lip_test,
142
+ n_rep,
143
+ trp_ctrl,
144
+ trp_test,
145
+ trp_n_rep,
146
+ )
147
+ }
148
+ )
149
+
150
+ def run(self) -> dict[object: _spr.Result]:
151
+ """
152
+ Run the processes added to the study.
153
+ Study parameters can be changed by editing the `flippr.rcParams` dictionary.
154
+ """
155
+
156
+ self.results = {pid: proc.run(rcParams) for pid, proc in self.processes.items()}
157
+
158
+ return self.results
159
+
160
+ def __read_annotation(self, liptrp: Path) -> set:
161
+ def __strip_fragpipe_repilicate(sample: str) -> str:
162
+ return "_".join([_ for _ in sample.split("_")[:-1]])
163
+
164
+ annotation = liptrp.joinpath("experiment_annotation.tsv")
165
+
166
+ annotation_df = pl.read_csv(annotation, separator="\t")
167
+
168
+ annotation_dict = annotation_df.select(pl.col("sample")).to_dict(
169
+ as_series=False
170
+ )
171
+
172
+ return set(__strip_fragpipe_repilicate(sample) for sample in annotation_dict["sample"])