robert05 commited on
Commit
8fb2f0e
·
verified ·
1 Parent(s): e460eb5

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .DS_Store +0 -0
  2. .gitattributes +84 -0
  3. NIST/.DS_Store +0 -0
  4. NIST/BSA/.DS_Store +0 -0
  5. NIST/BSA/2011_04_01_bsa_consensus_final_true_lib.tar.gz +3 -0
  6. NIST/BSA/bsa_consensus_final_true_lib.mgf +0 -0
  7. NIST/BSA/bsa_consensus_final_true_lib.msp +0 -0
  8. NIST/BSA/msp_to_mgf.py +130 -0
  9. NIST/C.elegans/.DS_Store +0 -0
  10. NIST/C.elegans/2011_05_24_c_elegans_consensus_final_true_lib.tar.gz +3 -0
  11. NIST/C.elegans/c_elegans_consensus_final_true_lib.mgf +3 -0
  12. NIST/C.elegans/c_elegans_consensus_final_true_lib.msp +3 -0
  13. NIST/C.elegans/msp_to_mgf.py +130 -0
  14. NIST/Chicken/.DS_Store +0 -0
  15. NIST/Chicken/2011_05_24_chicken_consensus_final_true_lib.tar.gz +3 -0
  16. NIST/Chicken/chicken_consensus_final_true_lib.mgf +0 -0
  17. NIST/Chicken/chicken_consensus_final_true_lib.msp +3 -0
  18. NIST/Chicken/msp_to_mgf.py +130 -0
  19. NIST/Chinese_Hamster/.DS_Store +0 -0
  20. NIST/Chinese_Hamster/2018_02_23_chinese_hamster_hcd_selected.tar.gz +3 -0
  21. NIST/Chinese_Hamster/chinese_hamster_hcd_selected.mgf +3 -0
  22. NIST/Chinese_Hamster/chinese_hamster_hcd_selected.msp +3 -0
  23. NIST/Chinese_Hamster/msp_to_mgf.py +130 -0
  24. NIST/Drosophila/.DS_Store +0 -0
  25. NIST/Drosophila/2012_04_11_drosophila_consensus_final_true_lib.tar.gz +3 -0
  26. NIST/Drosophila/drosophila_consensus_final_true_lib.mgf +3 -0
  27. NIST/Drosophila/drosophila_consensus_final_true_lib.msp +3 -0
  28. NIST/Drosophila/msp_to_mgf.py +130 -0
  29. NIST/E.coli/.DS_Store +0 -0
  30. NIST/E.coli/2013_05_08_e_coli_consensus_final_true_lib.tar.gz +3 -0
  31. NIST/E.coli/e_coli_consensus_final_true_lib.mgf +3 -0
  32. NIST/E.coli/e_coli_consensus_final_true_lib.msp +3 -0
  33. NIST/E.coli/msp_to_mgf.py +130 -0
  34. NIST/Human/.DS_Store +0 -0
  35. NIST/Human/download_list.txt +11 -0
  36. NIST/Human/downloads/.DS_Store +0 -0
  37. NIST/Human/downloads/2014_05_29_human_consensus_final_true_lib.tar.gz +3 -0
  38. NIST/Human/downloads/cptac2_human_hcd_itraq_phospho_selected.msp.tar.gz +3 -0
  39. NIST/Human/downloads/cptac2_human_hcd_itraq_selected_part1.msp.tar.gz +3 -0
  40. NIST/Human/downloads/cptac2_human_hcd_itraq_selected_part2.msp.tar.gz +3 -0
  41. NIST/Human/downloads/cptac3_tmt_selected_passed_best.msp.tar.gz +3 -0
  42. NIST/Human/downloads/human_hair_selected_with_GVPs_passed_msp.tar.gz +3 -0
  43. NIST/Human/downloads/human_hcd_labelfree_phospho_selected_passed.msp.tar.gz +3 -0
  44. NIST/Human/downloads/human_hcd_semitryp.msp.tar.gz +3 -0
  45. NIST/Human/downloads/human_hcd_tryp_best.msp.tar.gz +3 -0
  46. NIST/Human/downloads/human_hcd_tryp_good.msp.tar.gz +3 -0
  47. NIST/Human/downloads/human_synthetic_hcd_selected.msp.tar.gz +3 -0
  48. NIST/Human/extracted/.DS_Store +0 -0
  49. NIST/Human/extracted/cptac2_human_hcd_itraq_phospho_selected.msp +3 -0
  50. NIST/Human/extracted/cptac2_human_hcd_itraq_selected_part1.msp +3 -0
