Newer
Older
{
"cells": [
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"from pybis import Openbis\n",
"import getpass\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Connecting to openBIS"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"o = Openbis('https://limb.ethz.ch/openbis:8443', verify_certificates=False)"
]
},
{
"cell_type": "code",
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
" ·····················\n"
]
}
],
"source": [
"username = 'hluetcke'\n",
"pw = getpass.getpass()"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"o.login(username, pw, save_token=True) # saves the session token in ~/.pybis/example.com.token\n",
"del pw"
]
},
{
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": [
"'hluetcke-181108105858142x7C2F61FBD12303B58F25E1786983C2BA'"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"o.token"
]
},
{
"cell_type": "code",
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"o.is_session_active()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_datastores()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Masterdata"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
"source": [
"o.get_experiment_types()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_sample_types()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_sample_type('PLATE')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_material_types()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_dataset_types()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_terms()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"obj = o.new_object(type='UNKNOWN', space='MATLAB_TEST', code='12345')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"sample = o.get_sample('/MATLAB_TEST/911922')"
]
},
{
"cell_type": "code",
"source": [
"sample.delete('just a test')"
]
},
{
"cell_type": "markdown",
"metadata": {},
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"counter = 0\n",
"for ds in datasets:\n",
" print(ds)\n",
" counter += 1\n",
" if counter > 10:\n",
" break"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds = o.get_dataset('20101105142049776-6512')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.get_files(start_folder='original')"
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Experiments / collections"
]
},
{
"cell_type": "code",
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>identifier</th>\n",
" <th>permId</th>\n",
" <th>project</th>\n",
" <th>type</th>\n",
" <th>registrator</th>\n",
" <th>registrationDate</th>\n",
" <th>modifier</th>\n",
" <th>modificationDate</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>/MATLAB_TEST/TEST_PROJECT/E1300</td>\n",
" <td>20181106172403609-9285</td>\n",
" <td>TEST_PROJECT</td>\n",
" <td>ISH</td>\n",
" <td>hluetcke</td>\n",
" <td>2018-11-06 17:24:04</td>\n",
" <td>hluetcke</td>\n",
" <td>2018-11-06 17:24:04</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" identifier permId project type registrator registrationDate modifier modificationDate\n",
"-- ------------------------------- ---------------------- ------------ ------ ------------- ------------------- ---------- -------------------\n",
" 0 /MATLAB_TEST/TEST_PROJECT/E1300 20181106172403609-9285 TEST_PROJECT ISH hluetcke 2018-11-06 17:24:04 hluetcke 2018-11-06 17:24:04"
]
},
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"o.get_experiments(\n",
" project='TEST_PROJECT',\n",
" space='MATLAB_TEST'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>attribute</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr> <td>code</td> <td>E1300</td> </tr><tr> <td>permId</td> <td>20181106172403609-9285</td> </tr><tr> <td>identifier</td> <td>/MATLAB_TEST/TEST_PROJECT/E1300</td> </tr><tr> <td>type</td> <td>ISH</td> </tr><tr> <td>project</td> <td>/MATLAB_TEST/TEST_PROJECT</td> </tr><tr> <td>tags</td> <td>['henry', 'test']</td> </tr><tr><td>attachments</td><td></td></tr>\n",
" </tbody>\n",
" </table>\n",
" "
],
"text/plain": [
"attribute value\n",
"----------- -------------------------------\n",
"code E1300\n",
"permId 20181106172403609-9285\n",
"identifier /MATLAB_TEST/TEST_PROJECT/E1300\n",
"type ISH\n",
"project /MATLAB_TEST/TEST_PROJECT\n",
"tags ['henry', 'test']"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"experiment = o.get_experiment('/MATLAB_TEST/TEST_PROJECT/E1300')\n",
"experiment"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"property value\n",
"---------- ----------\n",
"age 3S\n",
"probe VENTROPTIN\n",
"probe_2\n",
"probe_3\n",
"date"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"experiment.props"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"experiment = o.new_experiment(type='METHODS', code='METH123456', project='/MATLAB_TEST/TEST_PROJECT')"
]
},
{
"cell_type": "code",
{
"name": "stdout",
"output_type": "stream",
"text": [
"Experiment successfully created.\n"
]
},
{
"data": {
"text/html": [
"\n",
" <table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>attribute</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr> <td>code</td> <td>METH123456</td> </tr><tr> <td>permId</td> <td>20181108105941662-9286</td> </tr><tr> <td>identifier</td> <td>/MATLAB_TEST/TEST_PROJECT/METH123456</td> </tr><tr> <td>type</td> <td>METHODS</td> </tr><tr> <td>project</td> <td>/MATLAB_TEST/TEST_PROJECT</td> </tr><tr> <td>tags</td> <td>[]</td> </tr><tr><td>attachments</td><td></td></tr>\n",
" </tbody>\n",
" </table>\n",
" "
],
"text/plain": [
"attribute value\n",
"----------- ------------------------------------\n",
"permId 20181108105941662-9286\n",
"identifier /MATLAB_TEST/TEST_PROJECT/METH123456\n",
"type METHODS\n",
"project /MATLAB_TEST/TEST_PROJECT\n",
"tags []"
]
},
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds.download(files='', destination='data', wait_until_finished=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.imshow(plt.imread('data/20101105142920015-6525/original/441_x40001.tif'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_experiment_types()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_dataset_types()"
]
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"o.get_projects(space='MATLAB_TEST', code=None)"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"project = o.new_project(space='MATLAB_TEST', code='ANOTHER_TEST', description='TGIF')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"project.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"project.delete('just a test')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Logout"
]
},
{
"cell_type": "code",
"metadata": {},
"outputs": [],
"source": [
"o.logout()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
}
},
"nbformat": 4,
"nbformat_minor": 2
}