Skip to content

Commit 2b85f1b

Browse files
Deploy PR #95 preview [skip ci]
1 parent e2fcba7 commit 2b85f1b

424 files changed

Lines changed: 114796 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-95/API.html

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

pr-95/Data Formatting/Data Formatting.html

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

pr-95/Data Formatting/alphatims.html

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

pr-95/Data Formatting/alphatims.ipynb

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

pr-95/Data Formatting/pymzml.html

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

pr-95/Data Formatting/pymzml.ipynb

Lines changed: 252 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,252 @@
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+
"outputs": [],
43+
"source": [
44+
"!pip install pymzml --quiet"
45+
]
46+
},
47+
{
48+
"cell_type": "code",
49+
"execution_count": 2,
50+
"id": "44c8ed73-b62f-4c05-ab3a-f00fd8ba84c1",
51+
"metadata": {},
52+
"outputs": [],
53+
"source": [
54+
"import pandas as pd\n",
55+
"import pymzml"
56+
]
57+
},
58+
{
59+
"cell_type": "markdown",
60+
"id": "29a93547-1b8c-4b93-91c0-17c7caf932fd",
61+
"metadata": {},
62+
"source": [
63+
"## Download the test file"
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": 4,
69+
"id": "02396b2f-50c4-4e7c-b938-74a8f4c28dd8",
70+
"metadata": {},
71+
"outputs": [
72+
{
73+
"name": "stdout",
74+
"output_type": "stream",
75+
"text": [
76+
"File test.mzML downloaded successfully!\n"
77+
]
78+
}
79+
],
80+
"source": [
81+
"# # Download test file\n",
82+
"import requests\n",
83+
"\n",
84+
"url = 'https://raw.githubusercontent.com/levitsky/pyteomics/master/tests/test.mzML'\n",
85+
"file_name = 'test.mzML'\n",
86+
"\n",
87+
"# Send a GET request to the URL\n",
88+
"response = requests.get(url)\n",
89+
"\n",
90+
"# Save the content of the response to a file\n",
91+
"with open(file_name, 'wb') as file:\n",
92+
" file.write(response.content)\n",
93+
"\n",
94+
"print(f'File {file_name} downloaded successfully!')\n"
95+
]
96+
},
97+
{
98+
"cell_type": "markdown",
99+
"id": "9c601f0e-9118-44e5-a8d0-96b62ef1e65e",
100+
"metadata": {},
101+
"source": [
102+
"## Load `.mzML` file and convert to `pd.DataFrame`"
103+
]
104+
},
105+
{
106+
"cell_type": "code",
107+
"execution_count": 5,
108+
"id": "3cfbb66c-2dcc-4293-a0f3-4e747ec5c880",
109+
"metadata": {},
110+
"outputs": [
111+
{
112+
"data": {
113+
"text/html": [
114+
"<div>\n",
115+
"<style scoped>\n",
116+
" .dataframe tbody tr th:only-of-type {\n",
117+
" vertical-align: middle;\n",
118+
" }\n",
119+
"\n",
120+
" .dataframe tbody tr th {\n",
121+
" vertical-align: top;\n",
122+
" }\n",
123+
"\n",
124+
" .dataframe thead th {\n",
125+
" text-align: right;\n",
126+
" }\n",
127+
"</style>\n",
128+
"<table border=\"1\" class=\"dataframe\">\n",
129+
" <thead>\n",
130+
" <tr style=\"text-align: right;\">\n",
131+
" <th></th>\n",
132+
" <th>mz</th>\n",
133+
" <th>int</th>\n",
134+
" </tr>\n",
135+
" </thead>\n",
136+
" <tbody>\n",
137+
" <tr>\n",
138+
" <th>0</th>\n",
139+
" <td>204.760065</td>\n",
140+
" <td>3901.930681</td>\n",
141+
" </tr>\n",
142+
" <tr>\n",
143+
" <th>1</th>\n",
144+
" <td>204.778823</td>\n",
145+
" <td>3431.441349</td>\n",
146+
" </tr>\n",
147+
" <tr>\n",
148+
" <th>2</th>\n",
149+
" <td>204.790975</td>\n",
150+
" <td>3703.068912</td>\n",
151+
" </tr>\n",
152+
" <tr>\n",
153+
" <th>3</th>\n",
154+
" <td>204.795946</td>\n",
155+
" <td>4317.227255</td>\n",
156+
" </tr>\n",
157+
" <tr>\n",
158+
" <th>4</th>\n",
159+
" <td>204.797708</td>\n",
160+
" <td>4267.166873</td>\n",
161+
" </tr>\n",
162+
" <tr>\n",
163+
" <th>...</th>\n",
164+
" <td>...</td>\n",
165+
" <td>...</td>\n",
166+
" </tr>\n",
167+
" <tr>\n",
168+
" <th>1735</th>\n",
169+
" <td>1998.647154</td>\n",
170+
" <td>2567.956920</td>\n",
171+
" </tr>\n",
172+
" <tr>\n",
173+
" <th>1736</th>\n",
174+
" <td>1998.908241</td>\n",
175+
" <td>5539.517009</td>\n",
176+
" </tr>\n",
177+
" <tr>\n",
178+
" <th>1737</th>\n",
179+
" <td>1999.254369</td>\n",
180+
" <td>14109.211636</td>\n",
181+
" </tr>\n",
182+
" <tr>\n",
183+
" <th>1738</th>\n",
184+
" <td>1999.510959</td>\n",
185+
" <td>8432.185933</td>\n",
186+
" </tr>\n",
187+
" <tr>\n",
188+
" <th>1739</th>\n",
189+
" <td>1999.782814</td>\n",
190+
" <td>1875.846606</td>\n",
191+
" </tr>\n",
192+
" </tbody>\n",
193+
"</table>\n",
194+
"<p>1740 rows × 2 columns</p>\n",
195+
"</div>"
196+
],
197+
"text/plain": [
198+
" mz int\n",
199+
"0 204.760065 3901.930681\n",
200+
"1 204.778823 3431.441349\n",
201+
"2 204.790975 3703.068912\n",
202+
"3 204.795946 4317.227255\n",
203+
"4 204.797708 4267.166873\n",
204+
"... ... ...\n",
205+
"1735 1998.647154 2567.956920\n",
206+
"1736 1998.908241 5539.517009\n",
207+
"1737 1999.254369 14109.211636\n",
208+
"1738 1999.510959 8432.185933\n",
209+
"1739 1999.782814 1875.846606\n",
210+
"\n",
211+
"[1740 rows x 2 columns]"
212+
]
213+
},
214+
"execution_count": 5,
215+
"metadata": {},
216+
"output_type": "execute_result"
217+
}
218+
],
219+
"source": [
220+
"input_file = \"./test.mzML\"\n",
221+
"\n",
222+
"run = pymzml.run.Reader(input_file)\n",
223+
"# Get the first spec\n",
224+
"spec = run.next()\n",
225+
"# Convert to Pandas DataFrame\n",
226+
"df = pd.DataFrame(spec.centroidedPeaks).rename(columns={0:'mz', 1:'int'})\n",
227+
"df"
228+
]
229+
}
230+
],
231+
"metadata": {
232+
"kernelspec": {
233+
"display_name": "Python 3 (ipykernel)",
234+
"language": "python",
235+
"name": "python3"
236+
},
237+
"language_info": {
238+
"codemirror_mode": {
239+
"name": "ipython",
240+
"version": 3
241+
},
242+
"file_extension": ".py",
243+
"mimetype": "text/x-python",
244+
"name": "python",
245+
"nbconvert_exporter": "python",
246+
"pygments_lexer": "ipython3",
247+
"version": "3.12.7"
248+
}
249+
},
250+
"nbformat": 4,
251+
"nbformat_minor": 5
252+
}

0 commit comments

Comments
 (0)