.DS_Store CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
 
.gitattributes CHANGED
@@ -101,3 +101,87 @@ extracted/rat_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
101
  extracted/rat_qtof_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
102
  mgf/rat_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
103
  mgf/rat_qtof_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  extracted/rat_qtof_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
102
  mgf/rat_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
103
  mgf/rat_qtof_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
104
+ NIST/C.elegans/c_elegans_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
105
+ NIST/C.elegans/c_elegans_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
106
+ NIST/Chicken/chicken_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
107
+ NIST/Chinese_Hamster/chinese_hamster_hcd_selected.mgf filter=lfs diff=lfs merge=lfs -text
108
+ NIST/Chinese_Hamster/chinese_hamster_hcd_selected.msp filter=lfs diff=lfs merge=lfs -text
109
+ NIST/Drosophila/drosophila_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
110
+ NIST/Drosophila/drosophila_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
111
+ NIST/E.coli/e_coli_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
112
+ NIST/E.coli/e_coli_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
113
+ NIST/Human/extracted/cptac2_human_hcd_itraq_phospho_selected.msp filter=lfs diff=lfs merge=lfs -text
114
+ NIST/Human/extracted/cptac2_human_hcd_itraq_selected_part1.msp filter=lfs diff=lfs merge=lfs -text
115
+ NIST/Human/extracted/cptac2_human_hcd_itraq_selected_part2.msp filter=lfs diff=lfs merge=lfs -text
116
+ NIST/Human/extracted/cptac3_tmt_selected_passed_best.msp filter=lfs diff=lfs merge=lfs -text
117
+ NIST/Human/extracted/human_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
118
+ NIST/Human/extracted/human_hair_selected_with_GVPs_passed.msp filter=lfs diff=lfs merge=lfs -text
119
+ NIST/Human/extracted/human_hcd_labelfree_phospho_selected_passed.msp filter=lfs diff=lfs merge=lfs -text
120
+ NIST/Human/extracted/human_hcd_semitryp.msp filter=lfs diff=lfs merge=lfs -text
121
+ NIST/Human/extracted/human_hcd_tryp_best.msp filter=lfs diff=lfs merge=lfs -text
122
+ NIST/Human/extracted/human_hcd_tryp_good.msp filter=lfs diff=lfs merge=lfs -text
123
+ NIST/Human/extracted/human_synthetic_hcd_selected.msp filter=lfs diff=lfs merge=lfs -text
124
+ NIST/Human/mgf/cptac2_human_hcd_itraq_phospho_selected.mgf filter=lfs diff=lfs merge=lfs -text
125
+ NIST/Human/mgf/cptac2_human_hcd_itraq_selected_part1.mgf filter=lfs diff=lfs merge=lfs -text
126
+ NIST/Human/mgf/cptac2_human_hcd_itraq_selected_part2.mgf filter=lfs diff=lfs merge=lfs -text
127
+ NIST/Human/mgf/cptac3_tmt_selected_passed_best.mgf filter=lfs diff=lfs merge=lfs -text
128
+ NIST/Human/mgf/human_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
129
+ NIST/Human/mgf/human_hair_selected_with_GVPs_passed.mgf filter=lfs diff=lfs merge=lfs -text
130
+ NIST/Human/mgf/human_hcd_labelfree_phospho_selected_passed.mgf filter=lfs diff=lfs merge=lfs -text
131
+ NIST/Human/mgf/human_hcd_semitryp.mgf filter=lfs diff=lfs merge=lfs -text
132
+ NIST/Human/mgf/human_hcd_tryp_best.mgf filter=lfs diff=lfs merge=lfs -text
133
+ NIST/Human/mgf/human_hcd_tryp_good.mgf filter=lfs diff=lfs merge=lfs -text
134
+ NIST/Human/mgf/human_synthetic_hcd_selected.mgf filter=lfs diff=lfs merge=lfs -text
135
+ NIST/Mouse/extracted/cptac2_mouse_hcd_itraq_phospho_selected.msp filter=lfs diff=lfs merge=lfs -text
136
+ NIST/Mouse/extracted/cptac2_mouse_hcd_itraq_selected.msp filter=lfs diff=lfs merge=lfs -text
137
+ NIST/Mouse/extracted/cptac2_mouse_hcd_selected.msp filter=lfs diff=lfs merge=lfs -text
138
+ NIST/Mouse/extracted/mouse_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
139
+ NIST/Mouse/mgf/cptac2_mouse_hcd_itraq_phospho_selected.mgf filter=lfs diff=lfs merge=lfs -text
140
+ NIST/Mouse/mgf/cptac2_mouse_hcd_itraq_selected.mgf filter=lfs diff=lfs merge=lfs -text
141
+ NIST/Mouse/mgf/cptac2_mouse_hcd_selected.mgf filter=lfs diff=lfs merge=lfs -text
142
+ NIST/Mouse/mgf/mouse_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
143
+ NIST/Rat/extracted/rat_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
144
+ NIST/Rat/extracted/rat_qtof_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
145
+ NIST/Rat/mgf/rat_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
146
+ NIST/Rat/mgf/rat_qtof_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
147
+ NIST/Sigmaups1/sigmaups1_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
148
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/ALNUMNAM.INU filter=lfs diff=lfs merge=lfs -text
149
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/ALPHANAM.INU filter=lfs diff=lfs merge=lfs -text
150
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/LOSS_AM0.DBU filter=lfs diff=lfs merge=lfs -text
151
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/LOSS_AM0.INU filter=lfs diff=lfs merge=lfs -text
152
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/LOSS_EM0.DBU filter=lfs diff=lfs merge=lfs -text
153
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/LOSS_EM0.INU filter=lfs diff=lfs merge=lfs -text
154
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/MAXMASS.DBU filter=lfs diff=lfs merge=lfs -text
155
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/MAXMASS.INU filter=lfs diff=lfs merge=lfs -text
156
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/MW.INU filter=lfs diff=lfs merge=lfs -text
157
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/NAME.INU filter=lfs diff=lfs merge=lfs -text
158
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/NAMESORT.DBU filter=lfs diff=lfs merge=lfs -text
159
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK.DBU filter=lfs diff=lfs merge=lfs -text
160
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK.INU filter=lfs diff=lfs merge=lfs -text
161
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_AM0.DBU filter=lfs diff=lfs merge=lfs -text
162
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_AM0.INU filter=lfs diff=lfs merge=lfs -text
163
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_AM2.DBU filter=lfs diff=lfs merge=lfs -text
164
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_AM2.INU filter=lfs diff=lfs merge=lfs -text
165
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_EM0.DBU filter=lfs diff=lfs merge=lfs -text
166
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_EM1.DBU filter=lfs diff=lfs merge=lfs -text
167
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_EM1.INU filter=lfs diff=lfs merge=lfs -text
168
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_EM2.DBU filter=lfs diff=lfs merge=lfs -text
169
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_PM0.DBU filter=lfs diff=lfs merge=lfs -text
170
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/PEAK_PM0.INU filter=lfs diff=lfs merge=lfs -text
171
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/USER.DBU filter=lfs diff=lfs merge=lfs -text
172
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/USER.INU filter=lfs diff=lfs merge=lfs -text
173
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/cpdhash.inu filter=lfs diff=lfs merge=lfs -text
174
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/exactmw.inu filter=lfs diff=lfs merge=lfs -text
175
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/inchikey.inu filter=lfs diff=lfs merge=lfs -text
176
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/mzbin.dbu filter=lfs diff=lfs merge=lfs -text
177
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/mzbin.inu filter=lfs diff=lfs merge=lfs -text
178
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/mztxt.dbu filter=lfs diff=lfs merge=lfs -text
179
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/mztxt.inu filter=lfs diff=lfs merge=lfs -text
180
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/precmz.inu filter=lfs diff=lfs merge=lfs -text
181
+ NIST/Yeast/extracted/yeast_2012_04_17_qtof/precmzb.inu filter=lfs diff=lfs merge=lfs -text
182
+ NIST/Yeast/extracted/yeast_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
183
+ NIST/Yeast/extracted/yeast_pombe_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
184
+ NIST/Yeast/mgf/yeast_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
185
+ NIST/Yeast/mgf/yeast_pombe_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
186
+ NIST/Zebrafish/2015_01_09_zebrafish_it_consensus_final_true_lib.mgf filter=lfs diff=lfs merge=lfs -text
187
+ NIST/Zebrafish/2015_01_09_zebrafish_it_consensus_final_true_lib.msp filter=lfs diff=lfs merge=lfs -text
NIST/.DS_Store ADDED
Binary file (14.3 kB). View file
 
