Skip to content

Commit 4997b2a

Browse files
Deploy PR #91 preview [skip ci]
1 parent e74aa70 commit 4997b2a

425 files changed

Lines changed: 120344 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pr-91/API.html

Lines changed: 974 additions & 0 deletions
Large diffs are not rendered by default.

pr-91/Data Formatting/Data Formatting.html

Lines changed: 644 additions & 0 deletions
Large diffs are not rendered by default.

pr-91/Data Formatting/alphatims.html

Lines changed: 1023 additions & 0 deletions
Large diffs are not rendered by default.

pr-91/Data Formatting/alphatims.ipynb

Lines changed: 785 additions & 0 deletions
Large diffs are not rendered by default.

pr-91/Data Formatting/pymzml.html

Lines changed: 801 additions & 0 deletions
Large diffs are not rendered by default.

pr-91/Data Formatting/pymzml.ipynb

Lines changed: 290 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,290 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "f8776c6e-5d39-4f3e-9d9a-152dd0359c93",
6+
"metadata": {},
7+
"source": [
8+
"# pymzml"
9+
]
10+
},
11+
{
12+
"cell_type": "raw",
13+
"id": "5ea454b7-3fb4-4d87-86ac-62dcbb2671b1",
14+
"metadata": {
15+
"editable": true,
16+
"raw_mimetype": "text/html",
17+
"slideshow": {
18+
"slide_type": ""
19+
},
20+
"tags": []
21+
},
22+
"source": [
23+
"<a href=\"https://notebooks.gesis.org/binder/v2/gh/OpenMS/pyopenms_viz/main?filepath=docs/Data Formatting/pymzml.ipynb\" target=\"_blank\">\n",
24+
" <img src=\"https://mybinder.org/badge_logo.svg\" alt=\"Launch on Binder\" style=\"width: 150px;\"/>\n",
25+
"</a>\n",
26+
"<br></br>"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"id": "efb4dce4-75eb-464d-b839-bd3e93819142",
32+
"metadata": {},
33+
"source": [
34+
"## Install pymzml"
35+
]
36+
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": 1,
40+
"id": "6944da94-fa96-4f8e-bb68-798ca545e810",
41+
"metadata": {
42+
"execution": {
43+
"iopub.execute_input": "2025-08-01T15:34:55.603971Z",
44+
"iopub.status.busy": "2025-08-01T15:34:55.603761Z",
45+
"iopub.status.idle": "2025-08-01T15:34:56.351813Z",
46+
"shell.execute_reply": "2025-08-01T15:34:56.351075Z"
47+
}
48+
},
49+
"outputs": [
50+
{
51+
"name": "stdout",
52+
"output_type": "stream",
53+
"text": [
54+
"\r\n",
55+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.2\u001b[0m\r\n",
56+
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\r\n"
57+
]
58+
}
59+
],
60+
"source": [
61+
"!pip install pymzml --quiet"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 2,
67+
"id": "44c8ed73-b62f-4c05-ab3a-f00fd8ba84c1",
68+
"metadata": {
69+
"execution": {
70+
"iopub.execute_input": "2025-08-01T15:34:56.354328Z",
71+
"iopub.status.busy": "2025-08-01T15:34:56.354123Z",
72+
"iopub.status.idle": "2025-08-01T15:34:56.674318Z",
73+
"shell.execute_reply": "2025-08-01T15:34:56.673664Z"
74+
}
75+
},
76+
"outputs": [],
77+
"source": [
78+
"import pandas as pd\n",
79+
"import pymzml"
80+
]
81+
},
82+
{
83+
"cell_type": "markdown",
84+
"id": "29a93547-1b8c-4b93-91c0-17c7caf932fd",
85+
"metadata": {},
86+
"source": [
87+
"## Download the test file"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": 3,
93+
"id": "02396b2f-50c4-4e7c-b938-74a8f4c28dd8",
94+
"metadata": {
95+
"execution": {
96+
"iopub.execute_input": "2025-08-01T15:34:56.676582Z",
97+
"iopub.status.busy": "2025-08-01T15:34:56.676309Z",
98+
"iopub.status.idle": "2025-08-01T15:34:56.761494Z",
99+
"shell.execute_reply": "2025-08-01T15:34:56.760819Z"
100+
}
101+
},
102+
"outputs": [
103+
{
104+
"name": "stdout",
105+
"output_type": "stream",
106+
"text": [
107+
"File test.mzML downloaded successfully!\n"
108+
]
109+
}
110+
],
111+
"source": [
112+
"# # Download test file\n",
113+
"import requests\n",
114+
"\n",
115+
"url = 'https://raw.githubusercontent.com/levitsky/pyteomics/master/tests/test.mzML'\n",
116+
"file_name = 'test.mzML'\n",
117+
"\n",
118+
"# Send a GET request to the URL\n",
119+
"response = requests.get(url)\n",
120+
"\n",
121+
"# Save the content of the response to a file\n",
122+
"with open(file_name, 'wb') as file:\n",
123+
" file.write(response.content)\n",
124+
"\n",
125+
"print(f'File {file_name} downloaded successfully!')\n"
126+
]
127+
},
128+
{
129+
"cell_type": "markdown",
130+
"id": "9c601f0e-9118-44e5-a8d0-96b62ef1e65e",
131+
"metadata": {},
132+
"source": [
133+
"## Load `.mzML` file and convert to `pd.DataFrame`"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": 4,
139+
"id": "3cfbb66c-2dcc-4293-a0f3-4e747ec5c880",
140+
"metadata": {
141+
"execution": {
142+
"iopub.execute_input": "2025-08-01T15:34:56.763410Z",
143+
"iopub.status.busy": "2025-08-01T15:34:56.763218Z",
144+
"iopub.status.idle": "2025-08-01T15:34:56.811955Z",
145+
"shell.execute_reply": "2025-08-01T15:34:56.811334Z"
146+
}
147+
},
148+
"outputs": [
149+
{
150+
"data": {
151+
"text/html": [
152+
"<div>\n",
153+
"<style scoped>\n",
154+
" .dataframe tbody tr th:only-of-type {\n",
155+
" vertical-align: middle;\n",
156+
" }\n",
157+
"\n",
158+
" .dataframe tbody tr th {\n",
159+
" vertical-align: top;\n",
160+
" }\n",
161+
"\n",
162+
" .dataframe thead th {\n",
163+
" text-align: right;\n",
164+
" }\n",
165+
"</style>\n",
166+
"<table border=\"1\" class=\"dataframe\">\n",
167+
" <thead>\n",
168+
" <tr style=\"text-align: right;\">\n",
169+
" <th></th>\n",
170+
" <th>mz</th>\n",
171+
" <th>int</th>\n",
172+
" </tr>\n",
173+
" </thead>\n",
174+
" <tbody>\n",
175+
" <tr>\n",
176+
" <th>0</th>\n",
177+
" <td>204.760065</td>\n",
178+
" <td>3901.930681</td>\n",
179+
" </tr>\n",
180+
" <tr>\n",
181+
" <th>1</th>\n",
182+
" <td>204.778823</td>\n",
183+
" <td>3431.441349</td>\n",
184+
" </tr>\n",
185+
" <tr>\n",
186+
" <th>2</th>\n",
187+
" <td>204.790975</td>\n",
188+
" <td>3703.068912</td>\n",
189+
" </tr>\n",
190+
" <tr>\n",
191+
" <th>3</th>\n",
192+
" <td>204.795946</td>\n",
193+
" <td>4317.227255</td>\n",
194+
" </tr>\n",
195+
" <tr>\n",
196+
" <th>4</th>\n",
197+
" <td>204.797708</td>\n",
198+
" <td>4267.166873</td>\n",
199+
" </tr>\n",
200+
" <tr>\n",
201+
" <th>...</th>\n",
202+
" <td>...</td>\n",
203+
" <td>...</td>\n",
204+
" </tr>\n",
205+
" <tr>\n",
206+
" <th>1735</th>\n",
207+
" <td>1998.647154</td>\n",
208+
" <td>2567.956920</td>\n",
209+
" </tr>\n",
210+
" <tr>\n",
211+
" <th>1736</th>\n",
212+
" <td>1998.908241</td>\n",
213+
" <td>5539.517009</td>\n",
214+
" </tr>\n",
215+
" <tr>\n",
216+
" <th>1737</th>\n",
217+
" <td>1999.254369</td>\n",
218+
" <td>14109.211636</td>\n",
219+
" </tr>\n",
220+
" <tr>\n",
221+
" <th>1738</th>\n",
222+
" <td>1999.510959</td>\n",
223+
" <td>8432.185933</td>\n",
224+
" </tr>\n",
225+
" <tr>\n",
226+
" <th>1739</th>\n",
227+
" <td>1999.782814</td>\n",
228+
" <td>1875.846606</td>\n",
229+
" </tr>\n",
230+
" </tbody>\n",
231+
"</table>\n",
232+
"<p>1740 rows × 2 columns</p>\n",
233+
"</div>"
234+
],
235+
"text/plain": [
236+
" mz int\n",
237+
"0 204.760065 3901.930681\n",
238+
"1 204.778823 3431.441349\n",
239+
"2 204.790975 3703.068912\n",
240+
"3 204.795946 4317.227255\n",
241+
"4 204.797708 4267.166873\n",
242+
"... ... ...\n",
243+
"1735 1998.647154 2567.956920\n",
244+
"1736 1998.908241 5539.517009\n",
245+
"1737 1999.254369 14109.211636\n",
246+
"1738 1999.510959 8432.185933\n",
247+
"1739 1999.782814 1875.846606\n",
248+
"\n",
249+
"[1740 rows x 2 columns]"
250+
]
251+
},
252+
"execution_count": 4,
253+
"metadata": {},
254+
"output_type": "execute_result"
255+
}
256+
],
257+
"source": [
258+
"input_file = \"./test.mzML\"\n",
259+
"\n",
260+
"run = pymzml.run.Reader(input_file)\n",
261+
"# Get the first spec\n",
262+
"spec = run.next()\n",
263+
"# Convert to Pandas DataFrame\n",
264+
"df = pd.DataFrame(spec.centroidedPeaks).rename(columns={0:'mz', 1:'int'})\n",
265+
"df"
266+
]
267+
}
268+
],
269+
"metadata": {
270+
"kernelspec": {
271+
"display_name": "Python 3 (ipykernel)",
272+
"language": "python",
273+
"name": "python3"
274+
},
275+
"language_info": {
276+
"codemirror_mode": {
277+
"name": "ipython",
278+
"version": 3
279+
},
280+
"file_extension": ".py",
281+
"mimetype": "text/x-python",
282+
"name": "python",
283+
"nbconvert_exporter": "python",
284+
"pygments_lexer": "ipython3",
285+
"version": "3.12.11"
286+
}
287+
},
288+
"nbformat": 4,
289+
"nbformat_minor": 5
290+
}

0 commit comments

Comments
 (0)