quantms-rescoring 0.0.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.
- quantms_rescoring-0.0.1/LICENSE +201 -0
- quantms_rescoring-0.0.1/PKG-INFO +67 -0
- quantms_rescoring-0.0.1/README.md +31 -0
- quantms_rescoring-0.0.1/pyproject.toml +62 -0
- quantms_rescoring-0.0.1/quantmsrescore/__init__.py +1 -0
- quantms_rescoring-0.0.1/quantmsrescore/ms2rescore.py +496 -0
- quantms_rescoring-0.0.1/quantmsrescore/rescoring.py +29 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: quantms-rescoring
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: quantms-rescoring: Python scripts and helpers for the quantMS workflow
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: quantms,proteomics,mass-spectrometry,data-analysis,big data
|
|
7
|
+
Author: Yasset Perez-Riverol
|
|
8
|
+
Author-email: ypriverol@gmail.com
|
|
9
|
+
Requires-Python: >=3.8,<3.11
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Requires-Dist: click
|
|
21
|
+
Requires-Dist: deepLC (==2.2.38)
|
|
22
|
+
Requires-Dist: ms2rescore (==3.0.3)
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: pandas
|
|
25
|
+
Requires-Dist: protobuf (==3.19.6)
|
|
26
|
+
Requires-Dist: psm-utils (==0.8.3)
|
|
27
|
+
Requires-Dist: pygam
|
|
28
|
+
Requires-Dist: pyopenms
|
|
29
|
+
Requires-Dist: scipy (==1.13.1)
|
|
30
|
+
Project-URL: GitHub, https://github.com/bigbio/quantms-rescoring
|
|
31
|
+
Project-URL: LICENSE, https://github.com/bigbio/quantms-rescoring/blob/main/LICENSE
|
|
32
|
+
Project-URL: PyPi, https://pypi.org/project/quantms-rescoring/
|
|
33
|
+
Project-URL: Quantms, https://quantms.org
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# quantms-rescoring
|
|
37
|
+
|
|
38
|
+
[](https://github.com/bigbio/quantms-rescoring/actions/workflows/python-package.yml)
|
|
39
|
+
[](https://codecov.io/gh/bigbio/quantms-rescoring)
|
|
40
|
+
[](https://badge.fury.io/py/quantms-rescoring)
|
|
41
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
42
|
+
|
|
43
|
+
quantms-rescoring is a Python tool for rescoring peptide-spectrum matches (PSMs) in idXML files. It is part of the quantms ecosystem package and leverages the MS²Rescore framework to improve identification confidence in proteomics data analysis.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- Enhanced Rescoring: Utilizes advanced rescoring engines like Percolator to refine PSM scores.
|
|
48
|
+
- Flexible Feature Generators: Supports feature extraction using tools like MS²PIP, DeepLC, and custom generators.
|
|
49
|
+
- Metadata Retention: Preserves essential metadata from the input idXML files.
|
|
50
|
+
- Error Handling: Skips invalid PSMs and logs issues for transparent processing.
|
|
51
|
+
- Seamless Integration: Built to integrate into proteomics workflows.
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
To use quantms-rescoring, ensure the following dependencies are installed:
|
|
56
|
+
|
|
57
|
+
- Python 3.8+
|
|
58
|
+
- click
|
|
59
|
+
- pyopenms
|
|
60
|
+
- ms2rescore
|
|
61
|
+
- psm_utils
|
|
62
|
+
|
|
63
|
+
### Issues and Contributions
|
|
64
|
+
|
|
65
|
+
For any issues or contributions, please open an issue in the [GitHub repository](https://github.com/bigbio/quantms/issues) - we use the quantms repo to control all issues—or PR in the [GitHub repository](https://github.com/bigbio/quantms-rescoring/pulls).
|
|
66
|
+
|
|
67
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# quantms-rescoring
|
|
2
|
+
|
|
3
|
+
[](https://github.com/bigbio/quantms-rescoring/actions/workflows/python-package.yml)
|
|
4
|
+
[](https://codecov.io/gh/bigbio/quantms-rescoring)
|
|
5
|
+
[](https://badge.fury.io/py/quantms-rescoring)
|
|
6
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
7
|
+
|
|
8
|
+
quantms-rescoring is a Python tool for rescoring peptide-spectrum matches (PSMs) in idXML files. It is part of the quantms ecosystem package and leverages the MS²Rescore framework to improve identification confidence in proteomics data analysis.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Enhanced Rescoring: Utilizes advanced rescoring engines like Percolator to refine PSM scores.
|
|
13
|
+
- Flexible Feature Generators: Supports feature extraction using tools like MS²PIP, DeepLC, and custom generators.
|
|
14
|
+
- Metadata Retention: Preserves essential metadata from the input idXML files.
|
|
15
|
+
- Error Handling: Skips invalid PSMs and logs issues for transparent processing.
|
|
16
|
+
- Seamless Integration: Built to integrate into proteomics workflows.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
To use quantms-rescoring, ensure the following dependencies are installed:
|
|
21
|
+
|
|
22
|
+
- Python 3.8+
|
|
23
|
+
- click
|
|
24
|
+
- pyopenms
|
|
25
|
+
- ms2rescore
|
|
26
|
+
- psm_utils
|
|
27
|
+
|
|
28
|
+
### Issues and Contributions
|
|
29
|
+
|
|
30
|
+
For any issues or contributions, please open an issue in the [GitHub repository](https://github.com/bigbio/quantms/issues) - we use the quantms repo to control all issues—or PR in the [GitHub repository](https://github.com/bigbio/quantms-rescoring/pulls).
|
|
31
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "quantms-rescoring"
|
|
3
|
+
description = "quantms-rescoring: Python scripts and helpers for the quantMS workflow"
|
|
4
|
+
readme = "README.md"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
version = "0.0.1"
|
|
7
|
+
authors = [
|
|
8
|
+
"Yasset Perez-Riverol <ypriverol@gmail.com>",
|
|
9
|
+
"Dai Chengxin <chengxin2024@126.com>",
|
|
10
|
+
"Julianus Pfeuffer <jule.pf@gmail.com>"
|
|
11
|
+
]
|
|
12
|
+
keywords = [
|
|
13
|
+
"quantms",
|
|
14
|
+
"proteomics",
|
|
15
|
+
"mass-spectrometry",
|
|
16
|
+
"data-analysis",
|
|
17
|
+
"big data"
|
|
18
|
+
]
|
|
19
|
+
classifiers = [
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"License :: OSI Approved :: MIT License",
|
|
22
|
+
"Operating System :: OS Independent",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
25
|
+
"Development Status :: 5 - Production/Stable"
|
|
26
|
+
]
|
|
27
|
+
packages = [
|
|
28
|
+
{ include = "quantmsrescore" }
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[tool.poetry.dependencies]
|
|
32
|
+
python = ">=3.8,<3.11"
|
|
33
|
+
click = "*"
|
|
34
|
+
pyopenms = "*"
|
|
35
|
+
ms2rescore = "3.0.3"
|
|
36
|
+
pandas = "*"
|
|
37
|
+
numpy = "*"
|
|
38
|
+
psm-utils = "0.8.3"
|
|
39
|
+
deepLC = "2.2.38"
|
|
40
|
+
scipy = "1.13.1"
|
|
41
|
+
pygam = "*"
|
|
42
|
+
protobuf= "3.19.6"
|
|
43
|
+
|
|
44
|
+
[tool.poetry.urls]
|
|
45
|
+
GitHub = "https://github.com/bigbio/quantms-rescoring"
|
|
46
|
+
PyPi = "https://pypi.org/project/quantms-rescoring/"
|
|
47
|
+
Quantms = "https://quantms.org"
|
|
48
|
+
LICENSE = "https://github.com/bigbio/quantms-rescoring/blob/main/LICENSE"
|
|
49
|
+
|
|
50
|
+
[tool.poetry.scripts]
|
|
51
|
+
rescoring = "quantmsrescore.rescoring:main"
|
|
52
|
+
|
|
53
|
+
[tool.isort]
|
|
54
|
+
profile = "black"
|
|
55
|
+
|
|
56
|
+
[tool.black]
|
|
57
|
+
line-length = 99
|
|
58
|
+
target-version = ["py39"]
|
|
59
|
+
|
|
60
|
+
[build-system]
|
|
61
|
+
requires = ["poetry-core>=1.2.0"]
|
|
62
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
# Written by Jonas Scheid under the MIT license
|
|
2
|
+
# Contributions by Yasset Perez-Riverol and Dai Chengxin
|
|
3
|
+
# This script is part of the quantmsutils package
|
|
4
|
+
|
|
5
|
+
import importlib.resources
|
|
6
|
+
import json
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
import pyopenms as oms
|
|
11
|
+
from ms2rescore import package_data, rescore
|
|
12
|
+
from psm_utils import PSMList
|
|
13
|
+
from psm_utils.io.idxml import IdXMLReader, IdXMLWriter
|
|
14
|
+
from typing import Iterable, List, Union
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from psm_utils.psm import PSM
|
|
17
|
+
|
|
18
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class IDXMLReaderPatch(IdXMLReader):
|
|
22
|
+
def __init__(self, filename: Union[Path, str], *args, **kwargs) -> None:
|
|
23
|
+
"""
|
|
24
|
+
Patch Reader for idXML files based on IDXMLReader.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
filename: str, pathlib.Path
|
|
29
|
+
Path to idXML file.
|
|
30
|
+
|
|
31
|
+
Examples
|
|
32
|
+
--------
|
|
33
|
+
"""
|
|
34
|
+
super().__init__(filename, *args, **kwargs)
|
|
35
|
+
self.protein_ids, self.peptide_ids = self._parse_idxml()
|
|
36
|
+
self.user_params_metadata = self._get_userparams_metadata(self.peptide_ids[0].getHits()[0])
|
|
37
|
+
self.rescoring_features = self._get_rescoring_features(self.peptide_ids[0].getHits()[0])
|
|
38
|
+
self.skip_invalid_psm = 0
|
|
39
|
+
|
|
40
|
+
def __iter__(self) -> Iterable[PSM]:
|
|
41
|
+
"""
|
|
42
|
+
Iterate over file and return PSMs one-by-one.
|
|
43
|
+
Test cases will:
|
|
44
|
+
|
|
45
|
+
Input PSM 1: PeptideHit with metavalue
|
|
46
|
+
"MSGF:ScoreRatio" value="0.212121212121212"/>
|
|
47
|
+
"MSGF:Energy" value="130.0"/>
|
|
48
|
+
"MSGF:lnEValue" value="-3.603969939390662"/>
|
|
49
|
+
"MSGF:lnExplainedIonCurrentRatio" value="-0.881402756873971"/>
|
|
50
|
+
"MSGF:lnNTermIonCurrentRatio" value="-1.931878317286471"/>
|
|
51
|
+
"MSGF:lnCTermIonCurrentRatio" value="-1.311462733724937"/>
|
|
52
|
+
"MSGF:lnMS2IonCurrent" value="9.702930189540499"/>
|
|
53
|
+
"MSGF:MeanErrorTop7" value="259.986879999999985"/>
|
|
54
|
+
"MSGF:sqMeanErrorTop7" value="6.75931777721344e04"/>
|
|
55
|
+
"MSGF:StdevErrorTop7" value="143.678020000000004"/>
|
|
56
|
+
PSM2: PeptideHit No above metaValue
|
|
57
|
+
|
|
58
|
+
Run:
|
|
59
|
+
reader = IDXMLReaderPatch(input_file)
|
|
60
|
+
psm_list = reader.read_file()
|
|
61
|
+
|
|
62
|
+
psm_list: return [PSM 1]
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
for peptide_id in self.peptide_ids:
|
|
66
|
+
for peptide_hit in peptide_id.getHits():
|
|
67
|
+
psm = self._parse_psm(self.protein_ids, peptide_id, peptide_hit)
|
|
68
|
+
if psm is not None:
|
|
69
|
+
yield psm
|
|
70
|
+
else:
|
|
71
|
+
self.skip_invalid_psm += 1
|
|
72
|
+
|
|
73
|
+
def _parse_psm(
|
|
74
|
+
self,
|
|
75
|
+
protein_ids: oms.ProteinIdentification,
|
|
76
|
+
peptide_id: oms.PeptideIdentification,
|
|
77
|
+
peptide_hit: oms.PeptideHit,
|
|
78
|
+
) -> PSM:
|
|
79
|
+
"""
|
|
80
|
+
Parse idXML :py:class:`~pyopenms.PeptideHit` to :py:class:`~psm_utils.psm.PSM`.
|
|
81
|
+
|
|
82
|
+
Uses additional information from :py:class:`~pyopenms.ProteinIdentification` and
|
|
83
|
+
:py:class:`~pyopenms.PeptideIdentification` to annotate parameters of the
|
|
84
|
+
:py:class:`~psm_utils.psm.PSM` object.
|
|
85
|
+
"""
|
|
86
|
+
peptidoform = self._parse_peptidoform(
|
|
87
|
+
peptide_hit.getSequence().toString(), peptide_hit.getCharge()
|
|
88
|
+
)
|
|
89
|
+
# This is needed to calculate a qvalue before rescoring the PSMList
|
|
90
|
+
peptide_id_metadata = {
|
|
91
|
+
"idxml:score_type": str(peptide_id.getScoreType()),
|
|
92
|
+
"idxml:higher_score_better": str(peptide_id.isHigherScoreBetter()),
|
|
93
|
+
"idxml:significance_threshold": str(peptide_id.getSignificanceThreshold()),
|
|
94
|
+
}
|
|
95
|
+
peptide_hit_metadata = {
|
|
96
|
+
key: peptide_hit.getMetaValue(key) for key in self.user_params_metadata
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# Get search engines score features and check valueExits
|
|
100
|
+
rescoring_features = {}
|
|
101
|
+
for key in self.rescoring_features:
|
|
102
|
+
feature = peptide_hit.metaValueExists(key)
|
|
103
|
+
if not feature:
|
|
104
|
+
return None
|
|
105
|
+
else:
|
|
106
|
+
rescoring_features[key] = float(peptide_hit.getMetaValue(key))
|
|
107
|
+
|
|
108
|
+
return PSM(
|
|
109
|
+
peptidoform=peptidoform,
|
|
110
|
+
spectrum_id=peptide_id.getMetaValue("spectrum_reference"),
|
|
111
|
+
run=self._get_run(protein_ids, peptide_id),
|
|
112
|
+
is_decoy=self._is_decoy(peptide_hit),
|
|
113
|
+
score=peptide_hit.getScore(),
|
|
114
|
+
precursor_mz=peptide_id.getMZ(),
|
|
115
|
+
retention_time=peptide_id.getRT(),
|
|
116
|
+
# NOTE: ion mobility will be supported by OpenMS in the future
|
|
117
|
+
protein_list=[
|
|
118
|
+
accession.decode() for accession in peptide_hit.extractProteinAccessionsSet()
|
|
119
|
+
],
|
|
120
|
+
rank=peptide_hit.getRank() + 1, # 0-based to 1-based
|
|
121
|
+
source="idXML",
|
|
122
|
+
# Storing proforma notation of peptidoform and UNIMOD peptide sequence for mapping back
|
|
123
|
+
# to original sequence in writer
|
|
124
|
+
provenance_data={str(peptidoform): peptide_hit.getSequence().toString()},
|
|
125
|
+
# Store metadata of PeptideIdentification and PeptideHit objects
|
|
126
|
+
metadata={**peptide_id_metadata, **peptide_hit_metadata},
|
|
127
|
+
|
|
128
|
+
rescoring_features=rescoring_features,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def parse_cli_arguments_to_config(
|
|
133
|
+
config_file: str = None,
|
|
134
|
+
feature_generators: str = None,
|
|
135
|
+
ms2pip_model_dir: str = None,
|
|
136
|
+
ms2pip_model: str = None,
|
|
137
|
+
ms2_tolerance: float = None,
|
|
138
|
+
calibration_set_size: float = None,
|
|
139
|
+
rescoring_engine: str = None,
|
|
140
|
+
rng: int = None,
|
|
141
|
+
test_fdr: float = None,
|
|
142
|
+
processes: int = None,
|
|
143
|
+
spectrum_path: str = None,
|
|
144
|
+
fasta_file: str = None,
|
|
145
|
+
id_decoy_pattern: str = None,
|
|
146
|
+
lower_score_is_better: bool = None,
|
|
147
|
+
output_path: str = None,
|
|
148
|
+
log_level: str = None,
|
|
149
|
+
spectrum_id_pattern: str = None,
|
|
150
|
+
psm_id_pattern: str = None
|
|
151
|
+
) -> dict:
|
|
152
|
+
if config_file is None:
|
|
153
|
+
config = json.load(
|
|
154
|
+
importlib.resources.open_text(package_data, "config_default.json")
|
|
155
|
+
)
|
|
156
|
+
else:
|
|
157
|
+
with open(config_file) as f:
|
|
158
|
+
config = json.load(f)
|
|
159
|
+
if feature_generators is not None:
|
|
160
|
+
feature_generators_list = feature_generators.split(",")
|
|
161
|
+
config["ms2rescore"]["feature_generators"] = {}
|
|
162
|
+
if "basic" in feature_generators_list:
|
|
163
|
+
config["ms2rescore"]["feature_generators"]["basic"] = {}
|
|
164
|
+
if "ms2pip" in feature_generators_list:
|
|
165
|
+
config["ms2rescore"]["feature_generators"]["ms2pip"] = {
|
|
166
|
+
"model_dir": ms2pip_model_dir,
|
|
167
|
+
"model": ms2pip_model,
|
|
168
|
+
"ms2_tolerance": ms2_tolerance,
|
|
169
|
+
}
|
|
170
|
+
if "deeplc" in feature_generators_list:
|
|
171
|
+
config["ms2rescore"]["feature_generators"]["deeplc"] = {
|
|
172
|
+
"deeplc_retrain": False,
|
|
173
|
+
"calibration_set_size": calibration_set_size,
|
|
174
|
+
}
|
|
175
|
+
if "maxquant" in feature_generators_list:
|
|
176
|
+
config["ms2rescore"]["feature_generators"]["maxquant"] = {}
|
|
177
|
+
if "ionmob" in feature_generators:
|
|
178
|
+
config["ms2rescore"]["feature_generators"]["ionmob"] = {}
|
|
179
|
+
|
|
180
|
+
if rescoring_engine is not None:
|
|
181
|
+
# Reset rescoring engine dict we want to allow only computing features
|
|
182
|
+
config["ms2rescore"]["rescoring_engine"] = {}
|
|
183
|
+
if rescoring_engine == "mokapot":
|
|
184
|
+
config["ms2rescore"]["rescoring_engine"]["mokapot"] = {
|
|
185
|
+
"write_weights": True,
|
|
186
|
+
"write_txt": False,
|
|
187
|
+
"write_flashlfq": False,
|
|
188
|
+
"rng": rng,
|
|
189
|
+
"test_fdr": test_fdr,
|
|
190
|
+
"max_workers": processes,
|
|
191
|
+
}
|
|
192
|
+
if rescoring_engine == "percolator":
|
|
193
|
+
logging.info(
|
|
194
|
+
"Percolator rescoring engine has been specified. Use the idXML containing rescoring features and run Percolator in a separate step."
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
if ms2pip_model_dir is not None:
|
|
198
|
+
config["ms2rescore"]["ms2pip_model_dir"] = ms2pip_model_dir
|
|
199
|
+
if ms2pip_model is not None:
|
|
200
|
+
config["ms2rescore"]["ms2pip_model"] = ms2pip_model
|
|
201
|
+
if ms2_tolerance is not None:
|
|
202
|
+
config["ms2rescore"]["ms2_tolerance"] = ms2_tolerance
|
|
203
|
+
if calibration_set_size is not None:
|
|
204
|
+
config["ms2rescore"]["calibration_set_size"] = calibration_set_size
|
|
205
|
+
if rng is not None:
|
|
206
|
+
config["ms2rescore"]["rng"] = rng
|
|
207
|
+
if spectrum_path is not None:
|
|
208
|
+
config["ms2rescore"]["spectrum_path"] = spectrum_path
|
|
209
|
+
if fasta_file is not None:
|
|
210
|
+
config["ms2rescore"]["fasta_file"] = fasta_file
|
|
211
|
+
if id_decoy_pattern is not None:
|
|
212
|
+
config["ms2rescore"]["id_decoy_pattern"] = id_decoy_pattern
|
|
213
|
+
if lower_score_is_better is not None:
|
|
214
|
+
config["ms2rescore"]["lower_score_is_better"] = lower_score_is_better
|
|
215
|
+
if processes is None:
|
|
216
|
+
processes = 1 # Default to single process
|
|
217
|
+
config["ms2rescore"]["processes"] = processes
|
|
218
|
+
if output_path is not None:
|
|
219
|
+
config["ms2rescore"]["output_path"] = output_path
|
|
220
|
+
else:
|
|
221
|
+
raise ValueError("Output path must be specified.")
|
|
222
|
+
if log_level is not None:
|
|
223
|
+
config["ms2rescore"]["log_level"] = log_level
|
|
224
|
+
if spectrum_id_pattern is not None:
|
|
225
|
+
config["ms2rescore"]["spectrum_id_pattern"] = spectrum_id_pattern
|
|
226
|
+
if psm_id_pattern is not None:
|
|
227
|
+
config["ms2rescore"]["psm_id_pattern"] = psm_id_pattern
|
|
228
|
+
|
|
229
|
+
return config
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def rescore_idxml(input_file, output_file, config) -> None:
|
|
233
|
+
"""Rescore PSMs in an idXML file and keep other information unchanged."""
|
|
234
|
+
# Read PSMs
|
|
235
|
+
reader = IDXMLReaderPatch(input_file)
|
|
236
|
+
psm_list = reader.read_file()
|
|
237
|
+
|
|
238
|
+
if reader.skip_invalid_psm != 0:
|
|
239
|
+
logging.warning(
|
|
240
|
+
f"Removed {reader.skip_invalid_psm} PSMs without search engine features!"
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
# Rescore
|
|
244
|
+
rescore(config, psm_list)
|
|
245
|
+
|
|
246
|
+
# Filter out PeptideHits within PeptideIdentification(s) that could not be processed by all feature generators
|
|
247
|
+
peptide_ids_filtered = filter_out_artifact_psms(psm_list, reader.peptide_ids)
|
|
248
|
+
|
|
249
|
+
# Write
|
|
250
|
+
writer = IdXMLWriter(output_file, reader.protein_ids, peptide_ids_filtered)
|
|
251
|
+
writer.write_file(psm_list)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def filter_out_artifact_psms(
|
|
255
|
+
psm_list: PSMList, peptide_ids: List[oms.PeptideIdentification]
|
|
256
|
+
) -> List[oms.PeptideIdentification]:
|
|
257
|
+
"""Filter out PeptideHits that could not be processed by all feature generators"""
|
|
258
|
+
num_mandatory_features = max([len(psm.rescoring_features) for psm in psm_list])
|
|
259
|
+
new_psm_list = PSMList(
|
|
260
|
+
psm_list=[
|
|
261
|
+
psm
|
|
262
|
+
for psm in psm_list
|
|
263
|
+
if len(psm.rescoring_features) == num_mandatory_features
|
|
264
|
+
]
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# get differing peptidoforms of both psm lists
|
|
268
|
+
psm_list_peptides = set(
|
|
269
|
+
[next(iter(psm.provenance_data.items()))[1] for psm in psm_list]
|
|
270
|
+
)
|
|
271
|
+
new_psm_list_peptides = set(
|
|
272
|
+
[next(iter(psm.provenance_data.items()))[1] for psm in new_psm_list]
|
|
273
|
+
)
|
|
274
|
+
not_supported_peptides = psm_list_peptides - new_psm_list_peptides
|
|
275
|
+
|
|
276
|
+
# no need to filter if all peptides are supported
|
|
277
|
+
if len(not_supported_peptides) == 0:
|
|
278
|
+
return peptide_ids
|
|
279
|
+
# Create new peptide ids and filter out not supported peptides
|
|
280
|
+
new_peptide_ids = []
|
|
281
|
+
for peptide_id in peptide_ids:
|
|
282
|
+
new_hits = []
|
|
283
|
+
for hit in peptide_id.getHits():
|
|
284
|
+
if hit.getSequence().toString() in not_supported_peptides:
|
|
285
|
+
continue
|
|
286
|
+
new_hits.append(hit)
|
|
287
|
+
if len(new_hits) == 0:
|
|
288
|
+
continue
|
|
289
|
+
peptide_id.setHits(new_hits)
|
|
290
|
+
new_peptide_ids.append(peptide_id)
|
|
291
|
+
logging.info(
|
|
292
|
+
f"Removed {len(psm_list_peptides) - len(new_psm_list_peptides)} PSMs. Peptides not supported: {not_supported_peptides}"
|
|
293
|
+
)
|
|
294
|
+
return new_peptide_ids
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
@click.command(
|
|
298
|
+
"ms2rescore",
|
|
299
|
+
short_help="Rescore PSMs in an idXML file and keep other information unchanged.",
|
|
300
|
+
)
|
|
301
|
+
@click.option(
|
|
302
|
+
"-p",
|
|
303
|
+
"--psm_file",
|
|
304
|
+
help="Path to PSM file (idXML)",
|
|
305
|
+
required=True,
|
|
306
|
+
type=click.Path(exists=True),
|
|
307
|
+
)
|
|
308
|
+
@click.option(
|
|
309
|
+
"-s",
|
|
310
|
+
"--spectrum_path",
|
|
311
|
+
help="Path to MGF/mzML spectrum file or directory with spectrum files (default: derived from identification file)",
|
|
312
|
+
required=True,
|
|
313
|
+
type=click.Path(exists=True),
|
|
314
|
+
)
|
|
315
|
+
@click.option(
|
|
316
|
+
"-o",
|
|
317
|
+
"--output_path",
|
|
318
|
+
help="Path and stem for output file names (default: derive from identification file)",
|
|
319
|
+
)
|
|
320
|
+
@click.option(
|
|
321
|
+
"-l", "--log_level", help="Logging level (default: `info`)", default="info"
|
|
322
|
+
)
|
|
323
|
+
@click.option(
|
|
324
|
+
"-n",
|
|
325
|
+
"--processes",
|
|
326
|
+
help="Number of parallel processes available to MS²Rescore",
|
|
327
|
+
type=int,
|
|
328
|
+
default=16,
|
|
329
|
+
)
|
|
330
|
+
@click.option("-f", "--fasta_file", help="Path to FASTA file")
|
|
331
|
+
@click.option(
|
|
332
|
+
"-t",
|
|
333
|
+
"--test_fdr",
|
|
334
|
+
help="The false-discovery rate threshold at which to evaluate the learned models. (default: 0.05)",
|
|
335
|
+
default=0.05,
|
|
336
|
+
)
|
|
337
|
+
@click.option(
|
|
338
|
+
"-fg",
|
|
339
|
+
"--feature_generators",
|
|
340
|
+
help="Comma-separated list of feature generators to use (default: `ms2pip,deeplc`). See rescoring doc for further information",
|
|
341
|
+
default="",
|
|
342
|
+
)
|
|
343
|
+
@click.option(
|
|
344
|
+
"-pipm",
|
|
345
|
+
"--ms2pip_model",
|
|
346
|
+
help="MS²PIP model (default: `Immuno-HCD`)",
|
|
347
|
+
type=str,
|
|
348
|
+
default="Immuno-HCD",
|
|
349
|
+
)
|
|
350
|
+
@click.option(
|
|
351
|
+
"-md",
|
|
352
|
+
"--ms2pip_model_dir",
|
|
353
|
+
help="The path of MS²PIP model (default: `./`)",
|
|
354
|
+
type=str,
|
|
355
|
+
default="./",
|
|
356
|
+
)
|
|
357
|
+
@click.option(
|
|
358
|
+
"-ms2tol",
|
|
359
|
+
"--ms2_tolerance",
|
|
360
|
+
help="Fragment mass tolerance [Da](default: `0.02`)",
|
|
361
|
+
type=float,
|
|
362
|
+
default=0.02,
|
|
363
|
+
)
|
|
364
|
+
@click.option(
|
|
365
|
+
"-cs",
|
|
366
|
+
"--calibration_set_size",
|
|
367
|
+
help="Percentage of number of calibration set for DeepLC (default: `0.15`)",
|
|
368
|
+
default=0.15,
|
|
369
|
+
)
|
|
370
|
+
@click.option(
|
|
371
|
+
"-re",
|
|
372
|
+
"--rescoring_engine",
|
|
373
|
+
help="Either mokapot or percolator (default: `percolator`)",
|
|
374
|
+
default="percolator",
|
|
375
|
+
type=click.Choice(["mokapot", "percolator"]),
|
|
376
|
+
)
|
|
377
|
+
@click.option(
|
|
378
|
+
"-rng",
|
|
379
|
+
"--rng",
|
|
380
|
+
help="Seed for mokapot's random number generator (default: `4711`)",
|
|
381
|
+
type=int,
|
|
382
|
+
default=4711,
|
|
383
|
+
)
|
|
384
|
+
@click.option(
|
|
385
|
+
"-d",
|
|
386
|
+
"--id_decoy_pattern",
|
|
387
|
+
help="Regex decoy pattern (default: `DECOY_`)",
|
|
388
|
+
default="^DECOY_",
|
|
389
|
+
)
|
|
390
|
+
@click.option(
|
|
391
|
+
"-lsb",
|
|
392
|
+
"--lower_score_is_better",
|
|
393
|
+
help="Interpretation of primary search engine score (default: True)",
|
|
394
|
+
default=True,
|
|
395
|
+
)
|
|
396
|
+
@click.option(
|
|
397
|
+
"--config_file",
|
|
398
|
+
help="Path to MS²Rescore config file (default: `config_default.json`)",
|
|
399
|
+
default=None,
|
|
400
|
+
)
|
|
401
|
+
@click.option(
|
|
402
|
+
"--spectrum_id_pattern",
|
|
403
|
+
help="Regex pattern to extract index or scan number from spectrum file. Requires at least one capturing group.",
|
|
404
|
+
default="(.*)",
|
|
405
|
+
)
|
|
406
|
+
@click.option(
|
|
407
|
+
"--psm_id_pattern",
|
|
408
|
+
help="Regex pattern to extract index or scan number from PSM file. Requires at least one capturing group.",
|
|
409
|
+
default="(.*)",
|
|
410
|
+
)
|
|
411
|
+
@click.pass_context
|
|
412
|
+
def ms2rescore(
|
|
413
|
+
ctx,
|
|
414
|
+
psm_file: str,
|
|
415
|
+
spectrum_path,
|
|
416
|
+
output_path: str,
|
|
417
|
+
log_level,
|
|
418
|
+
processes,
|
|
419
|
+
fasta_file,
|
|
420
|
+
test_fdr,
|
|
421
|
+
feature_generators,
|
|
422
|
+
ms2pip_model_dir,
|
|
423
|
+
ms2pip_model,
|
|
424
|
+
ms2_tolerance,
|
|
425
|
+
calibration_set_size,
|
|
426
|
+
rescoring_engine,
|
|
427
|
+
rng,
|
|
428
|
+
id_decoy_pattern,
|
|
429
|
+
lower_score_is_better,
|
|
430
|
+
config_file: str,
|
|
431
|
+
spectrum_id_pattern: str,
|
|
432
|
+
psm_id_pattern: str
|
|
433
|
+
):
|
|
434
|
+
"""
|
|
435
|
+
Rescore PSMs in an idXML file and keep other information unchanged.
|
|
436
|
+
:param ms2pip_model_dir: Folder for models.
|
|
437
|
+
:param ctx: Click context object
|
|
438
|
+
:param psm_file: PSM file (idXML)
|
|
439
|
+
:param spectrum_path: Spectrum file or dictionary with spectrum files (MGF/mzML)
|
|
440
|
+
:param output_path: Output path for the new featured idXML file
|
|
441
|
+
:param log_level: log_level for the logger
|
|
442
|
+
:param processes: Number of parallel processes available to MS²Rescore
|
|
443
|
+
:param fasta_file: Fasta file for the database search
|
|
444
|
+
:param test_fdr: test FDR for the rescoring engine
|
|
445
|
+
:param feature_generators: feature generators to use
|
|
446
|
+
:param ms2pip_model: ms2pip model to use
|
|
447
|
+
:param ms2_tolerance: ms2 tolerance
|
|
448
|
+
:param calibration_set_size: calibration set size
|
|
449
|
+
:param rescoring_engine: rescoring engine to use (mokapot or percolator)
|
|
450
|
+
:param rng: random number generator seed
|
|
451
|
+
:param id_decoy_pattern: id decoy pattern
|
|
452
|
+
:param lower_score_is_better: lower score is better
|
|
453
|
+
:param config_file: config file
|
|
454
|
+
:param spectrum_id_pattern:egex pattern to extract index or scan number from spectrum file
|
|
455
|
+
:param psm_id_pattern: Regex pattern to extract index or scan number from PSM file
|
|
456
|
+
:return:
|
|
457
|
+
"""
|
|
458
|
+
logging.getLogger().setLevel(log_level.upper())
|
|
459
|
+
|
|
460
|
+
if output_path is None:
|
|
461
|
+
output_path = psm_file.replace(".idXML", "_ms2rescore.idXML")
|
|
462
|
+
|
|
463
|
+
if rescoring_engine == "moakapot":
|
|
464
|
+
logging.warning(
|
|
465
|
+
"Mokapot rescoring engine is not supported in this version. Please use Percolator."
|
|
466
|
+
)
|
|
467
|
+
raise ValueError(
|
|
468
|
+
"Mokapot rescoring engine is not supported in this version. Please use Percolator."
|
|
469
|
+
)
|
|
470
|
+
|
|
471
|
+
config = parse_cli_arguments_to_config(
|
|
472
|
+
config_file=config_file,
|
|
473
|
+
output_path=output_path,
|
|
474
|
+
feature_generators=feature_generators,
|
|
475
|
+
ms2pip_model_dir=ms2pip_model_dir,
|
|
476
|
+
ms2pip_model=ms2pip_model,
|
|
477
|
+
processes=processes,
|
|
478
|
+
ms2_tolerance=ms2_tolerance,
|
|
479
|
+
calibration_set_size=calibration_set_size,
|
|
480
|
+
rescoring_engine=rescoring_engine,
|
|
481
|
+
rng=rng,
|
|
482
|
+
test_fdr=test_fdr,
|
|
483
|
+
spectrum_path=spectrum_path,
|
|
484
|
+
fasta_file=fasta_file,
|
|
485
|
+
id_decoy_pattern=id_decoy_pattern,
|
|
486
|
+
lower_score_is_better=lower_score_is_better,
|
|
487
|
+
log_level=log_level,
|
|
488
|
+
spectrum_id_pattern=spectrum_id_pattern,
|
|
489
|
+
psm_id_pattern=psm_id_pattern
|
|
490
|
+
)
|
|
491
|
+
logging.info("MS²Rescore config:")
|
|
492
|
+
logging.info(config)
|
|
493
|
+
rescore_idxml(psm_file, output_path, config)
|
|
494
|
+
|
|
495
|
+
|
|
496
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
from quantmsrescore import __version__
|
|
5
|
+
from quantmsrescore.ms2rescore import ms2rescore
|
|
6
|
+
|
|
7
|
+
CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@click.version_option(
|
|
11
|
+
version=__version__, package_name="quantmsrescore", message="%(package)s %(version)s"
|
|
12
|
+
)
|
|
13
|
+
@click.group(context_settings=CONTEXT_SETTINGS)
|
|
14
|
+
def cli():
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
cli.add_command(ms2rescore)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def main():
|
|
22
|
+
try:
|
|
23
|
+
cli()
|
|
24
|
+
except SystemExit as e:
|
|
25
|
+
if e.code != 0:
|
|
26
|
+
raise
|
|
27
|
+
|
|
28
|
+
if __name__ == "__main__":
|
|
29
|
+
main()
|