NIST/BSA/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/BSA/2011_04_01_bsa_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2156f4d7848a698337f933d8600b47a88e1bae6e567c208aa2b62ddc50fbe6d0
3
+ size 949605
NIST/BSA/bsa_consensus_final_true_lib.mgf ADDED
The diff for this file is too large to render. See raw diff
 
NIST/BSA/bsa_consensus_final_true_lib.msp ADDED
The diff for this file is too large to render. See raw diff
 
NIST/BSA/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/BSA/bsa_consensus_final_true_lib.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/BSA/bsa_consensus_final_true_lib.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/C.elegans/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/C.elegans/2011_05_24_c_elegans_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8546aeb1bc5fa89bb42bee177e50b3b12c4b80fb718358fd9f03e283276d48d4
3
+ size 103804121
NIST/C.elegans/c_elegans_consensus_final_true_lib.mgf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8eeb81423b4cbc24065750f364a626ce0869868d60fae1d0566f800910c18893
3
+ size 115994585
NIST/C.elegans/c_elegans_consensus_final_true_lib.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c96c8c89b3d618ebc056315dc0d35f81a339982148655ec8e54d2be5ea16c310
3
+ size 315893881
NIST/C.elegans/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/C. elegans/c_elegans_consensus_final_true_lib.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/C. elegans/c_elegans_consensus_final_true_lib.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/Chicken/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/Chicken/2011_05_24_chicken_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7643ef0ed363c7d8bd6e0fd575c6ad55e12ea0e56f50cf7566ab13d338967d3b
3
+ size 4283755
NIST/Chicken/chicken_consensus_final_true_lib.mgf ADDED
The diff for this file is too large to render. See raw diff
 
NIST/Chicken/chicken_consensus_final_true_lib.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2158b057951cbf9303b3a73c2ac24f537680a6645a6b00100695c7ed06ea5711
3
+ size 13292012
NIST/Chicken/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/Chicken/chicken_consensus_final_true_lib.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/Chicken/chicken_consensus_final_true_lib.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/Chinese_Hamster/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/Chinese_Hamster/2018_02_23_chinese_hamster_hcd_selected.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3b641fc6150afb0c2f0648ccb747c51ce18ca8997bf5805bab38fe7c9f20f1d
3
+ size 234256395
NIST/Chinese_Hamster/chinese_hamster_hcd_selected.mgf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7db8a480e8ff0a5e602970a5a28e408dc690bc082160091731e8b8ba46e800a9
3
+ size 342825915
NIST/Chinese_Hamster/chinese_hamster_hcd_selected.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f25a4b9c6d6cbebc09e714ae18b4aaa2fafcbdafb092d66a3ef7e037f3c0c36
3
+ size 667312654
NIST/Chinese_Hamster/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/Chinese Hamster/chinese_hamster_hcd_selected.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/Chinese Hamster/chinese_hamster_hcd_selected.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/Drosophila/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/Drosophila/2012_04_11_drosophila_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19f2cd0f1421ca1330d4fc5a058b0b41e0a8531635b9d32989ec889bec3517f1
3
+ size 116991450
NIST/Drosophila/drosophila_consensus_final_true_lib.mgf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b38c7b5661a208a9a2fffa9873e3b07ed31fd2c1ea146d7c21d37ca0e5a84a40
3
+ size 125583207
NIST/Drosophila/drosophila_consensus_final_true_lib.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ed0babfbd7977935a5c5cdeec1591f25053f33985baf2e12ac9647987123318
3
+ size 358531744
NIST/Drosophila/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/Drosophila/drosophila_consensus_final_true_lib.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/Drosophila/drosophila_consensus_final_true_lib.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/E.coli/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/E.coli/2013_05_08_e_coli_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de62c0203b72bf37126d2952bc80dd1fd408c6a4f0311973c1da022a7386a256
3
+ size 87413877
NIST/E.coli/e_coli_consensus_final_true_lib.mgf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc4c05e0972a2973dc1690ebcd9469be1a354ac095e6f15da02e9e3434f705a6
3
+ size 91406955
NIST/E.coli/e_coli_consensus_final_true_lib.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13275e11e16916eee2b62248ad7c0232ddb5de421dcceb19bc02c2c772e0468b
3
+ size 266444472
NIST/E.coli/msp_to_mgf.py ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import re
4
+
5
+ # =========================================================
6
+ # 1) 读取路径与保存路径(请你按自己的电脑路径修改)
7
+ # =========================================================
8
+ # 示例(macOS):
9
+ MSP_PATH = "/Users/guanmumu/Desktop/Data/E. coli/e_coli_consensus_final_true_lib.msp"
10
+ MGF_PATH = "/Users/guanmumu/Desktop/Data/E. coli/e_coli_consensus_final_true_lib.mgf"
11
+
12
+ # 如果你想让脚本“放哪儿都能跑”,可以用脚本所在目录:
13
+ # BASE_DIR = os.path.dirname(os.path.abspath(__file__))
14
+ # MSP_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.msp")
15
+ # MGF_PATH = os.path.join(BASE_DIR, "bsa_consensus_final_true_lib.pepmass_is_mw.mgf")
16
+
17
+ # =========================================================
18
+ # 2) MSP 字段解析函数
19
+ # =========================================================
20
+ def parse_sequence_from_name(name_val: str) -> str:
21
+ # Name: SEQUENCE/charge_...
22
+ return name_val.split("/")[0].strip()
23
+
24
+ def parse_charge_from_name(name_val: str):
25
+ m = re.search(r"/(\d+)", name_val)
26
+ return int(m.group(1)) if m else None
27
+
28
+ def parse_mz_exact_from_comment(line: str):
29
+ # Comment: ... Mz_exact=536.5844 ...
30
+ m = re.search(r"\bMz_exact=([0-9]*\.?[0-9]+)", line)
31
+ return float(m.group(1)) if m else None
32
+
33
+ # =========================================================
34
+ # 3) 主逻辑:流式读取 MSP,写 MGF
35
+ # =========================================================
36
+ def main():
37
+ spectra_count = 0
38
+ unique_peptides = set()
39
+
40
+ with open(MSP_PATH, "r", encoding="utf-8", errors="replace") as fin, \
41
+ open(MGF_PATH, "w", encoding="utf-8") as fout:
42
+
43
+ name_val = None
44
+ seq = None
45
+ charge = None
46
+ mw = None # 你要求用作 PEPMASS
47
+ precursor_mz = None # 仅用于辅助记录(Mz_exact)
48
+
49
+ for line in fin:
50
+ line = line.rstrip("\n")
51
+
52
+ if line.startswith("Name:"):
53
+ name_val = line.split("Name:", 1)[1].strip()
54
+ seq = parse_sequence_from_name(name_val)
55
+ charge = parse_charge_from_name(name_val)
56
+ unique_peptides.add(seq)
57
+
58
+ elif line.startswith("MW:"):
59
+ try:
60
+ mw = float(line.split("MW:", 1)[1].strip())
61
+ except Exception:
62
+ mw = None
63
+
64
+ elif line.startswith("Comment:"):
65
+ precursor_mz = parse_mz_exact_from_comment(line)
66
+
67
+ elif line.startswith("Num peaks:"):
68
+ # 进入峰列表块
69
+ num_peaks = int(line.split("Num peaks:", 1)[1].strip())
70
+
71
+ spectra_count += 1
72
+
73
+ # ===================== 写一个 MGF block =====================
74
+ fout.write("BEGIN IONS\n")
75
+
76
+ # TITLE:建议写得可追溯
77
+ if seq is not None and charge is not None:
78
+ fout.write(f"TITLE={seq}/z{charge}\n")
79
+ elif seq is not None:
80
+ fout.write(f"TITLE={seq}\n")
81
+ else:
82
+ fout.write(f"TITLE=Spectrum_{spectra_count}\n")
83
+
84
+ # 你要求:PEPMASS = MW(不做换算)
85
+ # 注意:如果 mw 缺失,会跳过 PEPMASS 行
86
+ if mw is not None:
87
+ fout.write(f"PEPMASS={mw:.6f}\n")
88
+
89
+ # 电荷
90
+ if charge is not None:
91
+ fout.write(f"CHARGE={charge}+\n")
92
+
93
+ # 你要的 sequence 列:这里写在 MGF 自定义字段中
94
+ if seq is not None:
95
+ fout.write(f"SEQ={seq}\n")
96
+
97
+ # 辅助字段:把 Comment 里 Mz_exact 也记录下来(不影响你要求)
98
+ if precursor_mz is not None:
99
+ fout.write(f"PRECURSOR_MZ={precursor_mz:.6f}\n")
100
+
101
+ # 写峰:每行 "m/z intensity"
102
+ for _ in range(num_peaks):
103
+ peak_line = next(fin).strip()
104
+ if not peak_line:
105
+ continue
106
+ parts = peak_line.split()
107
+ if len(parts) >= 2:
108
+ mz = parts[0]
109
+ inten = parts[1]
110
+ fout.write(f"{mz} {inten}\n")
111
+
112
+ fout.write("END IONS\n\n")
113
+
114
+ # reset 当前谱状态
115
+ name_val = None
116
+ seq = None
117
+ charge = None
118
+ mw = None
119
+ precursor_mz = None
120
+
121
+ # =========================================================
122
+ # 4) 最终统计输出
123
+ # =========================================================
124
+ print(f"[DONE] MSP input : {MSP_PATH}")
125
+ print(f"[DONE] MGF output: {MGF_PATH}")
126
+ print(f"Spectra count : {spectra_count}")
127
+ print(f"Unique peptides : {len(unique_peptides)}")
128
+
129
+ if __name__ == "__main__":
130
+ main()
NIST/Human/.DS_Store ADDED
Binary file (14.3 kB). View file
 
NIST/Human/download_list.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/ION_TRAP/2014_05_29/2014_05_29_human_consensus_final_true_lib.tar.gz
2
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2020_05_19/human_hcd_tryp_best.msp.tar.gz
3
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2020_05_19/human_hcd_tryp_good.msp.tar.gz
4
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2020_05_19/human_hcd_semitryp.msp.tar.gz
5
+ https://chemdata.nist.gov/download/peptide_library/libraries/cptaclib/2015/cptac2_human_hcd_itraq_selected_part1.msp.tar.gz
6
+ https://chemdata.nist.gov/download/peptide_library/libraries/cptaclib/2015/cptac2_human_hcd_itraq_selected_part2.msp.tar.gz
7
+ https://chemdata.nist.gov/download/peptide_library/libraries/cptaclib/2015/cptac2_human_hcd_itraq_phospho_selected.msp.tar.gz
8
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2017_05_30/human_synthetic_hcd_selected.msp.tar.gz
9
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2019_02_14/human_hcd_labelfree_phospho_selected_passed.msp.tar.gz
10
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/hair/human_hair_selected_with_GVPs_passed_msp.tar.gz
11
+ https://chemdata.nist.gov/download/peptide_library/libraries/human/HCD/2022_03_16/cptac3_tmt_selected_passed_best.msp.tar.gz
NIST/Human/downloads/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/Human/downloads/2014_05_29_human_consensus_final_true_lib.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2c16ffdfb154e4b09db554bb2e6aabab48ecb196b0fab39b61977c5076b366f
3
+ size 573909561
NIST/Human/downloads/cptac2_human_hcd_itraq_phospho_selected.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:233f92a089d0eb83e48150d9b3c32c4145939fd886d364ffb2067922b45d8f8f
3
+ size 1162476607
NIST/Human/downloads/cptac2_human_hcd_itraq_selected_part1.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bf4dec73d2b3f1eac4f1902b00b6edadefac0244de99adf660a2b4fc145b1f3
3
+ size 1961961686
NIST/Human/downloads/cptac2_human_hcd_itraq_selected_part2.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14e0196680db5e2f2513094c4da86ac067928f5b8747aea20dc39d086e098438
3
+ size 2090393526
NIST/Human/downloads/cptac3_tmt_selected_passed_best.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:063ac05e057ef5b5745049d7ccba97d69b9d4de6806e96890e98f277b9d02bd3
3
+ size 2717409713
NIST/Human/downloads/human_hair_selected_with_GVPs_passed_msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5de06f70d0462b6b92510e30ba10028a8ebf0c7f613f21f77035cb5b7144b007
3
+ size 19504122
NIST/Human/downloads/human_hcd_labelfree_phospho_selected_passed.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1faa9bf7c77006c167a7a89d4d7435bea91adebe1528ffc0ab31ebd1bb61de5
3
+ size 244368083
NIST/Human/downloads/human_hcd_semitryp.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43670383bfbb3669fb900aefce08838cecd7766783df440cfc4fd0d28cb89a0b
3
+ size 627308208
NIST/Human/downloads/human_hcd_tryp_best.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1866af6296e9b696aed71d0dbf22b82dc15d02510459c236b2a37798a0c00ebf
3
+ size 677259962
NIST/Human/downloads/human_hcd_tryp_good.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b7ca7ccf69df16900df51f3b620f5cdb1bc155459d32dc82806c84ee6d6f3e5
3
+ size 414274314
NIST/Human/downloads/human_synthetic_hcd_selected.msp.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:049385c4b539a268389f10a5565ea6627b88bde8476075b93b6498084e64da0c
3
+ size 2282954701
NIST/Human/extracted/.DS_Store ADDED
Binary file (6.15 kB). View file
 
NIST/Human/extracted/cptac2_human_hcd_itraq_phospho_selected.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0a215409e67a71472d1a66723b13df4eee72fe4fc08b371a5002eb0caed0a95
3
+ size 3436589381
NIST/Human/extracted/cptac2_human_hcd_itraq_selected_part1.msp ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d53905c7e1f6feb87a3a813b370db9cebb29d18304fa2e9f4ed9888892b5c537
3
+ size 5696742728